OLD | NEW |
1 <style> | 1 <link rel="stylesheet" href="css/samples.css" /> |
2 a img { | 2 <script jscontent="search_data"></script> |
3 border:0; | 3 <script src="js/sample_search.js"></script> |
4 } | 4 <script src="js/samples.js"></script> |
5 </style> | |
6 | 5 |
7 <div id="pageData-showTOC" class="pageData">true</div> | 6 <script type="text/prerenderjs"> |
| 7 /** |
| 8 * The following code is executed before the jstemplate in this file is |
| 9 * rendered, meaning it can modify template data by changing the pageData |
| 10 * window variable. See api_page_generator.js for more information. |
| 11 * |
| 12 * Adds the samples manifest data + API modules. |
| 13 */ |
| 14 pageData.samples = samples; |
| 15 pageData.api_mapping = apiMapping; |
| 16 pageData.api_modules = []; |
| 17 schema.forEach(function(mod) { |
| 18 if (mod.nodoc) { |
| 19 return; |
| 20 } |
| 21 if (mod.namespace.indexOf('experimental') != -1) { |
| 22 return; |
| 23 } |
| 24 pageData.api_modules.push('chrome.' + mod.namespace); |
| 25 }); |
| 26 pageData.api_modules.push('chrome.experimental'); |
| 27 pageData.api_modules.sort(); |
8 | 28 |
9 <p> | 29 var search_data = {}; |
10 This page shows some sample extensions, | 30 samples.forEach(function(sample) { |
11 with links that let you install them | 31 search_data[sample.id] = sample.search_string; |
12 and find their source code. | |
13 Each sample also has links to the documentation | |
14 for each feature used by the sample. | |
15 </p> | |
16 | 32 |
17 <p><b>Note:</b> To run these samples on Linux or Mac, | 33 // Change the API calls data to be a mapping of calls to URLs for |
18 you need to get on an early access release channel of Google Chrome. | 34 // simpler template rendering. |
19 </p> | 35 var api_calls = sample.api_calls.slice(); |
| 36 sample.api_calls = []; |
| 37 api_calls.sort(); |
| 38 for (var i = 0; i < api_calls.length; i++) { |
| 39 sample.api_calls.push({ |
| 40 'call': api_calls[i], |
| 41 'url': apiMapping[api_calls[i]] |
| 42 }); |
| 43 } |
20 | 44 |
21 <ul> | 45 // Change the sample files list to be a mapping of relative paths to URLs |
22 <li> <b>Windows</b>: Use any release of Google Chrome</li> | 46 // for simpler template rendering. |
23 <li> <b>Linux</b>: Subscribe to the <a href="http://www.google.com/landing/chr
ome/beta/">Beta channel</a> </li> | 47 var source_files = sample.source_files.slice(); |
24 <li> <b>Mac</b>: Subscribe to the <a href="http://www.chromium.org/getting-inv
olved/dev-channel#TOC-Mac">Dev channel</a> </li> | 48 sample.source_files = []; |
25 </ul> | 49 source_files.sort(); |
| 50 for (var i = 0; i < source_files.length; i++) { |
| 51 sample.source_files.push({ |
| 52 'file': source_files[i], |
| 53 'url': 'http://src.chromium.org/viewvc/chrome/trunk' + |
| 54 '/src/chrome/common/extensions/docs/' + sample.path + |
| 55 source_files[i] + '?content-type=text/plain' |
| 56 }); |
| 57 } |
| 58 }); |
26 | 59 |
27 <p> | 60 // The search data should be injected as executable JavaScript, so assign |
28 For more example code, see the | 61 // a template value which will store the data as a page global. |
29 <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extension
s/docs/examples/" target="_blank">Chromium examples directory</a>. | 62 pageData.search_data = "var search_data = " + |
30 For tips on using the code viewer, see | 63 JSON.stringify(search_data); + ";"; |
31 <a href="#viewsource">How to view the source code</a>. | 64 </script> |
32 </p> | |
33 | 65 |
34 <h2 id="featured">Sample extensions</h2> | 66 <div id="controls"> |
| 67 <div id="searchbox" class="controlbox"> |
| 68 <strong>Filter by keyword:</strong> |
| 69 <input autofocus type="search" type="text" id="searchinput" placeholder="Typ
e to search" onkeyup="filterSamples();" /> |
| 70 <a id="clearlink" href="javascript:void(0);" onclick="clearFilter();" style=
"display: none;">clear</a> |
| 71 </div> |
35 | 72 |
36 <h3 id="gmail">Google Mail Checker</h3> | 73 <div id="filterbox" class="controlbox"> |
| 74 <strong>Filter by API:</strong> |
| 75 <span jseval="$total=api_modules.length"> |
| 76 <span jsselect="api_modules" > |
| 77 <a href="javascript:void(0);" jsvalues="onclick:'setFilter(\'' + $this +
'\', this)'" jscontent="$this"></a><span jsdisplay="$index != $total - 1">, </s
pan> |
| 78 </span> |
| 79 </span> |
| 80 </div> |
| 81 </div> |
37 | 82 |
38 <p>Adds a Google Mail button to the toolbar, displaying the number of unread mes
sages in your inbox. Click the button to open your inbox. | 83 <div jsselect="samples" jsvalues="id:id" class="sample"> |
| 84 <img jsdisplay="icon != null" class="icon" jsvalues="src:path + icon" /> |
| 85 <img jsdisplay="icon == null" class="icon" src="images/sample-default-icon.png
" /> |
| 86 <h2 class="name"> |
| 87 <a jscontent="name" jsvalues="href:'http://src.chromium.org/viewvc/chrome/tr
unk/src/chrome/common/extensions/docs/' + path" target="_blank"></a> |
| 88 </h2> |
| 89 <p jsdisplay="features.length > 0" class="metadata features" jseval="$total=fe
atures.length">Uses |
| 90 <span jsselect="features"> |
| 91 <strong jscontent="$this"></strong><span jsdisplay="$index < $total - 2 &&
$total > 2">, </span> |
| 92 <span jsdisplay="$index == $total - 2 && $total > 1" > and</span> |
| 93 </span> |
| 94 </p> |
| 95 <p jscontent="description"></p> |
| 96 <div jsdisplay="api_calls.length > 0" class="apicalls"><strong>Calls:</strong> |
| 97 <ul> |
| 98 <li jsselect="api_calls"> |
| 99 <code><a jsvalues="href:$this.url" jscontent="$this.call"></a></code> |
| 100 </li> |
| 101 </ul> |
| 102 </div> |
| 103 <div jsdisplay="source_files.length > 0" class="sourcefiles"><strong>Source fi
les:</strong> |
| 104 <ul> |
| 105 <li jsselect="source_files"> |
| 106 <code><a jsvalues="href:$this.url" jscontent="$this.file" target="_blank
"></a></code> |
| 107 </li> |
| 108 </ul> |
| 109 </div> |
| 110 </div> |
39 | 111 |
40 <p>Included with no charge is a swell animation when the number of unread items
changes. | 112 <div id="noresults" style="display:none"> |
| 113 Sorry, no results were found. |
| 114 </div> |
41 | 115 |
42 <p><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=
id%3Dmihcahmgecmbnbcchbopgniflfhgnkff%26uc%26lang%3Den-US"><img src="images/goog
le-mail-checker-capture.png" width="243" height="170" style="margin-bottom:0.5em
"></a><br> | |
43 <b><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=
id%3Dmihcahmgecmbnbcchbopgniflfhgnkff%26uc%26lang%3Den-US">Install</a> &nbs
p; | |
44 <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extension
s/docs/examples/extensions/gmail/">Source code</a></b> | |
45 | |
46 <br><br> | |
47 <p>Features used: | |
48 | |
49 <ul> | |
50 <li><a href="browserAction.html">Browser action</a> (with canvas-based animati
on) | |
51 <li><a href="browserAction.html#badge">Badge</a> | |
52 <li><a href="background_pages.html">Background page</a> | |
53 <li><a href="xhr.html">Cross-origin XMLHttpRequest</a> | |
54 <li><a href="tabs.html">Tabs</a> module | |
55 </ul> | |
56 | |
57 <br> | |
58 | |
59 <h3 id="subscribe_page_action">Subscribe in Feed Reader</h3> | |
60 | |
61 <p>Adds a small icon to the address bar when a web page contains a feed that can
be subscribed to. When you click the icon, you'll see a preview of the feed and
have the option to subscribe with the web-based reader of your choice. | |
62 | |
63 <p><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=
id%3Dnlbjncdgjeocebhnmkbbbdekmmmcbfjd%26uc%26lang%3Den-US"><img src="images/subs
cribe-cap1.png" style="margin-bottom:0.5em" width="342" height="165"></a> | |
64 | |
65 <p><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=
id%3Dnlbjncdgjeocebhnmkbbbdekmmmcbfjd%26uc%26lang%3Den-US"><img src="images/subs
cribe-cap2.png" style="margin-bottom:0.5em" width="566" height="327"></a><br> | |
66 <b><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=
id%3Dnlbjncdgjeocebhnmkbbbdekmmmcbfjd%26uc%26lang%3Den-US">Install</a> &nbs
p; <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/test/dat
a/extensions/subscribe_page_action/">Source code</a></b> | |
67 | |
68 <br><br> | |
69 <p>Features used: | |
70 | |
71 <ul> | |
72 <li><a href="pageAction.html">Page action</a> | |
73 <li><a href="background_pages.html">Background page</a> | |
74 <li><a href="content_scripts.html">Content scripts</a> | |
75 <li><a href="messaging.html">Message passing</a> | |
76 <li><a href="xhr.html">Cross-origin XMLHttpRequest</a> | |
77 </ul> | |
78 | |
79 <br> | |
80 | |
81 <h3 id="news">News Reader</h3> | |
82 | |
83 <p>Uses a popup to display the first 5 items from the "Google News - top news" R
SS feed. The popup dynamically resizes itself to fit additional content. | |
84 | |
85 <p><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=
id%3Dmmdhomleggalggemanamhjdhafaabfdi%26uc%26lang%3Den-US"><img src="images/news
.gif" style="margin-bottom:0.5em" width="475" height="346"></a><br> | |
86 | |
87 <b><a href="https://clients2.google.com/service/update2/crx?response=redirect&x=
id%3Dmmdhomleggalggemanamhjdhafaabfdi%26uc%26lang%3Den-US">Install</a> &nbs
p; <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/e
xtensions/docs/examples/extensions/news/">Source code</a></b> | |
88 | |
89 <br><br> | |
90 <p>Features used: | |
91 | |
92 <ul> | |
93 <li><a href="browserAction.html">Browser action</a> | |
94 <li><a href="xhr.html">Cross-origin XMLHttpRequest</a> | |
95 </ul> | |
96 | |
97 <br> | |
98 <h2 id="otherExtensions">Other sample extensions</h2> | |
99 <p>These samples use similar capabilities to the ones above, but to implement di
fferent features.</p> | |
100 <dl> | |
101 <dt>Chromium buildbot monitor</dt> | |
102 <dd>Monitors the Chromium tree status <br /> | |
103 <b><a href="https://clients2.google.com/service/update2/crx?response=redirect&
x=id%3Dafmppjmdopaajlhgcddfhfhfgincjeih%26uc%26lang%3Den-US">Install</a> &n
bsp; <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common
/extensions/docs/examples/extensions/news/">Source code</a></b> | |
104 </dd> | |
105 | |
106 <dt>Mappy</dt> | |
107 <dd>Lets you bring up a map for the first address on any web page <br /> | |
108 <b><a href="https://clients2.google.com/service/update2/crx?response=redirect&
x=id%3Dobjeacibkcphiplbghlbmlbnihbbmfjl%26uc%26lang%3Den-US">Install</a> &n
bsp; <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common
/extensions/docs/examples/extensions/mappy/">Source code</a></b> | |
109 </dd> | |
110 | |
111 <dt>Email this page</dt> | |
112 <dd>Lets you share the current web page by sending it in an email <br /> | |
113 <b><a href="https://clients2.google.com/service/update2/crx?response=redirect&
x=id%3Ddbeoemfhkdniadbojeencpkgmobndpai%26uc%26lang%3Den-US">Install</a> &n
bsp; <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common
/extensions/docs/examples/extensions/email_this_page/">Source code</a></b> | |
114 </dd> | |
115 </dl> | |
116 | |
117 | |
118 <h2 id="viewsource">How to view the source code</h2> | |
119 | |
120 <p> | |
121 The source code links in this page take you to a directory | |
122 (for example, | |
123 <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extension
s/docs/examples/extensions/gmail/">examples/extensions/gmail</a>) | |
124 that lists all the files in an extension. | |
125 To view a file, | |
126 first click its filename. | |
127 If the page that comes up has an <b>as text</b> link, | |
128 click that link to view the page's source code. | |
129 </p> | |
130 | |
131 <p> | |
132 To download the file, | |
133 right-click the <b>download</b> link. | |
134 You can also left-click the <b>download</b> link | |
135 to view the source code for files such as | |
136 <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extension
s/docs/examples/extensions/gmail/manifest.json">manifest.json</a> | |
137 that have no <b>as text</b> link. | |
138 </p> | |
139 | |
140 <p> | |
141 We're working on a way to make it easier to look at the sample source code. | |
142 If you'd like to track our progress, | |
143 put a star by bug <a href="http://code.google.com/p/chromium/issues/detail?id=25
247">25247</a>. | |
144 </p> | |
145 | |
OLD | NEW |