-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
132 lines (118 loc) · 3.79 KB
/
script.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
if (window.screen.width <= 1130) {
function removeall() {
$(".cir_border").css("border", "none");
}
$("#sec").on("click", function () {
removeall();
$("#sec").css("border", "2px solid whitesmoke");
$("#sec").css("border-radius", "20px");
});
$("#pri").on("click", function () {
removeall();
$("#pri").css("border", "2px solid whitesmoke");
$("#pri").css("border-radius", "20px");
});
$("#tri").on("click", function () {
removeall();
$("#tri").css("border", "2px solid whitesmoke");
$("#tri").css("border-radius", "20px");
});
$("#quad").on("click", function () {
removeall();
$("#quad").css("border", "2px solid whitesmoke");
$("#quad").css("border-radius", "20px");
});
$("#quint").on("click", function () {
removeall();
$("#quint").css("border", "2px solid whitesmoke");
$("#quint").css("border-radius", "20px");
});
$("#hex").on("click", function () {
removeall();
$("#hex").css("border", "2px solid whitesmoke");
$("#hex").css("border-radius", "20px");
});
$("#hept").on("click", function () {
removeall();
$("#hept").css("border", "2px solid whitesmoke");
$("#hept").css("border-radius", "20px");
});
}
$("#about").on("mouseover", function () {
introAboutLogoTransition();
});
$("input").on("change", function () {
$("body").toggleClass("blue");
});
// Light/Dark toggle
const checkbox = document.getElementById("checkbox");
function introAboutLogoTransition() {
$("#about-quad").css("top", "70%");
$("#about-quad").css("opacity", "1");
}
function checkDarkMode() {
if (
localStorage.getItem("tourism_website_darkmode") !== null &&
localStorage.getItem("tourism_website_darkmode") === "true"
) {
document.body.classList.add("dark");
checkbox.checked = true;
}
}
checkDarkMode();
checkbox.addEventListener("change", () => {
document.body.classList.toggle("dark");
document.body.classList.contains("dark")
? localStorage.setItem("tourism_website_darkmode", true)
: localStorage.setItem("tourism_website_darkmode", false);
});
// scroll button
let mybutton = document.getElementById("upbtn");
window.onscroll = function () {
scrollFunction();
};
function scrollFunction() {
if (
document.body.scrollTop > 20 ||
document.documentElement.scrollTop > 20
) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
// Update Navbar While Scrolling
function updateNav() {
const sections = document.querySelectorAll("section");
const navLinks = document.querySelectorAll(".nav-links li a");
sections.forEach((section, index) => {
const rect = section.getBoundingClientRect();
if (window.screen.width <= 425) {
if (rect.top <= 1300) {
navLinks.forEach((navLink) => {
navLink.classList.remove("active");
});
navLinks[index].classList.add("active");
}
} else if (425 <= window.screen.width <= 768) {
if (rect.top <= 1250) {
navLinks.forEach((navLink) => {
navLink.classList.remove("active");
});
navLinks[index].classList.add("active");
}
} else {
if (rect.top <= 1000) {
navLinks.forEach((navLink) => {
navLink.classList.remove("active");
});
navLinks[index].classList.add("active");
}
}
});
}
window.addEventListener("scroll", updateNav);