-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscript.js
More file actions
199 lines (163 loc) · 6.16 KB
/
Copy pathscript.js
File metadata and controls
199 lines (163 loc) · 6.16 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
const slides = document.querySelectorAll("#tech-carousel img");
let current = 0;
function showNextSlide() {
slides[current].classList.remove("opacity-100");
slides[current].classList.add("opacity-0");
current = (current + 1) % slides.length;
slides[current].classList.remove("opacity-0");
slides[current].classList.add("opacity-100");
}
if (slides.length > 0) {
setInterval(showNextSlide, 3000);
}
function toggleDropdown(id) {
const dropdown = document.getElementById(id);
const isHidden = dropdown.classList.contains("hidden");
document
.querySelectorAll("nav .absolute")
.forEach((el) => el.classList.add("hidden"));
if (isHidden) dropdown.classList.remove("hidden");
}
function toggleMobileMenu() {
document.getElementById("mobileMenu").classList.toggle("hidden");
}
document.addEventListener("click", function (event) {
const nav = document.querySelector("nav");
if (nav && !nav.contains(event.target)) {
document
.querySelectorAll("nav .absolute")
.forEach((el) => el.classList.add("hidden"));
}
});
const iemImages = document.querySelectorAll("#iem-carousel img");
let currentIem = 0;
function showNextIemImage() {
iemImages[currentIem].classList.remove("opacity-100");
iemImages[currentIem].classList.add("opacity-0");
currentIem = (currentIem + 1) % iemImages.length;
iemImages[currentIem].classList.remove("opacity-0");
iemImages[currentIem].classList.add("opacity-100");
}
if (iemImages.length > 0) {
setInterval(showNextIemImage, 5000);
}
const countdownDate = new Date("2026-08-21T09:00:00").getTime();
function updateCountdown() {
const now = new Date().getTime();
const distance = countdownDate - now;
if (distance < 0) {
const container = document.getElementById("countdown-container");
if (container) {
container.innerHTML =
"<p class='text-sm font-bold text-orange-400'>Event is Live!</p>";
}
clearInterval(timerInterval);
return;
}
const d = Math.floor(distance / (1000 * 60 * 60 * 24));
const h = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const m = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
const s = Math.floor((distance % (1000 * 60)) / 1000);
const daysEl = document.getElementById("days");
const hoursEl = document.getElementById("hours");
const minsEl = document.getElementById("minutes");
const secsEl = document.getElementById("seconds");
if (daysEl) daysEl.innerText = d.toString().padStart(2, "0");
if (hoursEl) hoursEl.innerText = h.toString().padStart(2, "0");
if (minsEl) minsEl.innerText = m.toString().padStart(2, "0");
if (secsEl) secsEl.innerText = s.toString().padStart(2, "0");
}
const timerInterval = setInterval(updateCountdown, 1000);
updateCountdown();
if (typeof lucide !== "undefined") {
lucide.createIcons();
}
function setupCarousel(carouselId) {
const carousel = document.getElementById(carouselId);
if (!carousel) return;
const track = carousel.querySelector(".carousel-track");
if (!track) return;
const slides = Array.from(track.children);
if (slides.length === 0) return;
const nextButton = carousel.querySelector("#nextBtn");
const prevButton = carousel.querySelector("#prevBtn");
if (!nextButton || !prevButton) return;
let slideWidth = slides[0].getBoundingClientRect().width;
let currentIndex = 0;
const updateCarouselPosition = () => {
const slidesInView = Math.round(carousel.clientWidth / slideWidth);
currentIndex = Math.max(
0,
Math.min(currentIndex, slides.length - slidesInView),
);
track.style.transform = `translateX(-${currentIndex * slideWidth}px)`;
};
nextButton.addEventListener("click", () => {
const slidesInView = Math.round(carousel.clientWidth / slideWidth);
if (currentIndex < slides.length - slidesInView) {
currentIndex++;
updateCarouselPosition();
}
});
prevButton.addEventListener("click", () => {
if (currentIndex > 0) {
currentIndex--;
updateCarouselPosition();
}
});
window.addEventListener("resize", () => {
slideWidth = slides[0].getBoundingClientRect().width;
updateCarouselPosition();
});
}
function setupSlideshow(containerId, selector, interval) {
const slideshow = document.getElementById(containerId);
if (!slideshow) return;
const elements = slideshow.querySelectorAll(selector);
if (elements.length < 2) return;
let currentIndex = 0;
setInterval(() => {
elements[currentIndex].classList.remove("opacity-100");
elements[currentIndex].classList.add("opacity-0");
currentIndex = (currentIndex + 1) % elements.length;
elements[currentIndex].classList.remove("opacity-0");
elements[currentIndex].classList.add("opacity-100");
}, interval);
}
function toggleModal() {
const modal = document.getElementById("trackModal");
modal.classList.toggle("hidden");
modal.classList.toggle("flex");
document.body.classList.toggle("overflow-hidden");
}
window.onclick = function (event) {
const modal = document.getElementById("trackModal");
if (event.target == modal) {
toggleModal();
}
};
setupCarousel("heritage-carousel");
setupSlideshow("background-slideshow", "img", 5000);
setupSlideshow("video-slideshow", "video", 8000);
// --- Lazy-Load Background Videos ---
function loadLazyVideos() {
const lazyVideos = document.querySelectorAll("video");
lazyVideos.forEach((video) => {
const sources = video.querySelectorAll("source[data-src]");
if (sources.length > 0) {
sources.forEach((source) => {
const dataSrc = source.getAttribute("data-src");
if (dataSrc) {
source.src = dataSrc;
}
});
video.load();
}
});
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", loadLazyVideos);
} else {
loadLazyVideos();
}
// $ `npx @tailwindcss/cli -i ./Output.css -o ./Style.css --watch`