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' + |