-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.js
More file actions
executable file
·62 lines (46 loc) · 1.63 KB
/
Copy pathoptions.js
File metadata and controls
executable file
·62 lines (46 loc) · 1.63 KB
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
// Saves options to localStorage.
function save_options() {
var jiveurl = document.getElementById("jiveurl").value;
localStorage["jiveurl"] = jiveurl;
var pollingfrequency = document.getElementById("polling-frequency").value;
if (pollingfrequency < 1000)
{
console.log ("polling too low")
var status = document.getElementById("status");
status.style.color = 'red';
status.innerHTML = "ERROR: Polling Frequency cannot be less than 1000 (milliseconds)";
setTimeout(function() {
status.innerHTML = "";
status.style.color = null;
}, 5000);
}else
{
localStorage["polling-frequency"] = pollingfrequency;
// Update status to let user know options were saved.
var status = document.getElementById("status");
status.innerHTML = "Options Saved.";
setTimeout(function() {
status.innerHTML = "";
}, 5000);
chrome.runtime.sendMessage({savedOptions: true}, function(response) {
console.log(response)
});
}
}
// Restores select box state to saved value from localStorage.
function restore_options() {
var jiveurl = localStorage["jiveurl"];
if (!jiveurl) {
return;
}
var select = document.getElementById("jiveurl");
select.value = localStorage["jiveurl"];
var pollingfrequency = localStorage["polling-frequency"];
if (!pollingfrequency) {
return;
}
var select = document.getElementById("polling-frequency");
select.value = localStorage["polling-frequency"];
}
document.addEventListener('DOMContentLoaded', restore_options);
document.querySelector('#save').addEventListener('click', save_options);