diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-16 08:48:59 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-16 08:48:59 +0000 |
commit | 2e22c0d8a7ed2dcb534f52fca6a900a8a3efd590 (patch) | |
tree | 2e4f3c03e0877d8569db16ca02b8b0df26fb98ce /chrome/common | |
parent | a17778305fbccf854628476181c94f07c9e806b0 (diff) | |
download | chromium_src-2e22c0d8a7ed2dcb534f52fca6a900a8a3efd590.zip chromium_src-2e22c0d8a7ed2dcb534f52fca6a900a8a3efd590.tar.gz chromium_src-2e22c0d8a7ed2dcb534f52fca6a900a8a3efd590.tar.bz2 |
Merge 32674: Remove use of innerHTML and Toolstrips from example
extensions.
BUG=27860,27861
TBR=rafaelw@chromium.org
Review URL: http://codereview.chromium.org/505018
git-svn-id: svn://svn.chromium.org/chrome/branches/249/src@34670 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/extensions/docs/examples/api/i18n/getMessage/icon.png | bin | 0 -> 2809 bytes | |||
-rw-r--r-- | chrome/common/extensions/docs/examples/api/i18n/getMessage/manifest.json | 6 | ||||
-rw-r--r-- | chrome/common/extensions/docs/examples/api/i18n/getMessage/popup.html (renamed from chrome/common/extensions/docs/examples/api/i18n/getMessage/toolstrip.html) | 19 | ||||
-rw-r--r-- | chrome/common/extensions/docs/examples/api/messaging/timer/popup.html | 139 | ||||
-rw-r--r-- | chrome/common/extensions/docs/examples/api/tabs/inspector/tabs_api.html | 7 | ||||
-rw-r--r-- | chrome/common/extensions/docs/examples/extensions/buildbot/popup.html | 35 | ||||
-rw-r--r-- | chrome/common/extensions/docs/examples/tutorials/debugging/hello_world.html | 45 | ||||
-rw-r--r-- | chrome/common/extensions/docs/examples/tutorials/debugging/manifest.json | 11 | ||||
-rw-r--r-- | chrome/common/extensions/docs/examples/tutorials/debugging/my_toolstrip.html | 3 |
9 files changed, 119 insertions, 146 deletions
diff --git a/chrome/common/extensions/docs/examples/api/i18n/getMessage/icon.png b/chrome/common/extensions/docs/examples/api/i18n/getMessage/icon.png Binary files differnew file mode 100644 index 0000000..9a79a46 --- /dev/null +++ b/chrome/common/extensions/docs/examples/api/i18n/getMessage/icon.png diff --git a/chrome/common/extensions/docs/examples/api/i18n/getMessage/manifest.json b/chrome/common/extensions/docs/examples/api/i18n/getMessage/manifest.json index ca7fefd..5b78230 100644 --- a/chrome/common/extensions/docs/examples/api/i18n/getMessage/manifest.json +++ b/chrome/common/extensions/docs/examples/api/i18n/getMessage/manifest.json @@ -3,5 +3,9 @@ "description": "Returns accept languages of the browser", "version": "0.1", "default_locale": "en_US", - "toolstrips": ["toolstrip.html"] + "browser_action": { + "default_title": "Click Me", + "default_icon": "icon.png", + "popup": "popup.html" + } } diff --git a/chrome/common/extensions/docs/examples/api/i18n/getMessage/toolstrip.html b/chrome/common/extensions/docs/examples/api/i18n/getMessage/popup.html index 970651a..f734779 100644 --- a/chrome/common/extensions/docs/examples/api/i18n/getMessage/toolstrip.html +++ b/chrome/common/extensions/docs/examples/api/i18n/getMessage/popup.html @@ -6,23 +6,32 @@ LICENSE file. <html> <head> + <style> +body { + color: black; + width: 300px; +} + </style> <script> + function setChildTextNode(elementId, text) { + document.getElementById(elementId).innerText = text; + } + function init() { - document.getElementById("languageSpan").innerHTML = - chrome.i18n.getMessage("click_here"); + setChildTextNode('languageSpan', chrome.i18n.getMessage("click_here")); } function getAcceptLanguages() { chrome.i18n.getAcceptLanguages(function(languageList) { var languages = languageList.join(","); - document.getElementById("languageSpan").innerHTML = - chrome.i18n.getMessage("chrome_accept_languages", languages); + setChildTextNode('languageSpan', + chrome.i18n.getMessage("chrome_accept_languages", languages)); }) } </script> </head> <body onload="init()"> - <div class="toolstrip-button" onclick="getAcceptLanguages();"> + <div onclick="getAcceptLanguages();"> <span id="languageSpan"></span> </div> </body> diff --git a/chrome/common/extensions/docs/examples/api/messaging/timer/popup.html b/chrome/common/extensions/docs/examples/api/messaging/timer/popup.html index 315baff..ef5bed8 100644 --- a/chrome/common/extensions/docs/examples/api/messaging/timer/popup.html +++ b/chrome/common/extensions/docs/examples/api/messaging/timer/popup.html @@ -1,68 +1,71 @@ -<head>
-<style>
-tr {
- white-space: nowrap;
-}
-.results {
- text-align: right;
- min-width: 6em;
-}
-</style>
-<script>
-// Tests the roundtrip time of sendRquest().
-function testRequest() {
- var results = document.getElementById("resultsRequest");
- results.innerHTML = "running...";
-
- chrome.tabs.getSelected(null, function(tab) {
- var timer = new chromium.Interval();
- timer.start();
-
- chrome.tabs.sendRequest(tab.id, {counter: 1}, function handler(response) {
- if (response.counter < 1000) {
- chrome.tabs.sendRequest(tab.id, {counter: response.counter}, handler);
- } else {
- timer.stop();
- var usec = Math.round(timer.microseconds() / response.counter);
- results.innerHTML = usec + "usec";
- }
- });
- });
-}
-
-// Tests the roundtrip time of Port.postMessage() after opening a channel.
-function testConnect() {
- var results = document.getElementById("resultsConnect");
- results.innerHTML = "running...";
-
- chrome.tabs.getSelected(null, function(tab) {
- var timer = new chromium.Interval();
- timer.start();
-
- var port = chrome.tabs.connect(tab.id);
- port.postMessage({counter: 1});
- port.onMessage.addListener(function getResp(response) {
- if (response.counter < 1000) {
- port.postMessage({counter: response.counter});
- } else {
- timer.stop();
- var usec = Math.round(timer.microseconds() / response.counter);
- results.innerHTML = usec + "usec";
- }
- });
- });
-}
-</script>
-</head>
-<body>
-<table>
- <tr>
- <td><button onclick="testRequest()">Measure sendRequest</button></td>
- <td id="resultsRequest" class="results">(results)</td>
- </tr>
- <tr>
- <td><button onclick="testConnect()">Measure postMessage</button></td>
- <td id="resultsConnect" class="results">(results)</td>
- </tr>
-</table>
-</body>
+<head> +<style> +tr { + white-space: nowrap; +} +.results { + text-align: right; + min-width: 6em; + color: black; +} +</style> +<script> +function setChildTextNode(elementId, text) { + document.getElementById(elementId).innerText = text; +} + +// Tests the roundtrip time of sendRequest(). +function testRequest() { + setChildTextNode("resultsRequest", "running..."); + + chrome.tabs.getSelected(null, function(tab) { + var timer = new chromium.Interval(); + timer.start(); + + chrome.tabs.sendRequest(tab.id, {counter: 1}, function handler(response) { + if (response.counter < 1000) { + chrome.tabs.sendRequest(tab.id, {counter: response.counter}, handler); + } else { + timer.stop(); + var usec = Math.round(timer.microseconds() / response.counter); + setChildTextNode("resultsRequest", usec + "usec"); + } + }); + }); +} + +// Tests the roundtrip time of Port.postMessage() after opening a channel. +function testConnect() { + setChildTextNode("resultsConnect", "running..."); + + chrome.tabs.getSelected(null, function(tab) { + var timer = new chromium.Interval(); + timer.start(); + + var port = chrome.tabs.connect(tab.id); + port.postMessage({counter: 1}); + port.onMessage.addListener(function getResp(response) { + if (response.counter < 1000) { + port.postMessage({counter: response.counter}); + } else { + timer.stop(); + var usec = Math.round(timer.microseconds() / response.counter); + setChildTextNode("resultsConnect", usec + "usec"); + } + }); + }); +} +</script> +</head> +<body> +<table> + <tr> + <td><button onclick="testRequest()">Measure sendRequest</button></td> + <td id="resultsRequest" class="results">(results)</td> + </tr> + <tr> + <td><button onclick="testConnect()">Measure postMessage</button></td> + <td id="resultsConnect" class="results">(results)</td> + </tr> +</table> +</body> diff --git a/chrome/common/extensions/docs/examples/api/tabs/inspector/tabs_api.html b/chrome/common/extensions/docs/examples/api/tabs/inspector/tabs_api.html index e8047ab..159cb27 100644 --- a/chrome/common/extensions/docs/examples/api/tabs/inspector/tabs_api.html +++ b/chrome/common/extensions/docs/examples/api/tabs/inspector/tabs_api.html @@ -131,12 +131,13 @@ function removeTab(tabId) { } function appendToLog(logLine) { - var log = document.getElementById('log'); - log.innerHTML = '<div> > ' + logLine + '</div>' + log.innerHTML; + document.getElementById('log') + .appendChild(document.createElement('div')) + .innerText = "> " + logLine; } function clearLog() { - document.getElementById('log').innerHTML = ''; + document.getElementById('log').innerText = ''; } chrome.windows.onCreated.addListener(function(createInfo) { diff --git a/chrome/common/extensions/docs/examples/extensions/buildbot/popup.html b/chrome/common/extensions/docs/examples/extensions/buildbot/popup.html index d5b913d..607f6a4 100644 --- a/chrome/common/extensions/docs/examples/extensions/buildbot/popup.html +++ b/chrome/common/extensions/docs/examples/extensions/buildbot/popup.html @@ -36,20 +36,34 @@ function updateBotList(text) { } function displayFailures() { - var html = ""; + bots.innerText = ""; + if (failures.length == 0) { - html = "<a href='' onclick='showConsole()' class='open'>" + - "The tree is completely green.</a> (no way!)"; + var anchor = document.createElement("a"); + anchor.addEventListener("click", showConsole); + anchor.className = "open"; + anchor.innerText = "The tree is completely green."; + bots.appendChild(anchor); + bots.appendChild(document.createTextNode(" (no way!)")); } else { - html = "<div><a class='closed' href='' onclick='showFailures()'>" + - "failures:</a></div>"; + var anchor = document.createElement("a"); + anchor.addEventListener("click", showFailures); + anchor.innerText = "failures:"; + var div = document.createElement("div"); + div.appendChild(anchor); + bots.appendChild(div); + failures.forEach(function(bot, i) { - html += "<div class='bot " + bot.color + - "' onclick='showBot(" + i + ")'>" + - bot.title + "</div>"; + var div = document.createElement("div"); + div.className = "bot " + bot.color; + div.addEventListener("click", function() { + // Requires closure for each iteration to retain local value of |i|. + return function() { showBot(i); } + }()); + div.innerText = bot.title; + bots.appendChild(div); }); } - bots.innerHTML = html; } function showURL(url) { @@ -79,7 +93,8 @@ function showFyi() { } function showFailures() { - var url = botRoot + "/waterfall/waterfall?show_events=true&failures_only=true"; + var url = botRoot + + "/waterfall/waterfall?show_events=true&failures_only=true"; showURL(url); } diff --git a/chrome/common/extensions/docs/examples/tutorials/debugging/hello_world.html b/chrome/common/extensions/docs/examples/tutorials/debugging/hello_world.html deleted file mode 100644 index 5cf5fab..0000000 --- a/chrome/common/extensions/docs/examples/tutorials/debugging/hello_world.html +++ /dev/null @@ -1,45 +0,0 @@ -<style> -img { - margin:5px; - border:2px solid black; - vertical-align:middle; - width:75px; - height:75px; -} -</style> - -<script> -var req = new XMLHttpRequest(); -req.open( - "GET", - "http://api.flickr.com/services/rest/?" + - "method=flickr.photos.search&" + - "api_key=90485e931f687a9b9c2a66bf58a3861a&" + - "text=hello%20world&" + - "safe_search=1&" + // 1 is "safe" - "content_type=1&" + // 1 is "photos only" - "sort=relevance&" + // another good one is "interestingness-desc" - "per_page=95", - true); -req.onload = showPhotos; -req.send(null); - -function showPhotos() { - var photos = req.responseXML.getElementsByTagName("photo"); - - for (var i = 0, photo; photo = photos[i]; i++) { - var img = document.createElement("image"); - img.src = constructImageURL(photo); - document.body.appendChild(img); - } -} - -// See: http://www.flickr.com/services/api/misc.urls.html -function constructImageURL(photo) { - return "http://farm" + photo.getAttribute("farm") + - ".static.flickr.com/" + photo.getAttribute("server") + - "/" + photo.getAttribute("id") + - "_" + photo.getAttribute("secret") + - "_s.jpg"; -} -</script> diff --git a/chrome/common/extensions/docs/examples/tutorials/debugging/manifest.json b/chrome/common/extensions/docs/examples/tutorials/debugging/manifest.json deleted file mode 100644 index 3170bf4..0000000 --- a/chrome/common/extensions/docs/examples/tutorials/debugging/manifest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "My First Extension", - "version": "1.0", - "description": "The first extension that I made.", - "toolstrips": [ - "my_toolstrip.html" - ], - "permissions": [ - "http://api.flickr.com/" - ] -} diff --git a/chrome/common/extensions/docs/examples/tutorials/debugging/my_toolstrip.html b/chrome/common/extensions/docs/examples/tutorials/debugging/my_toolstrip.html deleted file mode 100644 index a6b70d5..0000000 --- a/chrome/common/extensions/docs/examples/tutorials/debugging/my_toolstrip.html +++ /dev/null @@ -1,3 +0,0 @@ -<div class="toolstrip-button" onclick="window.open('hello_world.html')"> - <span>Hello, World!</span> -</div> |