aboutsummaryrefslogtreecommitdiffstats
path: root/options.js
diff options
context:
space:
mode:
authorTeddy Wing2014-03-30 14:13:42 -0400
committerTeddy Wing2014-03-30 14:13:42 -0400
commit5e42f11675bb301a4f9329e8e5d50ec136e6f0df (patch)
tree20af7e531690a374001862859e20fbc2d5fcc4a0 /options.js
parentf3da89298d586352066b4f1c6661af3a0abc7f54 (diff)
downloadchrome-copy-urls-from-all-tabs-5e42f11675bb301a4f9329e8e5d50ec136e6f0df.tar.bz2
Update options page
* Copy sample code from the docs http://developer.chrome.com/extensions/options * Include Chrome UI Bootstrap CSS https://github.com/roykolak/chrome-bootstrap
Diffstat (limited to 'options.js')
-rw-r--r--options.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/options.js b/options.js
new file mode 100644
index 0000000..ce07520
--- /dev/null
+++ b/options.js
@@ -0,0 +1,32 @@
+// Saves options to chrome.storage
+function save_options() {
+ var color = document.getElementById('color').value;
+ var likesColor = document.getElementById('like').checked;
+ chrome.storage.sync.set({
+ favoriteColor: color,
+ likesColor: likesColor
+ }, function() {
+ // Update status to let user know options were saved.
+ var status = document.getElementById('status');
+ status.textContent = 'Options saved.';
+ setTimeout(function() {
+ status.textContent = '';
+ }, 750);
+ });
+}
+
+// Restores select box and checkbox state using the preferences
+// stored in chrome.storage.
+function restore_options() {
+ // Use default value color = 'red' and likesColor = true.
+ chrome.storage.sync.get({
+ favoriteColor: 'red',
+ likesColor: true
+ }, function(items) {
+ document.getElementById('color').value = items.favoriteColor;
+ document.getElementById('like').checked = items.likesColor;
+ });
+}
+document.addEventListener('DOMContentLoaded', restore_options);
+document.getElementById('save').addEventListener('click',
+ save_options); \ No newline at end of file