This repository was archived by the owner on Mar 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathoptions.js
More file actions
58 lines (48 loc) · 2.11 KB
/
options.js
File metadata and controls
58 lines (48 loc) · 2.11 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
/*
Grays out or [whatever the opposite of graying out is called] the option
field.
*/
function ghost(isDeactivated) {
options.style.color = isDeactivated ? 'graytext' : 'black';
// The label color.
options.frequency.disabled = isDeactivated; // The control manipulability.
}
var restore_options = function() {
// Initialize the option controls.
options.isActivated.checked = JSON.parse(localStorage.isActivated);
// The display activation.
options.frequency.value = localStorage.frequency;
// The display frequency, in minutes.
options.timeOut.value = localStorage.timeOut;
// The display notification timeOut, in seconds.
options.login.value = localStorage.login; // The user's login.
options.hostname.value = localStorage.hostname; // The hostname.
options.token.value = localStorage.token; // The user's token.
options.showActions.checked = JSON.parse(localStorage.showActions);
// Show user's actions.
if (!options.isActivated.checked) { ghost(true); }
// Set the display activation and frequency.
options.isActivated.onchange = function() {
localStorage.isActivated = options.isActivated.checked;
ghost(!options.isActivated.checked);
};
options.frequency.onchange = function() {
localStorage.frequency = options.frequency.value;
};
options.timeOut.onchange = function() {
localStorage.timeOut = options.timeOut.value;
};
options.login.onchange = function() {
localStorage.login = options.login.value;
};
options.hostname.onchange = function() {
localStorage.hostname = options.hostname.value;
};
options.token.onchange = function() {
localStorage.token = options.token.value;
};
options.showActions.onchange = function() {
localStorage.showActions = options.showActions.checked;
};
};
document.addEventListener('DOMContentLoaded', restore_options);