-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
81 lines (69 loc) · 2.3 KB
/
Copy pathscript.js
File metadata and controls
81 lines (69 loc) · 2.3 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
const yearEl = document.getElementById("year");
if (yearEl) {
yearEl.textContent = new Date().getFullYear();
}
const overlay = document.getElementById("videoOverlay");
const enterButton = document.getElementById("enterButton");
const splashVideo = document.getElementById("splashVideo");
const splashStorageKey = "parteeSplashTimestamp";
const dayMs = 24 * 60 * 60 * 1000;
function hideOverlay() {
if (!overlay) {
return;
}
overlay.classList.add("fade-out");
window.setTimeout(() => {
overlay.remove();
}, 850);
}
if (overlay && enterButton) {
const lastShownRaw = localStorage.getItem(splashStorageKey);
const lastShown = lastShownRaw ? Number.parseInt(lastShownRaw, 10) : 0;
const now = Date.now();
if (lastShown && now - lastShown < dayMs) {
overlay.remove();
} else {
enterButton.addEventListener("click", () => {
localStorage.setItem(splashStorageKey, String(Date.now()));
hideOverlay();
if (splashVideo && !splashVideo.paused) {
splashVideo.pause();
}
});
}
}
const heroTabButtons = Array.from(document.querySelectorAll(".hero-link"));
const heroTabPanels = Array.from(document.querySelectorAll(".hero-copy"));
function activateHeroTab(tabId) {
heroTabButtons.forEach((button) => {
const isActive = button.dataset.tab === tabId;
button.classList.toggle("active", isActive);
button.setAttribute("aria-selected", isActive ? "true" : "false");
});
heroTabPanels.forEach((panel) => {
panel.hidden = panel.id !== tabId;
panel.classList.toggle("active", panel.id === tabId);
});
}
heroTabButtons.forEach((button) => {
button.addEventListener("click", () => {
activateHeroTab(button.dataset.tab);
});
});
const tabIds = new Set(heroTabPanels.map((panel) => panel.id));
const hashTabId = window.location.hash.replace("#", "");
if (tabIds.has(hashTabId)) {
activateHeroTab(hashTabId);
}
document.querySelectorAll('a[href^="#"]').forEach((link) => {
link.addEventListener("click", (event) => {
const targetId = link.getAttribute("href").replace("#", "");
if (!tabIds.has(targetId)) {
return;
}
event.preventDefault();
activateHeroTab(targetId);
document.getElementById("home")?.scrollIntoView({ behavior: "smooth", block: "start" });
history.replaceState(null, "", `#${targetId}`);
});
});