This repository was archived by the owner on Oct 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoptions.js
More file actions
42 lines (34 loc) · 1.4 KB
/
options.js
File metadata and controls
42 lines (34 loc) · 1.4 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
function saveOptions() {
saveToLocalStorage();
var status = document.getElementById("status");
status.innerHTML = "Options Saved.";
setTimeout(function() {
status.innerHTML = "";
}, 750);
}
function saveToLocalStorage() {
localStorage["showPublic"] = document.getElementById("public").checked + "";
localStorage["showProtected"] = document.getElementById("protected").checked + "";
localStorage["showNone"] = document.getElementById("none").checked + "";
localStorage["showPrivate"] = document.getElementById("private").checked + "";
}
function restoreOptions() {
var showPublic = localStorage["showPublic"];
var showProtected = localStorage["showProtected"];
var showNone = localStorage["showNone"];
var showPrivate = localStorage["showPrivate"];
if (showPublic === undefined || showProtected === undefined
|| showNone === undefined || showPrivate === undefined) {
showPublic = "true";
showProtected = showNone = showPrivate = "false";
}
document.getElementById("public").checked = (showPublic == "true");
document.getElementById("protected").checked = (showProtected == "true");
document.getElementById("none").checked = (showNone == "true");
document.getElementById("private").checked = (showPrivate == "true");
saveToLocalStorage();
}
(function() {
restoreOptions();
document.getElementById("saveButton").addEventListener("click", saveOptions);
})();