Home | History | Annotate | Download | only in static
      1 <link rel="stylesheet" href="css/samples.css" />
      2 <script jscontent="search_data"></script>
      3 <script src="js/sample_search.js"></script>
      4 
      5 <script type="text/prerenderjs">
      6   /**
      7    * The following code is executed before the jstemplate in this file is
      8    * rendered, meaning it can modify template data by changing the pageData
      9    * window variable.  See api_page_generator.js for more information.
     10    *
     11    * Adds the samples manifest data + API modules.
     12    */
     13   pageData.samples = samples;
     14   pageData.api_mapping = apiMapping;
     15   pageData.api_modules = [];
     16   schema.forEach(function(mod) {
     17     if (mod.nodoc) {
     18       return;
     19     }
     20     if (mod.namespace.indexOf('experimental') != -1) {
     21       return;
     22     }
     23     pageData.api_modules.push('chrome.' + mod.namespace);
     24   });
     25   pageData.api_modules.push('chrome.experimental');
     26   pageData.api_modules.sort();
     27 
     28   var search_data = {};
     29   samples.forEach(function(sample) {
     30     search_data[sample.id] = sample.search_string;
     31 
     32     // Change the API calls data to be a mapping of calls to URLs for
     33     // simpler template rendering.
     34     var api_calls = sample.api_calls.slice();
     35     sample.api_calls = [];
     36     api_calls.sort();
     37     for (var i = 0; i < api_calls.length; i++) {
     38       sample.api_calls.push({
     39           'call': api_calls[i],
     40           'url': apiMapping[api_calls[i]]
     41       });
     42     }
     43 
     44     // Change the sample files list to be a mapping of relative paths to URLs
     45     // for simpler template rendering.
     46     var source_files = sample.source_files.slice();
     47     sample.source_files = [];
     48     source_files.sort();
     49     for (var i = 0; i < source_files.length; i++) {
     50       sample.source_files.push({
     51           'file': source_files[i],
     52           'url': 'http://src.chromium.org/viewvc/chrome/trunk' +
     53                  '/src/chrome/common/extensions/docs/' + sample.path +
     54                  source_files[i] + '?content-type=text/plain'
     55       });
     56     }
     57   });
     58 
     59   // The search data should be injected as executable JavaScript, so assign
     60   // a template value which will store the data as a page global.
     61   pageData.search_data = "var search_data = " +
     62                          JSON.stringify(search_data); + ";";
     63 </script>
     64 
     65 <div id="controls">
     66   <div id="searchbox" class="controlbox">
     67     <strong>Filter by keyword:</strong>
     68     <input autofocus type="search" type="text" id="searchinput" placeholder="Type to search" onkeyup="filterSamples();" />
     69     <a id="clearlink" href="javascript:void(0);" onclick="clearFilter();" style="display: none;">clear</a>
     70   </div>
     71 
     72   <div id="filterbox" class="controlbox">
     73     <strong>Filter by API:</strong>
     74     <span jseval="$total=api_modules.length">
     75       <span jsselect="api_modules" >
     76         <a href="javascript:void(0);" jsvalues="onclick:'setFilter(\'' + $this + '\', this)'" jscontent="$this"></a><span jsdisplay="$index != $total - 1">, </span>
     77       </span>
     78     </span>
     79   </div>
     80 </div>
     81 
     82 <div jsselect="samples" jsvalues="id:id" class="sample">
     83   <img jsdisplay="icon != null" class="icon" jsvalues="src:path + icon" />
     84   <img jsdisplay="icon == null" class="icon" src="images/sample-default-icon.png" />
     85   <h2 class="name">
     86     <a jscontent="name" jsvalues="href:'#'+$this.id"></a>
     87   </h2>
     88   <p jsdisplay="features.length > 0" class="metadata features" jseval="$total=features.length">Uses
     89     <span jsselect="features">
     90       <strong jscontent="$this"></strong><span jsdisplay="$index < $total - 2 && $total > 2">, </span>
     91       <span jsdisplay="$index == $total - 2 && $total > 1" > and</span>
     92     </span>
     93   </p>
     94   <p jscontent="description"></p>
     95   <div jsdisplay="api_calls.length > 0" class="apicalls"><strong>Calls:</strong>
     96     <ul>
     97       <li jsselect="api_calls">
     98         <code><a jsvalues="href:$this.url" jscontent="$this.call"></a></code>
     99       </li>
    100     </ul>
    101   </div>
    102   <div jsdisplay="source_files.length > 0" class="sourcefiles"><strong>Source files:</strong>
    103     <ul>
    104       <li jsselect="source_files">
    105         <code><a jsvalues="href:$this.url" jscontent="$this.file" target="_blank"></a></code>
    106       </li>
    107     </ul>
    108   </div>
    109   <div>
    110     <a jsvalues="href:'http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/' + path" target="_blank">Browse source</a>
    111     - <a jsvalues="href:$this.zip_path">Download source</a>
    112   </div>
    113 </div>
    114 
    115 <div id="noresults" style="display:none">
    116   Sorry, no results were found.
    117 </div>
    118