-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript.js
54 lines (47 loc) · 1.15 KB
/
javascript.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
const thms = ["josefin", "comic"];
function removeTheme(){
var b = document.getElementById("body");
for (let i = 0; i < thms.length; i++){
b.classList.remove(thms[i]);
}
}
setTheme()
function setTheme(){
var b = document.getElementById("body");
if (thms.indexOf(localStorage.theme) == -1){
localStorage.theme = thm[0];
}
removeTheme();
b.classList.add(localStorage.theme);
}
function switchTheme(themename){
var b = document.getElementById("body");
removeTheme();
b.classList.add(themename);
localStorage.theme = themename;
}
function toggleTheme(){
var currenttheme = thms.indexOf(localStorage.theme);
if (currenttheme == -1){
switchTheme(thms[1]);
}
else if (currenttheme == thms.length - 1){
switchTheme(thms[0]);
}
else{
switchTheme(thms[currenttheme + 1]);
}
}
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
}