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

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: 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 unified diff | Download patch
« no previous file with comments | « go-back-with-backspace/pages/options.html ('k') | go-back-with-backspace/pages/popup.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // TODO: Validate the items as URLs and display a warning in case of
23 document.getElementById('blacklist').value.split(/\s+/), 24 // errors.
24 disableInApplets: document.getElementById('disableInApplets').checked, 25 blacklist: $('blacklist').value.split(/\s+/),
25 whitelist: 26 disableInApplets: $('disableInApplets').checked,
26 document.getElementById('whitelist').value.split(/\s+/) 27 whitelist: $('whitelist').value.split(/\s+/)
27 }, function() { 28 }, function() {
28 // One easy way to force an error for testing is to change "sync" to 29 // One easy way to force an error for testing is to change "sync" to
29 // "managed" in the chrome.storage.sync.set() call above. 30 // "managed" in the chrome.storage.sync.set() call above.
30 if (chrome.runtime.lastError) { 31 if (chrome.runtime.lastError) {
31 document.getElementById('error').textContent = 32 $('error').textContent =
32 chrome.i18n.getMessage('errorSaving', 33 chrome.i18n.getMessage('errorSaving',
33 chrome.runtime.lastError.message); 34 chrome.runtime.lastError.message);
34 } else { 35 } else {
35 window.close(); 36 window.close();
36 } 37 }
37 }); 38 });
38 }; 39 };
39 40
40 document.getElementById('cancel_button').onclick = function() { 41 $('disableInApplets').onchange = updateEnabledInputs;
41 window.close(); 42 $('cancel-button').onclick = window.close.bind(window);
42 }; 43 $('feedback-link').onclick = function() {
43 44 sendFeedback();
44 document.getElementById('report_page').onclick = function() {
45 reportPage();
46 }; 45 };
47 46
48 // Load saved settings into the form fields. 47 // Load saved settings into the form fields.
49 chrome.storage.sync.get({ 48 chrome.storage.sync.get({
50 blacklist: [], 49 blacklist: [],
51 disableInApplets: true, 50 disableInApplets: true,
52 whitelist: [] 51 whitelist: []
53 }, function(items) { 52 }, function(items) {
54 blacklist.value = items.blacklist.join('\n'); 53 $('blacklist').value = items.blacklist.join('\n');
55 checkbox.checked = items.disableInApplets; 54 $('disableInApplets').checked = items.disableInApplets;
56 whitelist.value = items.whitelist.join('\n'); 55 $('whitelist').value = items.whitelist.join('\n');
56
57 updateEnabledInputs();
57 }); 58 });
58 } 59 }
59 60
60 window.addEventListener('load', init, false); 61 window.addEventListener('load', init);
OLDNEW
« no previous file with comments | « go-back-with-backspace/pages/options.html ('k') | go-back-with-backspace/pages/popup.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698