-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
436 lines (377 loc) · 15.7 KB
/
script.js
File metadata and controls
436 lines (377 loc) · 15.7 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
// Mobile Navigation
const hamburger = document.querySelector('.hamburger');
const navMenu = document.querySelector('.nav-menu');
if (hamburger && navMenu) {
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
navMenu.classList.toggle('active');
});
document.querySelectorAll('.nav-menu a').forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
navMenu.classList.remove('active');
});
});
}
// Theme Toggle
function toggleTheme() {
const body = document.body;
const themeIcon = document.getElementById('themeIcon');
if (body.classList.contains('light-mode')) {
body.classList.remove('light-mode');
if (themeIcon) themeIcon.className = 'fas fa-moon';
localStorage.setItem('theme', 'dark');
} else {
body.classList.add('light-mode');
if (themeIcon) themeIcon.className = 'fas fa-sun';
localStorage.setItem('theme', 'light');
}
}
// Language Switcher
function changeLanguage() {
const langSelect = document.getElementById('languageSelect');
if (!langSelect) return;
const lang = langSelect.value;
localStorage.setItem('language', lang);
document.querySelectorAll(`[data-${lang}]`).forEach(element => {
const translation = element.getAttribute(`data-${lang}`);
if (translation) {
element.textContent = translation;
}
});
document.querySelectorAll(`[data-placeholder-${lang}]`).forEach(element => {
const placeholder = element.getAttribute(`data-placeholder-${lang}`);
if (placeholder) {
element.placeholder = placeholder;
}
});
}
// Load saved preferences
function loadTheme() {
const savedTheme = localStorage.getItem('theme');
const themeIcon = document.getElementById('themeIcon');
if (savedTheme === 'light') {
document.body.classList.add('light-mode');
if (themeIcon) themeIcon.className = 'fas fa-sun';
} else {
if (themeIcon) themeIcon.className = 'fas fa-moon';
}
}
function loadLanguage() {
const savedLang = localStorage.getItem('language') || 'en';
const langSelect = document.getElementById('languageSelect');
if (langSelect) {
langSelect.value = savedLang;
changeLanguage();
}
}
// Modal functionality
function showModal(modalId) {
document.getElementById(modalId).style.display = 'block';
}
function hideModal(modalId) {
document.getElementById(modalId).style.display = 'none';
}
function showSubscribeModal() {
showModal('subscribeModal');
}
function showAmbassadorModal() {
showModal('ambassadorModal');
}
function showScoutModal() {
showModal('scoutModal');
}
function showPartnerModal() {
showModal('partnerModal');
}
function showSponsorModal() {
showModal('sponsorModal');
}
// Close modals
document.querySelectorAll('.close').forEach(closeBtn => {
closeBtn.addEventListener('click', (e) => {
e.target.closest('.modal').style.display = 'none';
});
});
window.addEventListener('click', (e) => {
if (e.target.classList.contains('modal')) {
e.target.style.display = 'none';
}
});
// Smooth scrolling
function scrollToSection(sectionId) {
document.getElementById(sectionId).scrollIntoView({
behavior: 'smooth'
});
}
// Toggle functions
function toggleMentors() {
const hiddenMentors = document.querySelectorAll('.mentor-card.hidden-mentor');
const button = document.getElementById('showMoreMentors');
const currentLang = localStorage.getItem('language') || 'en';
const translations = {
en: { more: 'See More Mentors', less: 'Show Less' },
fr: { more: 'Voir Plus de Mentors', less: 'Voir Moins' },
de: { more: 'Mehr Mentoren Sehen', less: 'Weniger Zeigen' },
zh: { more: '查看更多导师', less: '显示更少' },
es: { more: 'Ver Más Mentores', less: 'Mostrar Menos' }
};
if (button.textContent.includes('See More') || button.textContent.includes('Voir Plus') || button.textContent.includes('Mehr') || button.textContent.includes('查看') || button.textContent.includes('Ver Más')) {
hiddenMentors.forEach(mentor => {
mentor.style.display = 'block';
});
button.textContent = translations[currentLang].less;
} else {
hiddenMentors.forEach(mentor => {
mentor.style.display = 'none';
});
button.textContent = translations[currentLang].more;
}
}
function toggleTeam() {
const hiddenTeam = document.querySelectorAll('.team-member.hidden-team');
const button = document.getElementById('showMoreTeam');
const currentLang = localStorage.getItem('language') || 'en';
const translations = {
en: { more: 'See More Team', less: 'Show Less' },
fr: { more: 'Voir Plus d\'Équipe', less: 'Voir Moins' },
de: { more: 'Mehr Team Sehen', less: 'Weniger Zeigen' },
zh: { more: '查看更多团队', less: '显示更少' },
es: { more: 'Ver Más Equipo', less: 'Mostrar Menos' }
};
if (button.textContent.includes('See More') || button.textContent.includes('Voir Plus') || button.textContent.includes('Mehr') || button.textContent.includes('查看') || button.textContent.includes('Ver Más')) {
hiddenTeam.forEach(member => {
member.style.display = 'block';
});
button.textContent = translations[currentLang].less;
} else {
hiddenTeam.forEach(member => {
member.style.display = 'none';
});
button.textContent = translations[currentLang].more;
}
}
function toggleStory() {
const fullStory = document.getElementById('fullStory');
const button = document.querySelector('.read-more-btn');
const currentLang = localStorage.getItem('language') || 'en';
const translations = {
en: { more: 'Read More', less: 'Read Less' },
fr: { more: 'Lire Plus', less: 'Lire Moins' },
de: { more: 'Mehr Lesen', less: 'Weniger Lesen' },
zh: { more: '阅读更多', less: '阅读更少' },
es: { more: 'Leer Más', less: 'Leer Menos' }
};
if (fullStory.style.display === 'none') {
fullStory.style.display = 'block';
button.textContent = translations[currentLang].less;
} else {
fullStory.style.display = 'none';
button.textContent = translations[currentLang].more;
}
}
// Blog Subscribe Form
function setupBlogSubscription() {
const blogForm = document.getElementById('blogSubscribeForm');
if (blogForm) {
blogForm.addEventListener('submit', (e) => {
e.preventDefault();
const email = e.target.querySelector('input[type="email"]').value;
if (typeof emailjs !== 'undefined' && typeof EMAILJS_CONFIG !== 'undefined') {
console.log('Sending email with config:', EMAILJS_CONFIG);
const templateParams = {
to_email: email,
subscriber_email: email,
subscription_type: 'Blog Updates',
from_name: 'LaunchPad Community'
};
if (typeof grecaptcha !== 'undefined') {
grecaptcha.execute().then(token => {
templateParams['g-recaptcha-response'] = token;
emailjs.send(EMAILJS_CONFIG.SERVICE_ID, EMAILJS_CONFIG.TEMPLATES.BLOG, templateParams).then(() => {
alert('Welcome to LaunchPad Community! Check your email for confirmation.');
e.target.reset();
}).catch((error) => {
console.error('EmailJS Error Details:', error);
alert('Error: ' + (error.text || error.message || 'Please check EmailJS configuration'));
});
});
} else {
emailjs.send(EMAILJS_CONFIG.SERVICE_ID, EMAILJS_CONFIG.TEMPLATES.BLOG, templateParams).then(() => {
alert('Welcome to LaunchPad Community! Check your email for confirmation.');
e.target.reset();
}).catch((error) => {
console.error('EmailJS Error Details:', error);
alert('Error: ' + (error.text || error.message || 'Please check EmailJS configuration'));
});
}
} else {
alert('EmailJS not configured. Check emailjs-config.js file.');
}
});
}
}
// Fire Sparks Rain Animation
function createSparkRain() {
const flamePositions = [20, 30, 40, 50, 60, 70, 80];
for (let i = 0; i < 5; i++) {
setTimeout(() => {
const spark = document.createElement('div');
const isBlue = Math.random() < 0.3;
spark.className = `fire-spark ${isBlue ? 'blue' : 'orange'}`;
const flamePos = flamePositions[Math.floor(Math.random() * flamePositions.length)];
spark.style.position = 'fixed';
spark.style.left = `calc(${flamePos}% - 10px)`;
spark.style.bottom = '80px';
spark.style.setProperty('--drift', (Math.random() - 0.5) * 100 + 'px');
spark.style.animationDuration = (Math.random() * 2 + 5) + 's';
spark.style.zIndex = '1';
document.body.appendChild(spark);
setTimeout(() => {
if (spark.parentNode) spark.remove();
}, 8000);
}, i * 100);
}
}
// Scroll Animation Observer
function initScrollAnimations() {
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
});
}, observerOptions);
// Add animation classes to elements
document.querySelectorAll('.team-member').forEach((el, i) => {
el.classList.add(i % 2 === 0 ? 'fade-in-left' : 'fade-in-right');
observer.observe(el);
});
document.querySelectorAll('.mentor-card').forEach((el, i) => {
el.classList.add(i % 3 === 0 ? 'fade-in-left' : i % 3 === 1 ? 'fade-in-up' : 'fade-in-right');
observer.observe(el);
});
document.querySelectorAll('.apply-option, .objective, .story, .purpose-item').forEach((el, i) => {
el.classList.add(i % 2 === 0 ? 'fade-in-left' : 'fade-in-right');
observer.observe(el);
});
document.querySelectorAll('.section-title').forEach(el => {
el.classList.add('fade-in-up');
observer.observe(el);
});
}
// Initialize animations on page load
document.addEventListener('DOMContentLoaded', function() {
loadTheme();
loadLanguage();
setupBlogSubscription();
initScrollAnimations();
// Start fire spark rain immediately and continuously
createSparkRain();
setInterval(createSparkRain, 800);
// Existing form handlers...
const subscribeForm = document.getElementById('subscribeForm');
if (subscribeForm) {
subscribeForm.addEventListener('submit', (e) => {
e.preventDefault();
alert('Thank you for subscribing! You will receive updates about opportunities and events.');
hideModal('subscribeModal');
e.target.reset();
});
}
const ambassadorForm = document.getElementById('ambassadorForm');
if (ambassadorForm) {
ambassadorForm.addEventListener('submit', (e) => {
e.preventDefault();
alert('Thank you for your ambassador application! We will review it and get back to you within 48 hours.');
hideModal('ambassadorModal');
e.target.reset();
});
}
const scoutForm = document.getElementById('scoutForm');
if (scoutForm) {
scoutForm.addEventListener('submit', (e) => {
e.preventDefault();
alert('Thank you for your scout application! We will review it and contact you soon.');
hideModal('scoutModal');
e.target.reset();
});
}
const partnerForm = document.getElementById('partnerForm');
if (partnerForm) {
partnerForm.addEventListener('submit', (e) => {
e.preventDefault();
alert('Thank you for your partnership inquiry! Our team will contact you within 24 hours.');
hideModal('partnerModal');
e.target.reset();
});
}
const sponsorForm = document.getElementById('sponsorForm');
if (sponsorForm) {
sponsorForm.addEventListener('submit', (e) => {
e.preventDefault();
if (typeof emailjs !== 'undefined' && typeof EMAILJS_CONFIG !== 'undefined') {
const formData = new FormData(e.target);
const templateParams = {
to_email: 'LaunchPadCommunity00@gmail.com',
org_name: formData.get('org_name') || e.target.querySelector('input[placeholder*="Organization"]').value,
contact_person: e.target.querySelector('input[placeholder*="Contact"]').value,
from_email: e.target.querySelector('input[type="email"]').value,
phone: e.target.querySelector('input[type="tel"]').value,
sponsorship_type: e.target.querySelector('select').value,
message: e.target.querySelector('textarea').value
};
emailjs.send(EMAILJS_CONFIG.SERVICE_ID, EMAILJS_CONFIG.TEMPLATES.SPONSORSHIP, templateParams)
.then(() => {
alert('Thank you for your sponsorship inquiry! We appreciate your interest in supporting our mission.');
hideModal('sponsorModal');
e.target.reset();
})
.catch((error) => {
console.error('EmailJS Error:', error);
alert('Failed to send sponsorship inquiry. Please try again or contact us directly.');
});
} else {
alert('Thank you for your sponsorship inquiry! We appreciate your interest in supporting our mission.');
hideModal('sponsorModal');
e.target.reset();
}
});
}
const feedbackForm = document.getElementById('feedbackForm');
if (feedbackForm) {
feedbackForm.addEventListener('submit', (e) => {
e.preventDefault();
alert('Thank you for your feedback! We value your input and will use it to improve our community.');
hideModal('feedbackModal');
e.target.reset();
});
}
const reportForm = document.getElementById('reportForm');
if (reportForm) {
reportForm.addEventListener('submit', (e) => {
e.preventDefault();
alert('Thank you for reporting this issue. Our team will investigate and take appropriate action.');
hideModal('reportModal');
e.target.reset();
});
}
});
// Make functions globally accessible
window.toggleTheme = toggleTheme;
window.changeLanguage = changeLanguage;
window.showModal = showModal;
window.hideModal = hideModal;
window.showSubscribeModal = showSubscribeModal;
window.showAmbassadorModal = showAmbassadorModal;
window.showScoutModal = showScoutModal;
window.showPartnerModal = showPartnerModal;
window.showSponsorModal = showSponsorModal;
window.scrollToSection = scrollToSection;
window.toggleMentors = toggleMentors;
window.toggleTeam = toggleTeam;
window.toggleStory = toggleStory;