forked from ElijahLynn/devtools-redirect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
44 lines (30 loc) · 1.3 KB
/
options.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//options.js
(function() {
var storage = chrome.storage.sync;
// Saves options to localStorage.
var save_options = function(event) {
var checkbox = document.getElementById("opt-velocity-stacktrace");
storage.set({'opt-velocity-stacktrace': checkbox.checked ? true : false}, function() {
storage.get('opt-velocity-stacktrace', function(opts) { console.log(opts['opt-velocity-stacktrace']); });
// Update status to let user know options were saved.
var status = document.getElementById("status");
status.innerHTML = "Options Saved.";
setTimeout(function() {
status.innerHTML = "";
}, 750);
});
event.preventDefault();
}
// Restores select box state to saved value from localStorage.
var restore_options = function() {
storage.get('opt-velocity-stacktrace', function(opts) { console.log(opts['opt-velocity-stacktrace']); });
var checkbox = document.getElementById("opt-velocity-stacktrace");
storage.get('opt-velocity-stacktrace', function(opts) {
checkbox.checked = opts['opt-velocity-stacktrace'] ? true : false;
});
}
document.addEventListener('DOMContentLoaded', function() {
restore_options();
document.querySelector('#save').addEventListener('click', save_options);
});
})();