-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
79 lines (69 loc) · 2.08 KB
/
index.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
let physics, computer, math, complex;
let physicsContent, computerContent, mathContent, complexContent;
function toggle(topic) {
if (topic == "physics") {
physics = !physics
}
if (topic == "computer") {
computer = !computer
}
if (topic == "math") {
math = !math
}
if (topic == "complex") {
complex = !complex
}
changeContents();
}
function changeContents() {
if (physics) {
for (let i = 0; i < physicsContent.length; i++) {
physicsContent[i].style.display = "block";
}
} else {
for (let i = 0; i < physicsContent.length; i++) {
physicsContent[i].style.display = "none";
}
}
if (computer) {
for (let i = 0; i < computerContent.length; i++) {
computerContent[i].style.display = "block";
}
}
else {
for (let i = 0; i < computerContent.length; i++) {
computerContent[i].style.display = "none";
}
}
if (math) {
for (let i = 0; i < mathContent.length; i++) {
mathContent[i].style.display = "block";
}
}
else {
for (let i = 0; i < mathContent.length; i++) {
mathContent[i].style.display = "none";
}
}
if (complex) {
for (let i = 0; i < complexContent.length; i++) {
complexContent[i].style.display = "block";
}
}
else {
for (let i = 0; i < complexContent.length; i++) {
complexContent[i].style.display = "none";
}
}
}
window.onload = function () {
physics = document.getElementById("physics-check").checked;
computer = document.getElementById("computer-check").checked;
math = document.getElementById("math-check").checked;
complex = document.getElementById("complex-check").checked;
physicsContent = document.getElementsByClassName("physics");
computerContent = document.getElementsByClassName("computer");
mathContent = document.getElementsByClassName("math");
complexContent = document.getElementsByClassName("complex");
changeContents();
}