-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.js
More file actions
30 lines (25 loc) · 768 Bytes
/
options.js
File metadata and controls
30 lines (25 loc) · 768 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
var defaultColor = "blue";
function loadOptions() {
var favColor = localStorage["favColor"];
// valid colors are red, blue, green and yellow
if (favColor == undefined || (favColor != "red" && favColor != "blue" && favColor != "green" && favColor != "yellow")) {
favColor = defaultColor;
}
var select = document.getElementById("color");
for (var i = 0; i < select.children.length; i++) {
var child = select.children[i];
if (child.value == favColor) {
child.selected = "true";
break;
}
}
}
function saveOptions() {
var select = document.getElementById("color");
var color = select.children[select.selectedIndex].value;
localStorage["favColor"] = color;
}
function eraseOptions() {
localStorage.removeItem("favColor");
location.reload();
}