Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: chrome/common/extensions/docs/server2/templates/articles/options.html

Issue 10832042: Extensions Docs Server: Doc conversion script (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: script/build.py fixes Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <h1 class="page_title">Options</h1>
2 <p>To allow users to customize the behavior of your extension, you may wish to p rovide an options page. If you do, a link to it will be provided from the extens ions management page at chrome://extensions. Clicking the Options link opens a n ew tab pointing at your options page.
3 <h2>Step 1: Declare your options page in the manifest</h2>
4 <pre>{
5 "name": "My extension",
6 ...
7 <b>"options_page": "options.html"</b>,
8 ...
9 }</pre>
10 <h2>Step 2: Write your options page</h2>
11 Here is an example options page:
12 <pre>// Save this script as `options.js`
13 // Saves options to localStorage.
14 function save_options() {
15 var select = document.getElementById("color");
16 var color = select.children[select.selectedIndex].value;
17 localStorage["favorite_color"] = color;
18 // Update status to let user know options were saved.
19 var status = document.getElementById("status");
20 status.innerHTML = "Options Saved.";
21 setTimeout(function() {
22 status.innerHTML = "";
23 }, 750);
24 }
25 // Restores select box state to saved value from localStorage.
26 function restore_options() {
27 var favorite = localStorage["favorite_color"];
28 if (!favorite) {
29 return;
30 }
31 var select = document.getElementById("color");
32 for (var i = 0; i &lt; select.children.length; i++) {
33 var child = select.children[i];
34 if (child.value == favorite) {
35 child.selected = "true";
36 break;
37 }
38 }
39 }
40 document.addEventListener('DOMContentReady', restore_options);
41 document.querySelector('#save').addEventListener('click', save_options);
42 </pre>
43 <pre>
44 &lt;html>
45 &lt;head>&lt;title>My Test Extension Options&lt;/title>&lt;/head>
46 &lt;script src="options.js">
47 &lt;body>
48 Favorite Color:
49 &lt;select id="color">
50 &lt;option value="red">red&lt;/option>
51 &lt;option value="green">green&lt;/option>
52 &lt;option value="blue">blue&lt;/option>
53 &lt;option value="yellow">yellow&lt;/option>
54 &lt;/select>
55 &lt;br>
56 &lt;div id="status">&lt;/div>
57 &lt;button id="save">Save&lt;/button>
58 &lt;/body>
59 &lt;/html>
60 </pre>
61 <h2>Important notes</h2>
62 <ul>
63 <li>We plan on providing some default css styles to encourage a consistent look across different extensions' options pages. You can star <a href="http://crbug.c om/25317">crbug.com/25317</a> to be notified of updates.</li>
64 </ul>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698