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

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

Issue 2325963003: Add options and a browser-action popup. (Closed) Base URL: https://chromium.googlesource.com/chromium/extensions-by-google.git@master
Patch Set: Comments and copyrights Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: go-back-with-backspace/pages/options.js
diff --git a/go-back-with-backspace/pages/options.js b/go-back-with-backspace/pages/options.js
new file mode 100644
index 0000000000000000000000000000000000000000..488995e9b05c835aed5c90dd46fbfeb8fe5d60d6
--- /dev/null
+++ b/go-back-with-backspace/pages/options.js
@@ -0,0 +1,66 @@
+// Copyright 2016 Google Inc. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Initialize the page.
+function init() {
+ // Load internationalized strings.
+ var all = document.getElementsByTagName('*');
ojan 2016/09/15 19:07:15 ditto
Pam (message me for reviews) 2016/09/16 16:35:13 Done -- and moved into common.js.
+ for (var i = 0; i < all.length; ++i) {
+ var i18n = all[i].getAttribute('i18n');
+ if (i18n)
+ all[i].textContent = chrome.i18n.getMessage(i18n);
+ }
+
+ var blacklist = document.getElementById('blacklist');
+ var checkbox = document.getElementById('disableInApplets');
+ var whitelist = document.getElementById('whitelist');
+
+ // Configure the textboxes, allowing 200 characters for JSON serialization
+ // and key length.
+ blacklist.maxlength = chrome.storage.sync.QUOTA_BYTES_PER_ITEM - 200;
+ whitelist.maxlength = chrome.storage.sync.QUOTA_BYTES_PER_ITEM - 200;
+
+ // Set event handlers.
+ document.getElementById('done_button').onclick = function() {
+ chrome.storage.sync.set({
+ // Split the lists into arrays at whitespace before saving.
+ blacklist:
+ document.getElementById('blacklist').value.split(/\s+/),
+ disableInApplets: document.getElementById('disableInApplets').checked,
+ whitelist:
+ document.getElementById('whitelist').value.split(/\s+/)
+ }, function() {
+ // One easy way to force an error for testing is to change "sync" to
+ // "managed" in the chrome.storage.sync.set() call above.
+ if (chrome.runtime.lastError) {
+ document.getElementById('error').textContent =
+ chrome.i18n.getMessage('errorSaving',
+ chrome.runtime.lastError.message);
+ } else {
+ window.close();
+ }
+ });
+ };
+
+ document.getElementById('cancel_button').onclick = function() {
+ window.close();
+ };
+
+ document.getElementById('report_page').onclick = function() {
+ reportPage();
+ };
+
+ // Load saved settings into the form fields.
+ chrome.storage.sync.get({
+ blacklist: [],
+ disableInApplets: true,
+ whitelist: []
+ }, function(items) {
+ blacklist.value = items.blacklist.join('\n');
+ checkbox.checked = items.disableInApplets;
+ whitelist.value = items.whitelist.join('\n');
+ });
+}
+
+window.addEventListener('load', init, false);

Powered by Google App Engine
This is Rietveld 408576698