-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
111 lines (97 loc) · 4.94 KB
/
scripts.js
File metadata and controls
111 lines (97 loc) · 4.94 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
document.addEventListener('DOMContentLoaded', function() {
const countdownElement = document.getElementById('countdown-timer');
const heroCtaButton = document.getElementById('hero-cta-button');
const preregistrationSection = document.getElementById('preregistration-area');
const finalRegistrationSection = document.getElementById('final-registration-form');
const launchToggle = document.getElementById('launch-toggle');
// --- IMPORTANT: SET YOUR LAUNCH DATE HERE ---
// Format: YYYY, Month (0-11), Day
const launchDate = new Date(2025, 6, 13); // July 13, 2025
function setPageState(isPostLaunch) {
if (isPostLaunch) {
// --- POST-LAUNCH STATE ---
countdownElement.classList.add('hidden');
preregistrationSection.classList.add('hidden');
finalRegistrationSection.classList.remove('hidden');
heroCtaButton.href = "#final-registration-form";
} else {
// --- PRE-LAUNCH STATE ---
const today = new Date();
today.setHours(0,0,0,0);
const timeDiff = launchDate.getTime() - today.getTime();
const daysLeft = Math.ceil(timeDiff / (1000 * 3600 * 24));
if (daysLeft > 0) {
countdownElement.textContent = `${daysLeft} days to go until launch on ${launchDate.toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric' })}`;
countdownElement.classList.remove('hidden');
} else {
countdownElement.textContent = `Launching today!`;
}
preregistrationSection.classList.remove('hidden');
finalRegistrationSection.classList.add('hidden');
heroCtaButton.href = "#preregistration-area";
}
}
// --- Dev Toggle Logic ---
if (launchToggle) {
launchToggle.addEventListener('change', function() {
setPageState(this.checked);
});
// Set initial state based on toggle (default to pre-launch)
setPageState(launchToggle.checked);
}
/* // --- Automatic Date-Based Logic (Commented out for dev toggle) ---
const today = new Date();
today.setHours(0,0,0,0);
if (today >= launchDate) {
setPageState(true); // Post-launch
} else {
setPageState(false); // Pre-launch
}
*/
// --- FAQ Accordion Logic ---
const faqList = document.querySelector('.faq-list');
if (faqList) {
faqList.addEventListener('click', function(e) {
const question = e.target.closest('.faq-question');
if (question) {
const allItems = faqList.querySelectorAll('.faq-item');
const currentItem = question.parentElement;
allItems.forEach(item => {
if (item !== currentItem && item.classList.contains('active')) {
item.classList.remove('active');
}
});
currentItem.classList.toggle('active');
}
});
}
// --- Smooth Scrolling for Anchor Links ---
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if(targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// --- Expressive Scroll Animations ---
const animatedSections = document.querySelectorAll('.animated-section');
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('is-visible');
observer.unobserve(entry.target);
}
});
}, {
threshold: 0.1
});
animatedSections.forEach(section => {
observer.observe(section);
});
});