-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
52 lines (39 loc) · 1.44 KB
/
script.js
File metadata and controls
52 lines (39 loc) · 1.44 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
let copyrightArea = document.getElementsByClassName("copyright-area")[0];
copyrightArea.innerHTML = "Copyright @ " + new Date().getFullYear() + ", <span class='academate'>Order</span>. All rights reserved.";
const toTop = document.querySelector(".to-top");
window.addEventListener("scroll", () => {
if (window.pageYOffset > 100) {
toTop.classList.add("active");
} else {
toTop.classList.remove("active");
}
});
const navBarFun = (toShowOrNot) => {
let secondaryNavMenu = document.getElementById("secondary-nav-links");
if (toShowOrNot == true) {
secondaryNavMenu.style.visibility = "visible";
secondaryNavMenu.style.transform = "translateX(0px)";
} else {
secondaryNavMenu.style.visibility = "hidden";
secondaryNavMenu.style.transform = "translateX(24rem)";
}
}
//theme change
let theme = localStorage.getItem("theme");
let themeChangeCheckbox = document.getElementsByClassName("checkbox")[0];
const themeFunction = () => {
let htmlElement = document.documentElement;
htmlElement.classList.toggle("dark");
}
if (theme == "light") {
themeFunction();
themeChangeCheckbox.checked = true;
}
themeChangeCheckbox.addEventListener("change", () => {
if (themeChangeCheckbox.checked) {
localStorage.setItem("theme", "light");
} else {
localStorage.setItem("theme", "dark");
}
themeFunction();
});