-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUtilities.js
More file actions
53 lines (44 loc) · 1.16 KB
/
Utilities.js
File metadata and controls
53 lines (44 loc) · 1.16 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
function LoadStyle(){
if(typeof(Storage) == "undefined"){
console.log("This browser does not support web storage!");
return;
}
var style = localStorage.getItem("style");
if(style === null || style === "dark"){
return "dark";
}else{
return "light";
}
}
function SaveStyle(mode){
if(typeof(Storage) == "undefined"){
console.log("This browser does not support web storage!");
return;
}
if(mode == "light"){
localStorage.setItem("style", "light");
}else if(mode === "dark"){
localStorage.setItem("style", "dark");
}
}
function SetStyle(mode){
if(mode != "light" && mode != "dark"){
console.log("Attempted to set invalid style mode: [" + mode + "]!");
return;
}
document.getElementById('body-main').className = mode;
if(mode == "light"){
document.getElementById('style-button').innerHTML = "Day Mode";
}else if(mode === "dark"){
document.getElementById('style-button').innerHTML = "Night Mode";
}
SaveStyle(mode);
}
function ToggleStyle(){
var currentStyle = LoadStyle();
if(currentStyle === "light"){
SetStyle("dark");
}else if(currentStyle === "dark"){
SetStyle("light");
}
}