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

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

Issue 2400303003: Update UI and catch executeScript errors now shown in Canary (Closed)
Patch Set: Review feedback applied 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 Google Inc. All rights reserved. 1 // Copyright 2016 Google Inc. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Disable the whitelist field when it's not relevant.
6 function updateEnabledInputs() {
7 $('whitelist').disabled = !$('disableInApplets').checked;
8 }
9
5 // Initialize the page. 10 // Initialize the page.
6 function init() { 11 function init() {
7 LoadInternationalizedStrings(); 12 loadInternationalizedStrings();
8
9 var blacklist = document.getElementById('blacklist');
10 var checkbox = document.getElementById('disableInApplets');
11 var whitelist = document.getElementById('whitelist');
12 13
13 // Configure the textboxes, allowing 200 characters for JSON serialization 14 // Configure the textboxes, allowing 200 characters for JSON serialization
14 // and key length. 15 // and key length.
15 blacklist.maxlength = chrome.storage.sync.QUOTA_BYTES_PER_ITEM - 200; 16 $('blacklist').maxlength = chrome.storage.sync.QUOTA_BYTES_PER_ITEM - 200;
16 whitelist.maxlength = chrome.storage.sync.QUOTA_BYTES_PER_ITEM - 200; 17 $('whitelist').maxlength = chrome.storage.sync.QUOTA_BYTES_PER_ITEM - 200;
17 18
18 // Set event handlers. 19 // Set event handlers.
19 document.getElementById('done_button').onclick = function() { 20 $('done-button').onclick = function() {
20 chrome.storage.sync.set({ 21 chrome.storage.sync.set({
21 // Split the lists into arrays at whitespace before saving. 22 // Split the lists into arrays at whitespace before saving.
22 blacklist: 23 blacklist: $('blacklist').value.split(/\s+/),
23 document.getElementById('blacklist').value.split(/\s+/), 24 disableInApplets: $('disableInApplets').checked,
24 disableInApplets: document.getElementById('disableInApplets').checked, 25 whitelist: $('whitelist').value.split(/\s+/)
25 whitelist:
26 document.getElementById('whitelist').value.split(/\s+/)
27 }, function() { 26 }, function() {
28 // One easy way to force an error for testing is to change "sync" to 27 // One easy way to force an error for testing is to change "sync" to
29 // "managed" in the chrome.storage.sync.set() call above. 28 // "managed" in the chrome.storage.sync.set() call above.
30 if (chrome.runtime.lastError) { 29 if (chrome.runtime.lastError) {
31 document.getElementById('error').textContent = 30 $('error').textContent =
32 chrome.i18n.getMessage('errorSaving', 31 chrome.i18n.getMessage('errorSaving',
33 chrome.runtime.lastError.message); 32 chrome.runtime.lastError.message);
34 } else { 33 } else {
35 window.close(); 34 window.close();
36 } 35 }
37 }); 36 });
38 }; 37 };
39 38
40 document.getElementById('cancel_button').onclick = function() { 39 $('disableInApplets').onchange = updateEnabledInputs;
41 window.close(); 40 $('cancel-button').onclick = window.close.bind(window);
42 }; 41 $('feedback-link').onclick = function() {
Devlin 2016/11/05 02:18:21 why not just = sendFeedback?
Pam (message me for reviews) 2016/11/05 04:12:56 sendFeedback takes an optional argument: if it's p
Devlin 2016/11/05 04:56:09 Whoops, missed your reply, sorry for the repeat!
43 42 sendFeedback();
44 document.getElementById('report_page').onclick = function() {
45 reportPage();
46 }; 43 };
47 44
48 // Load saved settings into the form fields. 45 // Load saved settings into the form fields.
49 chrome.storage.sync.get({ 46 chrome.storage.sync.get({
50 blacklist: [], 47 blacklist: [],
51 disableInApplets: true, 48 disableInApplets: true,
52 whitelist: [] 49 whitelist: []
53 }, function(items) { 50 }, function(items) {
54 blacklist.value = items.blacklist.join('\n'); 51 $('blacklist').value = items.blacklist.join('\n');
55 checkbox.checked = items.disableInApplets; 52 $('disableInApplets').checked = items.disableInApplets;
56 whitelist.value = items.whitelist.join('\n'); 53 $('whitelist').value = items.whitelist.join('\n');
54
55 updateEnabledInputs();
57 }); 56 });
58 } 57 }
59 58
60 window.addEventListener('load', init, false); 59 window.addEventListener('load', init);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698