-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathoptions.js
42 lines (36 loc) · 1.22 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
document.addEventListener("DOMContentLoaded", function(){
restoreOptions();
document.getElementById("SaveButton").addEventListener('click', saveOptions, false);
});
var selectReqInterval;
var radioBackgroundTabs;
function initVariables() {
selectReqInterval = document.getElementById("RequestInterval");
radioBackgroundTabs = document.getElementsByName("BackgroundTabs");
}
function restoreOptions() {
initVariables();
var reqInterval = localStorage["HN.RequestInterval"];
for (var i=0; i<selectReqInterval.children.length; i++) {
if (selectReqInterval[i].value == reqInterval) {
selectReqInterval[i].selected = "true";
break;
}
}
var backgroundTabs = localStorage["HN.BackgroundTabs"];
for (var i=0; i<radioBackgroundTabs.length; i++) {
if (radioBackgroundTabs[i].value == backgroundTabs) {
radioBackgroundTabs[i].checked = "true";
}
}
}
function saveOptions() {
var interval = selectReqInterval.children[selectReqInterval.selectedIndex].value;
localStorage["HN.RequestInterval"] = interval;
for (var i=0; i<radioBackgroundTabs.length; i++) {
if (radioBackgroundTabs[i].checked) {
localStorage["HN.BackgroundTabs"] = radioBackgroundTabs[i].value;
break;
}
}
}