-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
60 lines (53 loc) · 1.84 KB
/
scripts.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
document.addEventListener('DOMContentLoaded', () => {
const sections = document.querySelectorAll('section');
let currentSectionIndex = 0;
let isScrolling = false;
const scrollToSection = (index) => {
if (index < 0 || index >= sections.length) return;
isScrolling = true;
sections[index].scrollIntoView({ behavior: 'smooth' });
setTimeout(() => {
isScrolling = false;
currentSectionIndex = index;
}, 1000); // Adjust timeout to match the smooth scroll duration
};
window.addEventListener('wheel', (event) => {
if (isScrolling) return;
if (event.deltaY > 0) {
// Scrolling down
scrollToSection(currentSectionIndex + 1);
} else {
// Scrolling up
scrollToSection(currentSectionIndex - 1);
}
});
const links = document.querySelectorAll('nav a');
links.forEach((link, index) => {
link.addEventListener('click', (event) => {
event.preventDefault();
scrollToSection(index);
});
});
});
function copyToClipboard() {
const text = document.getElementById('copy-text').textContent;
navigator.clipboard.writeText(text).then(() => {
alert('Copied to clipboard');
}).catch(err => {
console.error('Failed to copy: ', err);
});
}
function calculateDaysUntil(targetDate) {
const today = new Date();
const timeDiff = targetDate - today;
const daysDiff = Math.ceil(timeDiff / (8.64e7));
return daysDiff;
}
function updateDaysCounter() {
const targetDate = new Date('October 18, 2025');
const daysCounterElement = document.getElementById('days-counter');
const daysUntil = calculateDaysUntil(targetDate);
daysCounterElement.textContent = daysUntil;
}
// Update the counter when the page loads
updateDaysCounter();