| 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
|
| index 9ff25d65f1c7564e76834ea643093fd4fa7893ba..dfb03dcea49e0f2880b680d0039e7dfba94c7fe3 100644
|
| --- a/go-back-with-backspace/pages/options.js
|
| +++ b/go-back-with-backspace/pages/options.js
|
| @@ -2,33 +2,34 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +// Disable the whitelist field when it's not relevant.
|
| +function updateEnabledInputs() {
|
| + $('whitelist').disabled = !$('disableInApplets').checked;
|
| +}
|
| +
|
| // Initialize the page.
|
| function init() {
|
| - LoadInternationalizedStrings();
|
| -
|
| - var blacklist = document.getElementById('blacklist');
|
| - var checkbox = document.getElementById('disableInApplets');
|
| - var whitelist = document.getElementById('whitelist');
|
| + loadInternationalizedStrings();
|
|
|
| // 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;
|
| + $('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() {
|
| + $('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+/)
|
| + // TODO: Validate the items as URLs and display a warning in case of
|
| + // errors.
|
| + blacklist: $('blacklist').value.split(/\s+/),
|
| + disableInApplets: $('disableInApplets').checked,
|
| + whitelist: $('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 =
|
| + $('error').textContent =
|
| chrome.i18n.getMessage('errorSaving',
|
| chrome.runtime.lastError.message);
|
| } else {
|
| @@ -37,12 +38,10 @@ function init() {
|
| });
|
| };
|
|
|
| - document.getElementById('cancel_button').onclick = function() {
|
| - window.close();
|
| - };
|
| -
|
| - document.getElementById('report_page').onclick = function() {
|
| - reportPage();
|
| + $('disableInApplets').onchange = updateEnabledInputs;
|
| + $('cancel-button').onclick = window.close.bind(window);
|
| + $('feedback-link').onclick = function() {
|
| + sendFeedback();
|
| };
|
|
|
| // Load saved settings into the form fields.
|
| @@ -51,10 +50,12 @@ function init() {
|
| disableInApplets: true,
|
| whitelist: []
|
| }, function(items) {
|
| - blacklist.value = items.blacklist.join('\n');
|
| - checkbox.checked = items.disableInApplets;
|
| - whitelist.value = items.whitelist.join('\n');
|
| + $('blacklist').value = items.blacklist.join('\n');
|
| + $('disableInApplets').checked = items.disableInApplets;
|
| + $('whitelist').value = items.whitelist.join('\n');
|
| +
|
| + updateEnabledInputs();
|
| });
|
| }
|
|
|
| -window.addEventListener('load', init, false);
|
| +window.addEventListener('load', init);
|
|
|