OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 Google Inc. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Initialize the page. |
| 6 function init() { |
| 7 LoadInternationalizedStrings(); |
| 8 |
| 9 var blacklist = document.getElementById('blacklist'); |
| 10 var checkbox = document.getElementById('disableInApplets'); |
| 11 var whitelist = document.getElementById('whitelist'); |
| 12 |
| 13 // Configure the textboxes, allowing 200 characters for JSON serialization |
| 14 // and key length. |
| 15 blacklist.maxlength = chrome.storage.sync.QUOTA_BYTES_PER_ITEM - 200; |
| 16 whitelist.maxlength = chrome.storage.sync.QUOTA_BYTES_PER_ITEM - 200; |
| 17 |
| 18 // Set event handlers. |
| 19 document.getElementById('done_button').onclick = function() { |
| 20 chrome.storage.sync.set({ |
| 21 // Split the lists into arrays at whitespace before saving. |
| 22 blacklist: |
| 23 document.getElementById('blacklist').value.split(/\s+/), |
| 24 disableInApplets: document.getElementById('disableInApplets').checked, |
| 25 whitelist: |
| 26 document.getElementById('whitelist').value.split(/\s+/) |
| 27 }, function() { |
| 28 // 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 if (chrome.runtime.lastError) { |
| 31 document.getElementById('error').textContent = |
| 32 chrome.i18n.getMessage('errorSaving', |
| 33 chrome.runtime.lastError.message); |
| 34 } else { |
| 35 window.close(); |
| 36 } |
| 37 }); |
| 38 }; |
| 39 |
| 40 document.getElementById('cancel_button').onclick = function() { |
| 41 window.close(); |
| 42 }; |
| 43 |
| 44 document.getElementById('report_page').onclick = function() { |
| 45 reportPage(); |
| 46 }; |
| 47 |
| 48 // Load saved settings into the form fields. |
| 49 chrome.storage.sync.get({ |
| 50 blacklist: [], |
| 51 disableInApplets: true, |
| 52 whitelist: [] |
| 53 }, function(items) { |
| 54 blacklist.value = items.blacklist.join('\n'); |
| 55 checkbox.checked = items.disableInApplets; |
| 56 whitelist.value = items.whitelist.join('\n'); |
| 57 }); |
| 58 } |
| 59 |
| 60 window.addEventListener('load', init, false); |
OLD | NEW |