-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
71 lines (57 loc) · 2.09 KB
/
script.js
File metadata and controls
71 lines (57 loc) · 2.09 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
// --- INTELLIGENT THEME SWITCHER ---
const themeButton = document.getElementById('theme');
const docElement = document.documentElement;
const applyTheme = (theme) => {
docElement.setAttribute('data-theme', theme);
localStorage.setItem('theme', theme);
};
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const initialTheme = savedTheme || (prefersDark ? 'dark' : 'light');
applyTheme(initialTheme);
themeButton?.addEventListener('click', () => {
const currentTheme = docElement.getAttribute('data-theme');
const newTheme = currentTheme === 'light' ? 'dark' : 'light';
applyTheme(newTheme);
});
// --- DYNAMIC FOOTER ---
const legalElement = document.getElementById('legal');
if (legalElement) {
const currentYear = new Date().getFullYear();
legalElement.textContent = `Released under CC BY 4.0. No cookies. No trackers.`;
}
// --- SHARE BUTTONS LOGIC -
const copyLinkButton = document.getElementById('copy-link-btn');
const copyIcon = document.getElementById('copy-icon');
const checkIcon = document.getElementById('check-icon');
copyLinkButton?.addEventListener('click', () => {
navigator.clipboard.writeText(window.location.href).then(() => {
copyIcon.classList.add('hidden');
checkIcon.classList.remove('hidden');
setTimeout(() => {
copyIcon.classList.remove('hidden');
checkIcon.classList.add('hidden');
}, 2000);
}).catch(err => {
console.error('Failed to copy link: ', err);
});
});
// --- VITA: MINDFUL SCROLL ANIMATION ---
const revealElements = document.querySelectorAll('.reveal');
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1 // Trigger when 10% of the element is visible
};
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
// Optional: stop observing the element once it's visible
// observer.unobserve(entry.target);
}
});
}, observerOptions);
revealElements.forEach(el => {
observer.observe(el);
});