1 /* Copyright (c) 2014 The Chromium Authors. 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 // Saves options to chrome.storage 6 function save_options() { 7 var border = document.getElementById('border').checked; 8 chrome.storage.sync.set({ 9 addBorder: border 10 }, function() { 11 // Update status to let user know options were saved. 12 var status = document.getElementById('status'); 13 status.textContent = 'Options saved.'; 14 setTimeout(function() { 15 status.textContent = ''; 16 }, 750); 17 }); 18 } 19 20 // Restores select box and checkbox state using the preferences 21 // stored in chrome.storage. 22 function restore_options() { 23 // Use default value addBOrder = false. 24 chrome.storage.sync.get("addBorder", function(item) { 25 document.getElementById('border').checked = item.addBorder; 26 }); 27 } 28 29 document.addEventListener('DOMContentLoaded', restore_options); 30 document.getElementById('border').addEventListener('click', save_options); 31