-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
48 lines (39 loc) · 1.13 KB
/
script.js
File metadata and controls
48 lines (39 loc) · 1.13 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
const $ = (id) => {
return document.querySelector(id);
}
const $s = (id) => {
return document.querySelectorAll(id);
}
const szabodiv = $("#szabo");
const szantodiv = $("#szanto");
const briefIntro = $s(".brief-intro");
const briefIntroBtn = $s(".brief-intro-btn");
const grayish = "rgb(67, 76, 94)";
briefIntroBtn[0].style = `background-color: ${grayish};`;
szantodiv.style = "display: none;";
const getIndexOf = (arr, item) => {
for (let i = 0; i < arr.length; i++) {
if (arr[i] == item)
return i;
}
return -1;
}
const toggleBriefIntro = (item) => {
const index = getIndexOf(briefIntroBtn, item);
for (let i = 0; i < briefIntroBtn.length; i++) {
if (i == index) {
briefIntro[i].style = "display: block;";
briefIntroBtn[i].style = `background-color: ${grayish};`;
}
else {
briefIntro[i].style = "display: none;";
briefIntroBtn[i].style = `background-color: whitesmoke;`;
}
}
}
briefIntroBtn.forEach(bib => {
bib.addEventListener("click", (e) => {
const t = e.target;
toggleBriefIntro(t);
});
});