-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.js
More file actions
40 lines (32 loc) · 951 Bytes
/
options.js
File metadata and controls
40 lines (32 loc) · 951 Bytes
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
var defaultAction = "red";
$(()=>{
var favAction = localStorage["action"];
// valid colors are red, blue, green and yellow
if (favAction == undefined || (favAction != "red" && favAction != "hide")) {
favAction = defaultAction;
}
var select = document.getElementById("action");
for (var i = 0; i < select.children.length; i++) {
var child = select.children[i];
if (child.value == favAction) {
child.selected = "true";
break;
}
}
$("#action").change(()=>{
saveOptions();
});
});
function saveOptions() {
var select = document.getElementById("action");
var action = select.children[select.selectedIndex].value;
localStorage["action"] = action;
chrome.storage.sync.set({"action": action}, function() {
console.log('Saved', "action", action);
$(".saved").show().delay(2000).hide(100);
});
}
function eraseOptions() {
localStorage.removeItem("action");
location.reload();
}