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

Unified Diff: go-back-with-backspace/pages/common.js

Issue 2400303003: Update UI and catch executeScript errors now shown in Canary (Closed)
Patch Set: Add TODO to validate URLs Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « go-back-with-backspace/manifest.json ('k') | go-back-with-backspace/pages/feedback.png » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go-back-with-backspace/pages/common.js
diff --git a/go-back-with-backspace/pages/common.js b/go-back-with-backspace/pages/common.js
index 9fb28c52b55789d3514c40c499cda60951205af7..d0e32e4d34ee62d9b1597a14fa1b0443db06c8d3 100644
--- a/go-back-with-backspace/pages/common.js
+++ b/go-back-with-backspace/pages/common.js
@@ -2,26 +2,35 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// Define the customary shorthand for getElementById.
+var $ = document.getElementById.bind(document);
+
// Load strings from messages.json into the HTML page. Each element that needs
// an internationalized string should have an 'i18n' property holding the
-// name of the message to be used.
-function LoadInternationalizedStrings() {
+// name of the message to be used. If the element instead has an 'i18n-alt'
+// property, that message will be used for the alt and title attributes of the
+// element (generally an image).
+function loadInternationalizedStrings() {
var all = document.querySelectorAll('[i18n]');
+ for (var i = 0; i < all.length; ++i)
+ all[i].textContent = chrome.i18n.getMessage(all[i].getAttribute('i18n'));
+
+ all = document.querySelectorAll('[i18n-alt]');
for (var i = 0; i < all.length; ++i) {
- var i18n = all[i].getAttribute('i18n');
- if (i18n)
- all[i].textContent = chrome.i18n.getMessage(i18n);
+ var message = chrome.i18n.getMessage(all[i].getAttribute('i18n-alt'));
+ all[i].alt = message;
+ all[i].title = message;
}
}
// Open a pre-filled email to send feedback to the extension developers. The
// initial content of the email depends on whether the URL of the current page
// is provided.
-function reportPage(url) {
+function sendFeedback(opt_url) {
var subject = chrome.i18n.getMessage('reportSubject');
var body = '';
- if (url)
- body = chrome.i18n.getMessage('reportBodyWithURL', url);
+ if (opt_url)
+ body = chrome.i18n.getMessage('reportBodyWithURL', opt_url);
else
body = chrome.i18n.getMessage('reportBody');
var msg = 'mailto:gobackwithbackspace@google.com' +
« no previous file with comments | « go-back-with-backspace/manifest.json ('k') | go-back-with-backspace/pages/feedback.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698