diff options
author | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 21:42:40 +0000 |
---|---|---|
committer | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 21:42:40 +0000 |
commit | ec623dad7b56ca081a8eb5a26dc45d60509f521d (patch) | |
tree | f0fd0558e5d678022a0a4ccd113c1404cc836dca | |
parent | a9781f59ad21eb05f3b9112342d9add8d28906f6 (diff) | |
download | chromium_src-ec623dad7b56ca081a8eb5a26dc45d60509f521d.zip chromium_src-ec623dad7b56ca081a8eb5a26dc45d60509f521d.tar.gz chromium_src-ec623dad7b56ca081a8eb5a26dc45d60509f521d.tar.bz2 |
Remove use of innerHTML and Toolstrips from example extensions
BUG=27860,27861
Review URL: http://codereview.chromium.org/411008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32674 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | 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 | 17 | ||||
-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, 58 insertions, 85 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 100755 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..5f7e2b4 100644 --- a/chrome/common/extensions/docs/examples/api/messaging/timer/popup.html +++ b/chrome/common/extensions/docs/examples/api/messaging/timer/popup.html @@ -6,13 +6,17 @@ tr { .results {
text-align: right;
min-width: 6em;
+ color: black;
}
</style>
<script>
-// Tests the roundtrip time of sendRquest().
+function setChildTextNode(elementId, text) {
+ document.getElementById(elementId).innerText = text;
+}
+
+// Tests the roundtrip time of sendRequest().
function testRequest() {
- var results = document.getElementById("resultsRequest");
- results.innerHTML = "running...";
+ setChildTextNode("resultsRequest", "running...");
chrome.tabs.getSelected(null, function(tab) {
var timer = new chromium.Interval();
@@ -24,7 +28,7 @@ function testRequest() { } else {
timer.stop();
var usec = Math.round(timer.microseconds() / response.counter);
- results.innerHTML = usec + "usec";
+ setChildTextNode("resultsRequest", usec + "usec");
}
});
});
@@ -32,8 +36,7 @@ function testRequest() { // Tests the roundtrip time of Port.postMessage() after opening a channel.
function testConnect() {
- var results = document.getElementById("resultsConnect");
- results.innerHTML = "running...";
+ setChildTextNode("resultsConnect", "running...");
chrome.tabs.getSelected(null, function(tab) {
var timer = new chromium.Interval();
@@ -47,7 +50,7 @@ function testConnect() { } else {
timer.stop();
var usec = Math.round(timer.microseconds() / response.counter);
- results.innerHTML = usec + "usec";
+ setChildTextNode("resultsConnect", usec + "usec");
}
});
});
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..11b2b40 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> |