-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
214 lines (189 loc) · 7.62 KB
/
index.js
File metadata and controls
214 lines (189 loc) · 7.62 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
AOS.init({ once: true, duration: 700, easing: 'ease-out-cubic' });
/* PARALLAX */
(function () {
const layers = document.querySelectorAll('.parallax-layer');
function onScroll() {
const scroll = window.scrollY;
layers.forEach(l => {
const speed = parseFloat(l.dataset.speed) || (l.classList.contains('bg') ? 0.22 : 0.06);
l.style.transform = `translate3d(0, ${scroll * speed}px, 0)`;
});
}
window.addEventListener('scroll', onScroll);
onScroll();
})();
/* MARQUEE clone: repeat track to ensure continuous movement */
// Built via CSS animation with duplicated text.
/* COUNTERS - animate when visible */
(function () {
const counters = document.querySelectorAll('.num');
const obs = new IntersectionObserver(entries => {
entries.forEach(e => {
if (e.isIntersecting) {
const el = e.target;
const target = +el.dataset.target;
let start = 0;
const step = Math.max(1, Math.floor(target / 80));
const iv = setInterval(() => {
start += step;
if (start >= target) { el.textContent = target; clearInterval(iv); }
else el.textContent = start;
}, 18);
obs.unobserve(el);
}
});
}, { threshold: 0.6 });
counters.forEach(c => obs.observe(c));
})();
/* Tabs for 2-day schedule + render timetable rows */
(function () {
const dayTabs = document.querySelectorAll('.tabs .tab');
const timetableGrid = document.getElementById('timetableGrid');
const schedule = {
1: [
['09:00', 'Gates open & check-in'],
['11:00', 'Opening ceremony & welcome talk'],
['13:00', 'Lunch (local cuisine)'],
['15:00', 'Guided cultural walk & market'],
['17:30', 'Workshop: traditional crafts'],
['19:30', 'Sunset performance — dusk stage'],
['21:30', 'Night DJ set']
],
2: [
['07:00', 'Morning yoga & sunrise session'],
['09:00', 'Breakfast & local market'],
['11:00', 'Photography walk to ridgeline'],
['13:00', 'Picnic lunch'],
['16:00', 'Artist Q&A & masterclass'],
['18:30', 'Main stage headline'],
['21:00', 'Farewell bonfire & final set']
]
};
function render(day) {
timetableGrid.innerHTML = '';
const rows = schedule[day];
rows.forEach(r => {
const row = document.createElement('div'); row.className = 'tt-row';
const t = document.createElement('div'); t.className = 'tt-time'; t.textContent = r[0];
const a = document.createElement('div'); a.className = 'tt-activity'; a.textContent = r[1];
row.appendChild(t); row.appendChild(a); timetableGrid.appendChild(row);
});
}
dayTabs.forEach(tab => {
tab.addEventListener('click', () => {
dayTabs.forEach(t => t.classList.remove('active'));
tab.classList.add('active');
const day = tab.dataset.day;
render(day);
});
});
// init day 1 default
render(1);
})();
/* Flip card keyboard accessibility: toggle on Enter */
document.querySelectorAll('.flip-card').forEach(fc => {
fc.tabIndex = 0;
fc.addEventListener('keydown', e => {
if (e.key === 'Enter') fc.querySelector('.flip-inner').classList.toggle('flipped');
});
});
/* FAQ accordion */
document.querySelectorAll('.faq-item').forEach(item => {
item.addEventListener('click', () => item.classList.toggle('open'));
item.addEventListener('keydown', e => { if (e.key === 'Enter') item.classList.toggle('open'); });
});
/* Lightbox for images */
document.querySelectorAll('img').forEach(img => {
img.addEventListener('click', (e) => {
// avoid activating for small UI icons (we only have content images here)
if (img.closest('header') || img.closest('nav')) return;
const src = img.getAttribute('src');
if (!src) return;
const overlay = document.createElement('div');
overlay.style.position = 'fixed'; overlay.style.inset = 0; overlay.style.background = 'rgba(0,0,0,.9)'; overlay.style.display = 'flex';
overlay.style.alignItems = 'center'; overlay.style.justifyContent = 'center'; overlay.style.zIndex = 9999;
const im = document.createElement('img'); im.src = src; im.style.maxWidth = '92%'; im.style.maxHeight = '92%';
im.style.borderRadius = '8px'; overlay.appendChild(im);
overlay.addEventListener('click', () => overlay.remove());
document.body.appendChild(overlay);
});
});
/* Registration handler (demo) */
function handleRegistration() {
const form = document.getElementById('regForm');
const data = new FormData(form);
const name = data.get('name') || 'Guest';
const ticket = data.get('ticket') || 'Classic';
const qty = data.get('qty') || '1';
alert(`Thank you ${name}!\n\nRegistered: ${ticket} (${qty})\nWe will contact you with payment details.`);
form.reset();
// scroll to contact to simulate next step
document.querySelector('#contact').scrollIntoView({ behavior: 'smooth' });
}
/* smooth scroll for nav anchors */
document.querySelectorAll('a[href^="#"]').forEach(a => {
a.addEventListener('click', e => {
const href = a.getAttribute('href');
if (href.length > 1) {
e.preventDefault();
document.querySelector(href).scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
});
document.addEventListener("DOMContentLoaded", () => {
const track = document.getElementById("carouselTrack");
const cards = track.children;
const cloneCount = Math.min(cards.length, 3); // how many to duplicate for smooth loop
for (let i = 0; i < cloneCount; i++) {
const clone = cards[i].cloneNode(true);
track.appendChild(clone);
}
});
const hamburger = document.getElementById('hamburger');
const mobileNav = document.getElementById('mobileNav');
// Get the desktop navigation element
const desktopNav = document.getElementById('desktopNav');
// Function to check screen width and toggle desktop nav visibility
const checkScreenWidth = () => {
if (window.innerWidth <= 768) { // Assuming 768px is your mobile breakpoint
desktopNav.style.display = 'none';
} else {
desktopNav.style.display = 'flex';
}
};
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
mobileNav.classList.toggle('active');
});
// Optional: close menu on link click
document.querySelectorAll('.mobile-nav a').forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
mobileNav.classList.remove('active');
});
});
// Initial check on page load
checkScreenWidth();
// Listen for window resize events
window.addEventListener('resize', checkScreenWidth);
// video section
document.querySelectorAll(".video-box").forEach(box => {
box.addEventListener("click", () => {
const videoUrl = box.getAttribute("data-video");
box.innerHTML = `<iframe src="${videoUrl}"
frameborder="0"
allow="autoplay; encrypted-media"
allowfullscreen></iframe>`;
});
});
// dynamic footer
document.getElementById("year").textContent = new Date().getFullYear();
function copyNumber(e, number) {
// On desktop, override "tel:" so it copies instead
if (!/Mobi|Android|iPhone/i.test(navigator.userAgent)) {
e.preventDefault();
navigator.clipboard.writeText(number).then(() => {
alert("Number copied: " + number);
});
}
}