-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.js
65 lines (53 loc) · 2.13 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Saves options to localStorage.
function save_options() {
var u = document.getElementById("xmlurl").value;
localStorage["xmlurl"] = u;
var i = document.getElementById("pollInterval").value;
localStorage["pollinterval"] = i;
var username = document.getElementById("username").value;
localStorage["username"] = username;
var password = document.getElementById("password").value;
localStorage["password"] = password;
var beeponerror = document.getElementById("beeponerror").checked;
localStorage["beeponerror"] = beeponerror;
alert("Settings saved");
//check to see if everything saved correctly
restore_options();
}
// Restores options from localStorage.
function restore_options() {
var u = localStorage["xmlurl"];
if (!u) {
u = "http://192.168.1.3:16001";
}
document.getElementById("xmlurl").value = u;
var i = localStorage["pollinterval"];
if (!i) {
i = 10;
}
document.getElementById("pollInterval").value = i;
var username = localStorage["username"];
if (!username) {
username = "";
}
document.getElementById("username").value = username;
var password = localStorage["password"];
if (!password) {
password = "";
}
document.getElementById("password").value = password;
if ( localStorage["beeponerror"] == "true" ) {
var beeponerror = true;
} else {
var beeponerror = false;
}
document.getElementById("beeponerror").checked = beeponerror;
}
window.addEventListener("load", restore_options);
document.getElementById("savebutton").addEventListener("click",save_options);
// Put all the translated strings into the DOM
document.getElementById("extNameSettingsLabel").innerHTML = chrome.i18n.getMessage("extName") + " " + chrome.i18n.getMessage("settings");
document.getElementById("loginLabel").innerHTML = chrome.i18n.getMessage("login");
document.getElementById("passwordLabel").innerHTML = chrome.i18n.getMessage("password");
document.getElementById("updateIntervalLabel").innerHTML = chrome.i18n.getMessage("updateinterval");
document.getElementById("beeponerrorLabel").innerHTML = chrome.i18n.getMessage("beeponerror");