-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
723 lines (627 loc) · 22.9 KB
/
script.js
File metadata and controls
723 lines (627 loc) · 22.9 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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
// DOM Elements
const loginBtn = document.getElementById('loginBtn');
const signupBtn = document.getElementById('signupBtn');
const loginModal = document.getElementById('loginModal');
const signupModal = document.getElementById('signupModal');
const closeLoginModal = document.getElementById('closeLoginModal');
const closeSignupModal = document.getElementById('closeSignupModal');
const startPlanningBtn = document.getElementById('startPlanningBtn');
const continuePathwayBtn = document.getElementById('continuePathwayBtn');
const langBtn = document.querySelector('.lang-btn');
const featureCards = document.querySelectorAll('.feature-card');
const progressCards = document.querySelectorAll('.progress-card');
// Language switching functionality
const languages = {
en: {
tagline: "Forge Your Learning Journey",
startPlanning: "Start Planning",
continuePathway: "Continue Pathway",
login: "Login",
signup: "Sign Up",
welcomeBack: "Welcome Back",
joinWayforge: "Join Wayforge",
learningProgress: "Learning Progress",
timeSpent: "Time Spent",
achievements: "Achievements",
goalsMet: "Goals Met",
resourceHub: "Resource Hub",
resourceHubDesc: "Access curated learning materials and resources",
interactiveQuizzes: "Interactive Quizzes",
interactiveQuizzesDesc: "Test your knowledge with engaging quizzes",
explorationMode: "Exploration Mode",
explorationModeDesc: "Discover new learning opportunities",
resumeBuilder: "Resume Builder",
resumeBuilderDesc: "Create professional resumes with AI assistance",
careerTrends: "Career Trends",
careerTrendsDesc: "Stay updated with industry trends and insights",
guidanceDashboard: "Guidance Dashboard",
guidanceDashboardDesc: "Get personalized career guidance and mentorship",
careerCompass: "Career Compass",
careerCompassDesc: "Navigate your career path with precision",
marketConditions: "Market Conditions",
marketConditionsDesc: "Real-time job market analysis and opportunities",
whatIfSimulator: "What-If Simulator",
whatIfSimulatorDesc: "Simulate different career scenarios and outcomes",
gamifiedExperience: "Gamified Experience",
gamifiedExperienceDesc: "Learn through engaging games and challenges"
},
es: {
tagline: "Forja Tu Camino de Aprendizaje",
startPlanning: "Comenzar Planificación",
continuePathway: "Continuar Ruta",
login: "Iniciar Sesión",
signup: "Registrarse",
welcomeBack: "Bienvenido de Vuelta",
joinWayforge: "Únete a Wayforge",
learningProgress: "Progreso de Aprendizaje",
timeSpent: "Tiempo Invertido",
achievements: "Logros",
goalsMet: "Metas Cumplidas"
},
fr: {
tagline: "Forgez Votre Parcours d'Apprentissage",
startPlanning: "Commencer la Planification",
continuePathway: "Continuer le Parcours",
login: "Se Connecter",
signup: "S'inscrire",
welcomeBack: "Bon Retour",
joinWayforge: "Rejoindre Wayforge",
learningProgress: "Progrès d'Apprentissage",
timeSpent: "Temps Passé",
achievements: "Réalisations",
goalsMet: "Objectifs Atteints"
},
de: {
tagline: "Schmieden Sie Ihren Lernweg",
startPlanning: "Planung Beginnen",
continuePathway: "Pfad Fortsetzen",
login: "Anmelden",
signup: "Registrieren",
welcomeBack: "Willkommen Zurück",
joinWayforge: "Wayforge Beitreten",
learningProgress: "Lernfortschritt",
timeSpent: "Verbrachte Zeit",
achievements: "Errungenschaften",
goalsMet: "Erreichte Ziele"
}
};
let currentLanguage = 'en';
// Premium Interactive Effects
class PremiumEffects {
constructor() {
this.cursor = null;
this.cursorFollower = null;
this.init();
}
init() {
this.createCustomCursor();
this.initScrollReveal();
this.initMagneticEffect();
}
createCustomCursor() {
// Create colorful cursor trail effects
this.trailElements = [];
this.maxTrailLength = 8;
// Track mouse movement for trail effect
document.addEventListener('mousemove', (e) => {
this.createTrailElement(e.clientX, e.clientY);
});
// Clean up old trail elements
setInterval(() => {
this.cleanupTrail();
}, 100);
}
createTrailElement(x, y) {
const trail = document.createElement('div');
trail.className = 'cursor-trail';
trail.style.left = x + 'px';
trail.style.top = y + 'px';
document.body.appendChild(trail);
this.trailElements.push({
element: trail,
timestamp: Date.now()
});
// Animate trail element
setTimeout(() => {
trail.style.opacity = '0';
trail.style.transform = 'scale(0.5)';
}, 50);
// Remove after animation
setTimeout(() => {
if (trail.parentNode) {
trail.parentNode.removeChild(trail);
}
}, 300);
}
cleanupTrail() {
const now = Date.now();
this.trailElements = this.trailElements.filter(item => {
if (now - item.timestamp > 300) {
if (item.element.parentNode) {
item.element.parentNode.removeChild(item.element);
}
return false;
}
return true;
});
// Limit trail length
if (this.trailElements.length > this.maxTrailLength) {
const excess = this.trailElements.splice(0, this.trailElements.length - this.maxTrailLength);
excess.forEach(item => {
if (item.element.parentNode) {
item.element.parentNode.removeChild(item.element);
}
});
}
}
initScrollReveal() {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('revealed');
}
});
}, { threshold: 0.1 });
document.querySelectorAll('.feature-card, .progress-card').forEach(el => {
el.classList.add('scroll-reveal');
observer.observe(el);
});
}
initMagneticEffect() {
document.querySelectorAll('.btn, .feature-card, .logo-3d').forEach(element => {
element.addEventListener('mouseenter', () => {
element.style.transition = 'transform 0.3s ease';
});
element.addEventListener('mousemove', (e) => {
const rect = element.getBoundingClientRect();
const centerX = rect.left + rect.width / 2;
const centerY = rect.top + rect.height / 2;
const deltaX = (e.clientX - centerX) * 0.1;
const deltaY = (e.clientY - centerY) * 0.1;
element.style.transform = `translate(${deltaX}px, ${deltaY}px)`;
});
element.addEventListener('mouseleave', () => {
element.style.transform = '';
});
});
}
}
// Initialize the application
document.addEventListener('DOMContentLoaded', function() {
initializeAnimations();
initializeProgressBars();
initializeEventListeners();
initializeIntersectionObserver();
// Initialize premium effects
new PremiumEffects();
// Add staggered entrance animations
setTimeout(() => {
document.querySelectorAll('.feature-card').forEach((card, index) => {
setTimeout(() => {
card.classList.add('bounce-in');
}, index * 150);
});
}, 500);
});
// Initialize animations
function initializeAnimations() {
// Add fade-in animation to elements
const animatedElements = document.querySelectorAll('.progress-card, .feature-card, .main-btn');
animatedElements.forEach((element, index) => {
element.style.opacity = '0';
element.style.transform = 'translateY(30px)';
setTimeout(() => {
element.style.transition = 'all 0.6s ease';
element.style.opacity = '1';
element.style.transform = 'translateY(0)';
}, index * 100);
});
}
// Initialize progress bars
function initializeProgressBars() {
const progressFills = document.querySelectorAll('.progress-fill');
progressFills.forEach(fill => {
const progress = fill.getAttribute('data-progress');
setTimeout(() => {
fill.style.width = progress + '%';
}, 500);
});
}
// Initialize event listeners
function initializeEventListeners() {
// Modal functionality
loginBtn.addEventListener('click', () => openModal(loginModal));
signupBtn.addEventListener('click', () => openModal(signupModal));
closeLoginModal.addEventListener('click', () => closeModal(loginModal));
closeSignupModal.addEventListener('click', () => closeModal(signupModal));
// Close modals when clicking outside
[loginModal, signupModal].forEach(modal => {
modal.addEventListener('click', (e) => {
if (e.target === modal) {
closeModal(modal);
}
});
});
// Main action buttons
startPlanningBtn.addEventListener('click', handleStartPlanning);
continuePathwayBtn.addEventListener('click', handleContinuePathway);
// Language switching
const langDropdownButtons = document.querySelectorAll('.lang-dropdown button');
langDropdownButtons.forEach(btn => {
btn.addEventListener('click', (e) => {
const lang = e.target.getAttribute('data-lang');
switchLanguage(lang);
});
});
// Feature cards
featureCards.forEach(card => {
card.addEventListener('click', handleFeatureClick);
card.addEventListener('mouseenter', handleFeatureHover);
card.addEventListener('mouseleave', handleFeatureLeave);
});
// Form submissions
const authForms = document.querySelectorAll('.auth-form');
authForms.forEach(form => {
form.addEventListener('submit', handleFormSubmit);
});
// Keyboard navigation
document.addEventListener('keydown', handleKeyDown);
}
// Initialize Intersection Observer for scroll animations
function initializeIntersectionObserver() {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in');
}
});
}, {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
});
const observeElements = document.querySelectorAll('.progress-card, .feature-card');
observeElements.forEach(el => observer.observe(el));
}
// Modal functions
function openModal(modal) {
modal.classList.add('active');
document.body.style.overflow = 'hidden';
// Add entrance animation
const modalContent = modal.querySelector('.modal-content');
modalContent.style.transform = 'scale(0.9)';
setTimeout(() => {
modalContent.style.transform = 'scale(1)';
}, 10);
}
function closeModal(modal) {
const modalContent = modal.querySelector('.modal-content');
modalContent.style.transform = 'scale(0.9)';
setTimeout(() => {
modal.classList.remove('active');
document.body.style.overflow = 'auto';
}, 200);
}
// Language switching
function switchLanguage(lang) {
if (!languages[lang]) return;
currentLanguage = lang;
const langData = languages[lang];
// Update language button
langBtn.querySelector('span').textContent = lang.toUpperCase();
// Update text content
updateTextContent(langData);
// Add transition effect
document.body.style.transition = 'opacity 0.3s ease';
document.body.style.opacity = '0.8';
setTimeout(() => {
document.body.style.opacity = '1';
}, 300);
}
function updateTextContent(langData) {
// Update tagline
const tagline = document.querySelector('.brand-tagline');
if (tagline && langData.tagline) {
tagline.textContent = langData.tagline;
}
// Update buttons
const startBtn = document.querySelector('#startPlanningBtn span');
const continueBtn = document.querySelector('#continuePathwayBtn span');
const loginBtnText = document.querySelector('#loginBtn span');
const signupBtnText = document.querySelector('#signupBtn span');
if (startBtn && langData.startPlanning) startBtn.textContent = langData.startPlanning;
if (continueBtn && langData.continuePathway) continueBtn.textContent = langData.continuePathway;
if (loginBtnText && langData.login) loginBtnText.textContent = langData.login;
if (signupBtnText && langData.signup) signupBtnText.textContent = langData.signup;
// Update modal titles
const loginModalTitle = document.querySelector('#loginModal .modal-header h2');
const signupModalTitle = document.querySelector('#signupModal .modal-header h2');
if (loginModalTitle && langData.welcomeBack) loginModalTitle.textContent = langData.welcomeBack;
if (signupModalTitle && langData.joinWayforge) signupModalTitle.textContent = langData.joinWayforge;
}
// Main action handlers
function handleStartPlanning() {
// Add click animation
startPlanningBtn.style.transform = 'scale(0.95)';
setTimeout(() => {
startPlanningBtn.style.transform = 'scale(1)';
}, 150);
// Show loading state
showLoadingState(startPlanningBtn);
// Clear any existing progress and start fresh from step 1
localStorage.removeItem('wayforge_questionnaire_step');
localStorage.removeItem('wayforge_questionnaire_data');
localStorage.removeItem('wayforge_generated_paths');
// Navigate to questionnaire starting from step 1
setTimeout(() => {
window.location.href = 'questionnaire.html?step=1&fresh=true';
}, 1000);
}
function handleContinuePathway() {
// Add click animation
continuePathwayBtn.style.transform = 'scale(0.95)';
setTimeout(() => {
continuePathwayBtn.style.transform = 'scale(1)';
}, 150);
// Show loading state
showLoadingState(continuePathwayBtn);
// Check if user has saved progress
const savedStep = localStorage.getItem('wayforge_questionnaire_step');
const savedData = localStorage.getItem('wayforge_questionnaire_data');
const generatedPaths = localStorage.getItem('wayforge_generated_paths');
setTimeout(() => {
if (generatedPaths) {
// User has completed questionnaire, go to learning paths
window.location.href = 'learning-paths.html';
} else if (savedStep && savedData) {
// User has progress, resume from saved step
window.location.href = `questionnaire.html?step=${savedStep}&continue=true`;
} else {
// No progress found, start from beginning
window.location.href = 'questionnaire.html?step=1&fresh=true';
}
}, 1000);
}
// Feature card handlers
function handleFeatureClick(e) {
const card = e.currentTarget;
const feature = card.getAttribute('data-feature');
// Add click animation
card.style.transform = 'scale(0.95)';
setTimeout(() => {
card.style.transform = 'scale(1)';
}, 150);
// Handle feature navigation
navigateToFeature(feature);
}
function handleFeatureHover(e) {
const card = e.currentTarget;
const icon = card.querySelector('.card-icon');
// Add hover sound effect (if audio is enabled)
playHoverSound();
// Add particle effect
createParticleEffect(card);
}
function handleFeatureLeave(e) {
const card = e.currentTarget;
// Remove any temporary effects
}
// Navigation functions
function navigateToFeature(feature) {
const featurePages = {
'resource-hub': 'resource-hub.html',
'interactive-quizzes': 'quizzes.html',
'exploration-mode': 'exploration.html',
'resume-builder': 'resume-builder.html',
'career-trends': 'career-trends.html',
'guidance-dashboard': 'guidance.html',
'career-compass': 'career-compass.html',
'market-conditions': 'market-conditions.html',
'what-if-simulator': 'simulator.html',
'gamified-experience': 'gamification.html',
'skill-assessment': 'skill-assessment.html',
'dashboard': 'dashboard.html'
};
const targetPage = featurePages[feature];
if (targetPage) {
// Show loading animation
showPageTransition();
setTimeout(() => {
window.location.href = targetPage;
}, 1000);
}
}
// Form handling
function handleFormSubmit(e) {
e.preventDefault();
const form = e.target;
const isLogin = form.closest('#loginModal');
// Add loading state to form
const submitBtn = form.querySelector('.btn-primary');
showLoadingState(submitBtn);
// Simulate API call
setTimeout(() => {
hideLoadingState(submitBtn);
if (isLogin) {
alert('Login successful! (Demo)');
closeModal(loginModal);
} else {
alert('Registration successful! (Demo)');
closeModal(signupModal);
}
}, 1500);
}
// Keyboard navigation
function handleKeyDown(e) {
// Close modals with Escape key
if (e.key === 'Escape') {
if (loginModal.classList.contains('active')) {
closeModal(loginModal);
}
if (signupModal.classList.contains('active')) {
closeModal(signupModal);
}
}
// Navigate with arrow keys (for accessibility)
if (e.key === 'Tab') {
// Enhanced tab navigation could be implemented here
}
}
// Utility functions
function showLoadingState(element) {
const originalContent = element.innerHTML;
element.setAttribute('data-original-content', originalContent);
element.innerHTML = '<i class="fas fa-spinner fa-spin"></i>';
element.disabled = true;
element.classList.add('loading');
}
function hideLoadingState(element) {
const originalContent = element.getAttribute('data-original-content');
if (originalContent) {
element.innerHTML = originalContent;
}
element.disabled = false;
element.classList.remove('loading');
element.removeAttribute('data-original-content');
}
function showPageTransition() {
const overlay = document.createElement('div');
overlay.className = 'page-transition-overlay';
overlay.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
transition: opacity 0.3s ease;
`;
overlay.innerHTML = `
<div style="text-align: center; color: white;">
<i class="fas fa-spinner fa-spin" style="font-size: 3rem; margin-bottom: 1rem;"></i>
<p style="font-size: 1.2rem;">Loading...</p>
</div>
`;
document.body.appendChild(overlay);
setTimeout(() => {
overlay.style.opacity = '1';
}, 10);
// Store reference for cleanup
window.pageTransitionOverlay = overlay;
}
function hidePageTransition() {
const overlay = window.pageTransitionOverlay;
if (overlay) {
overlay.style.opacity = '0';
setTimeout(() => {
if (overlay.parentNode) {
overlay.parentNode.removeChild(overlay);
}
}, 300);
}
}
function createParticleEffect(element) {
const rect = element.getBoundingClientRect();
const particles = [];
for (let i = 0; i < 5; i++) {
const particle = document.createElement('div');
particle.style.cssText = `
position: fixed;
width: 4px;
height: 4px;
background: var(--primary-color);
border-radius: 50%;
pointer-events: none;
z-index: 1000;
left: ${rect.left + rect.width / 2}px;
top: ${rect.top + rect.height / 2}px;
opacity: 1;
transition: all 0.6s ease-out;
`;
document.body.appendChild(particle);
particles.push(particle);
// Animate particle
setTimeout(() => {
const angle = (i / 5) * Math.PI * 2;
const distance = 50;
particle.style.transform = `translate(${Math.cos(angle) * distance}px, ${Math.sin(angle) * distance}px)`;
particle.style.opacity = '0';
}, 10);
}
// Cleanup particles
setTimeout(() => {
particles.forEach(particle => {
if (particle.parentNode) {
particle.parentNode.removeChild(particle);
}
});
}, 600);
}
function playHoverSound() {
// Placeholder for hover sound effect
// Could implement Web Audio API sound here
}
// Performance optimization
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
// Smooth scrolling for internal links
function smoothScrollTo(target) {
const element = document.querySelector(target);
if (element) {
element.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
}
// Theme switching (for future implementation)
function toggleTheme() {
document.body.classList.toggle('light-theme');
localStorage.setItem('theme', document.body.classList.contains('light-theme') ? 'light' : 'dark');
}
// Initialize theme from localStorage
function initializeTheme() {
const savedTheme = localStorage.getItem('theme');
if (savedTheme === 'light') {
document.body.classList.add('light-theme');
}
}
// Analytics tracking (placeholder)
function trackEvent(eventName, properties = {}) {
// Placeholder for analytics tracking
console.log('Event tracked:', eventName, properties);
}
// Error handling
window.addEventListener('error', function(e) {
console.error('JavaScript error:', e.error);
// Could implement error reporting here
});
// Service Worker registration (for future PWA implementation)
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
// navigator.serviceWorker.register('/sw.js');
});
}
// Export functions for testing (if needed)
if (typeof module !== 'undefined' && module.exports) {
module.exports = {
switchLanguage,
openModal,
closeModal,
handleStartPlanning,
handleContinuePathway
};
}