-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
629 lines (580 loc) · 29.5 KB
/
index.html
File metadata and controls
629 lines (580 loc) · 29.5 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Learning Hub - Master JavaScript from Basics to Advanced</title>
<meta name="description"
content="Comprehensive JavaScript learning platform with interactive examples, algorithms, and exercises for developers of all levels.">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
'edu-blue': '#3B82F6',
'edu-green': '#10B981',
'edu-purple': '#8B5CF6',
'edu-yellow': '#F59E0B',
'edu-bg': '#F9FAFB',
'edu-text': '#374151'
}
}
}
}
</script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css">
<style>
.gradient-bg {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.code-preview {
background: #1a1a1a;
border-radius: 8px;
padding: 1rem;
overflow-x: auto;
}
.feature-card {
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.feature-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body class="bg-edu-bg text-edu-text">
<!-- Navigation -->
<nav class="bg-white shadow-lg fixed w-full z-50">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<div class="flex-shrink-0 flex items-center">
<span class="text-2xl font-bold text-edu-blue">JS</span>
<span class="text-2xl font-bold text-edu-purple ml-1">Learning Hub</span>
</div>
</div>
<div class="hidden md:flex items-center space-x-8">
<a href="#home" class="text-gray-700 hover:text-edu-blue transition-colors">Home</a>
<a href="lessons.html" class="text-gray-700 hover:text-edu-blue transition-colors">Lessons</a>
<a href="playground.html" class="text-gray-700 hover:text-edu-blue transition-colors">Playground</a>
<a href="algorithms.html" class="text-gray-700 hover:text-edu-blue transition-colors">Algorithms</a>
<a href="exercises.html" class="text-gray-700 hover:text-edu-blue transition-colors">Exercises</a>
<button onclick="scrollToLessons()"
class="bg-edu-blue text-white px-4 py-2 rounded-lg hover:bg-blue-600 transition-colors">
Get Started
</button>
</div>
<!-- Mobile menu button -->
<div class="md:hidden flex items-center">
<button class="text-gray-700 hover:text-edu-blue">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M4 6h16M4 12h16M4 18h16"></path>
</svg>
</button>
</div>
</div>
</div>
</nav>
<!-- Hero Section -->
<section id="home" class="gradient-bg pt-20 pb-16">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="text-center text-white">
<h1 class="text-5xl md:text-6xl font-bold mb-6">
Master JavaScript
<span class="block text-edu-yellow">From Basics to Advanced</span>
</h1>
<p class="text-xl md:text-2xl mb-8 max-w-3xl mx-auto opacity-90">
Interactive learning platform with hands-on examples, algorithms, and real-world projects
designed for developers at every level.
</p>
<div class="flex flex-col sm:flex-row gap-4 justify-center">
<button onclick="window.location.href='lessons.html'"
class="bg-edu-green text-white px-8 py-4 rounded-lg text-lg font-semibold hover:bg-green-600 transition-colors">
Start Learning Free
</button>
<button onclick="window.location.href='playground.html'"
class="border-2 border-white text-white px-8 py-4 rounded-lg text-lg font-semibold hover:bg-white hover:text-gray-800 transition-colors">
Try Playground
</button>
</div>
</div>
</div>
</section>
<!-- Features Section -->
<section class="py-20 bg-white">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="text-center mb-16">
<h2 class="text-4xl font-bold text-gray-900 mb-4">Why Choose JS Learning Hub?</h2>
<p class="text-xl text-gray-600 max-w-3xl mx-auto">
Our comprehensive approach combines theory, practice, and real-world applications
to ensure you master JavaScript effectively.
</p>
</div>
<div class="grid md:grid-cols-3 gap-8">
<!-- Feature 1 -->
<div class="feature-card bg-white p-8 rounded-xl shadow-lg border border-gray-100">
<div class="w-16 h-16 bg-edu-blue rounded-lg flex items-center justify-center mb-6">
<svg class="w-8 h-8 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"></path>
</svg>
</div>
<h3 class="text-2xl font-bold mb-4 text-gray-900">Interactive Code Examples</h3>
<p class="text-gray-600 mb-4">
Learn by doing with live code examples that you can modify and run instantly.
See results in real-time as you experiment with different approaches.
</p>
<a href="playground.html" class="text-edu-blue font-semibold hover:text-blue-600 transition-colors">
Try Examples →
</a>
</div>
<!-- Feature 2 -->
<div class="feature-card bg-white p-8 rounded-xl shadow-lg border border-gray-100">
<div class="w-16 h-16 bg-edu-green rounded-lg flex items-center justify-center mb-6">
<svg class="w-8 h-8 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z">
</path>
</svg>
</div>
<h3 class="text-2xl font-bold mb-4 text-gray-900">Algorithm Implementations</h3>
<p class="text-gray-600 mb-4">
Master computer science fundamentals with comprehensive algorithm implementations,
complete with complexity analysis and visual explanations.
</p>
<a href="lessons.html" class="text-edu-green font-semibold hover:text-green-600 transition-colors">
Explore Algorithms →
</a>
</div>
<!-- Feature 3 -->
<div class="feature-card bg-white p-8 rounded-xl shadow-lg border border-gray-100">
<div class="w-16 h-16 bg-edu-purple rounded-lg flex items-center justify-center mb-6">
<svg class="w-8 h-8 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.746 0 3.332.477 4.5 1.253v13C19.832 18.477 18.246 18 16.5 18c-1.746 0-3.332.477-4.5 1.253">
</path>
</svg>
</div>
<h3 class="text-2xl font-bold mb-4 text-gray-900">Progressive Learning Path</h3>
<p class="text-gray-600 mb-4">
Follow a carefully structured curriculum that builds from basic concepts to
advanced topics, ensuring solid understanding at each step.
</p>
<a href="lessons.html"
class="text-edu-purple font-semibold hover:text-purple-600 transition-colors">
View Curriculum →
</a>
</div>
</div>
</div>
</section>
<!-- Lessons Preview Section -->
<section id="lessons" class="py-20 bg-edu-bg">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="text-center mb-16">
<h2 class="text-4xl font-bold text-gray-900 mb-4">JavaScript Learning Modules</h2>
<p class="text-xl text-gray-600">
Comprehensive lessons covering every aspect of JavaScript development
</p>
</div>
<div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6" id="lesson-cards">
<!-- Lesson cards will be populated by JavaScript -->
</div>
<div class="text-center mt-12">
<button onclick="window.location.href='lessons.html'"
class="bg-edu-blue text-white px-8 py-3 rounded-lg text-lg font-semibold hover:bg-blue-600 transition-colors">
View All 15+ Lessons
</button>
</div>
</div>
</section>
<!-- Interactive Demo Section -->
<section class="py-20 bg-white">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="text-center mb-16">
<h2 class="text-4xl font-bold text-gray-900 mb-4">Try It Yourself</h2>
<p class="text-xl text-gray-600">
Interactive code playground - modify the code and see results instantly
</p>
</div>
<div class="bg-gray-900 rounded-xl p-6 max-w-4xl mx-auto">
<div class="flex items-center justify-between mb-4">
<div class="flex space-x-2">
<div class="w-3 h-3 bg-red-500 rounded-full"></div>
<div class="w-3 h-3 bg-yellow-500 rounded-full"></div>
<div class="w-3 h-3 bg-green-500 rounded-full"></div>
</div>
<span class="text-gray-400 text-sm">script.js</span>
</div>
<div class="code-preview">
<textarea id="demo-code-editor"
class="w-full bg-transparent text-gray-100 resize-none border-none outline-none font-mono text-sm"
rows="12" spellcheck="false">// JavaScript Function Example
function calculateArea(radius) {
const pi = Math.PI;
const area = pi * radius * radius;
return area.toFixed(2);
}
// Test the function
const circleRadius = 5;
const result = calculateArea(circleRadius);
console.log(`Circle with radius ${circleRadius} has area: ${result}`);
// Try changing the radius value above and run the code!</textarea>
</div>
<div class="mt-4 flex justify-between items-center">
<button id="run-demo-code"
class="bg-edu-green text-white px-4 py-2 rounded-lg hover:bg-green-600 transition-colors">
▶ Run Code
</button>
<button id="copy-demo-code" class="text-gray-400 hover:text-white transition-colors">
📋 Copy Code
</button>
</div>
<div id="demo-output" class="mt-4 p-4 bg-gray-800 rounded text-green-400 text-sm min-h-[60px] hidden">
<!-- Output will appear here -->
</div>
</div>
</div>
</section>
<!-- Statistics Section -->
<section class="py-20 gradient-bg">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="grid md:grid-cols-4 gap-8 text-center text-white">
<div>
<div class="text-4xl font-bold mb-2">15+</div>
<div class="text-xl opacity-90">Interactive Lessons</div>
</div>
<div>
<div class="text-4xl font-bold mb-2">50+</div>
<div class="text-xl opacity-90">Code Examples</div>
</div>
<div>
<div class="text-4xl font-bold mb-2">25+</div>
<div class="text-xl opacity-90">Algorithms</div>
</div>
<div>
<div class="text-4xl font-bold mb-2">100+</div>
<div class="text-xl opacity-90">Practice Exercises</div>
</div>
</div>
</div>
</section>
<!-- Call to Action -->
<section class="py-20 bg-white">
<div class="max-w-4xl mx-auto text-center px-4 sm:px-6 lg:px-8">
<h2 class="text-4xl font-bold text-gray-900 mb-6">
Ready to Master JavaScript?
</h2>
<p class="text-xl text-gray-600 mb-8">
Join thousands of developers who have improved their JavaScript skills with our comprehensive learning
platform.
</p>
<div class="flex flex-col sm:flex-row gap-4 justify-center">
<button onclick="window.location.href='lessons.html'"
class="bg-edu-blue text-white px-8 py-4 rounded-lg text-lg font-semibold hover:bg-blue-600 transition-colors">
Start Learning Today
</button>
<button
onclick="window.open('https://github.com/sharada-marasinha/JavaScript-Learning-Repository', '_blank')"
class="border-2 border-edu-blue text-edu-blue px-8 py-4 rounded-lg text-lg font-semibold hover:bg-edu-blue hover:text-white transition-colors">
Browse Repository
</button>
</div>
</div>
</section>
<!-- Footer -->
<footer class="bg-gray-900 text-white py-12">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="grid md:grid-cols-4 gap-8">
<div>
<div class="flex items-center mb-4">
<span class="text-2xl font-bold text-edu-blue">JS</span>
<span class="text-2xl font-bold text-edu-purple ml-1">Learning Hub</span>
</div>
<p class="text-gray-400">
Comprehensive JavaScript learning platform for developers of all levels.
</p>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Learn</h3>
<ul class="space-y-2 text-gray-400">
<li><a href="lessons.html" class="hover:text-white transition-colors">JavaScript Basics</a></li>
<li><a href="lessons.html" class="hover:text-white transition-colors">Advanced Concepts</a></li>
<li><a href="lessons.html" class="hover:text-white transition-colors">Algorithms</a></li>
<li><a href="playground.html" class="hover:text-white transition-colors">Practice Exercises</a>
</li>
</ul>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Resources</h3>
<ul class="space-y-2 text-gray-400">
<li><a href="#" class="hover:text-white transition-colors">Documentation</a></li>
<li><a href="#" class="hover:text-white transition-colors">Code Examples</a></li>
<li><a href="#" class="hover:text-white transition-colors">Cheat Sheets</a></li>
<li><a href="#" class="hover:text-white transition-colors">FAQ</a></li>
</ul>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Community</h3>
<ul class="space-y-2 text-gray-400">
<li><a href="https://github.com/sharada-marasinha/JavaScript-Learning-Repository"
target="_blank" class="hover:text-white transition-colors">GitHub Repository</a></li>
<li><a href="https://github.com/sharada-marasinha/JavaScript-Learning-Repository/discussions"
target="_blank" class="hover:text-white transition-colors">Discussions</a></li>
<li><a href="https://github.com/sharada-marasinha/JavaScript-Learning-Repository/blob/main/CONTRIBUTING.md"
target="_blank" class="hover:text-white transition-colors">Contribute</a></li>
<li><a href="https://github.com/sharada-marasinha/JavaScript-Learning-Repository/issues"
target="_blank" class="hover:text-white transition-colors">Support</a></li>
</ul>
</div>
</div>
<div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-400">
<p>© 2025 JavaScript Learning Hub. Made with ❤️ for the developer community.</p>
</div>
</div>
</footer>
<!-- JavaScript for interactivity -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-javascript.min.js"></script>
<script>
// Lesson data for the homepage
const homepageLessons = [
{
title: "01. Variables & Data Types",
description: "Learn about variable declarations, data types, and scope in JavaScript.",
color: "from-edu-blue to-blue-600",
code: 'let message = "Hello World!";'
},
{
title: "02. Arithmetic Expressions",
description: "Master mathematical operations and calculations in JavaScript.",
color: "from-edu-green to-green-600",
code: 'let result = 10 + 5 * 2;'
},
{
title: "03. User Input",
description: "Create interactive programs that respond to user input.",
color: "from-edu-purple to-purple-600",
code: 'let name = prompt("Enter name");'
},
{
title: "04. Type Conversion",
description: "Learn to convert between different data types effectively.",
color: "from-edu-yellow to-yellow-600",
code: 'let num = parseInt("123");'
},
{
title: "05. Constants",
description: "Understand immutable variables and when to use const.",
color: "from-red-500 to-red-600",
code: 'const PI = 3.14159;'
},
{
title: "06. Math Object",
description: "Explore the Math object for advanced mathematical operations.",
color: "from-indigo-500 to-indigo-600",
code: 'Math.random() * 100;'
}
];
// Render lesson cards
function renderLessonCards() {
const container = document.getElementById('lesson-cards');
container.innerHTML = homepageLessons.map(lesson => `
<div class="bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition-shadow cursor-pointer"
onclick="window.location.href='lessons.html'">
<div class="bg-gradient-to-r ${lesson.color} p-4">
<h3 class="text-white font-bold text-lg">${lesson.title}</h3>
</div>
<div class="p-6">
<p class="text-gray-600 mb-4">${lesson.description}</p>
<div class="code-preview text-sm">
<code class="text-green-400">${lesson.code}</code>
</div>
<button class="mt-4 text-edu-blue font-semibold hover:text-blue-600 transition-colors">
Start Lesson →
</button>
</div>
</div>
`).join('');
}
// Demo code functionality
function initDemoCode() {
const runButton = document.getElementById('run-demo-code');
const copyButton = document.getElementById('copy-demo-code');
const codeEditor = document.getElementById('demo-code-editor');
const outputDiv = document.getElementById('demo-output');
runButton.addEventListener('click', () => {
const code = codeEditor.value;
outputDiv.innerHTML = '';
outputDiv.classList.remove('hidden');
// Capture console.log output
const originalLog = console.log;
const logs = [];
console.log = (...args) => {
logs.push(args.map(arg =>
typeof arg === 'object' ? JSON.stringify(arg, null, 2) : String(arg)
).join(' '));
};
try {
eval(code);
if (logs.length > 0) {
outputDiv.innerHTML = `<div class="text-green-400">Output:</div>${logs.map(log => `<div class="ml-4">${log}</div>`).join('')}`;
} else {
outputDiv.innerHTML = '<div class="text-gray-400">No output generated</div>';
}
} catch (error) {
outputDiv.innerHTML = `<div class="text-red-400">Error: ${error.message}</div>`;
} finally {
console.log = originalLog;
}
});
copyButton.addEventListener('click', () => {
navigator.clipboard.writeText(codeEditor.value).then(() => {
copyButton.innerHTML = '✅ Copied!';
setTimeout(() => {
copyButton.innerHTML = '📋 Copy Code';
}, 2000);
});
});
}
// Smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Scroll to lessons function
function scrollToLessons() {
const lessonsSection = document.getElementById('lessons');
if (lessonsSection) {
lessonsSection.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
} else {
window.location.href = 'lessons.html';
}
}
// Mobile menu toggle
const mobileMenuButton = document.querySelector('button[class*="md:hidden"]');
let mobileMenuOpen = false;
if (mobileMenuButton) {
mobileMenuButton.addEventListener('click', function () {
mobileMenuOpen = !mobileMenuOpen;
if (mobileMenuOpen) {
// Create mobile menu
const mobileMenu = document.createElement('div');
mobileMenu.className = 'md:hidden bg-white border-t border-gray-200 px-4 py-4 space-y-4';
mobileMenu.innerHTML = `
<a href="#home" class="block text-gray-700 hover:text-edu-blue transition-colors">Home</a>
<a href="lessons.html" class="block text-gray-700 hover:text-edu-blue transition-colors">Lessons</a>
<a href="playground.html" class="block text-gray-700 hover:text-edu-blue transition-colors">Playground</a>
<a href="algorithms.html" class="block text-gray-700 hover:text-edu-blue transition-colors">Algorithms</a>
<a href="exercises.html" class="block text-gray-700 hover:text-edu-blue transition-colors">Exercises</a>
<button onclick="window.location.href='lessons.html'" class="w-full bg-edu-blue text-white px-4 py-2 rounded-lg hover:bg-blue-600 transition-colors">
Get Started
</button>
`;
mobileMenuButton.closest('nav').appendChild(mobileMenu);
} else {
// Remove mobile menu
const existingMenu = mobileMenuButton.closest('nav').querySelector('.md\\:hidden.bg-white');
if (existingMenu) {
existingMenu.remove();
}
}
});
}
// Animation on scroll
function animateOnScroll() {
const elements = document.querySelectorAll('.feature-card, .bg-white.rounded-lg');
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
});
elements.forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(20px)';
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(el);
});
}
// Counter animation for statistics
function animateCounters() {
const counters = document.querySelectorAll('.text-4xl.font-bold');
counters.forEach(counter => {
const target = parseInt(counter.textContent.replace(/\D/g, ''));
let current = 0;
const increment = target / 50;
const suffix = counter.textContent.replace(/\d/g, '');
const updateCounter = () => {
if (current < target) {
current += increment;
counter.textContent = Math.floor(current) + suffix;
setTimeout(updateCounter, 40);
} else {
counter.textContent = target + suffix;
}
};
// Start animation when element is visible
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
updateCounter();
observer.unobserve(entry.target);
}
});
});
observer.observe(counter);
});
}
// Initialize everything when DOM is loaded
document.addEventListener('DOMContentLoaded', function () {
renderLessonCards();
initDemoCode();
animateOnScroll();
animateCounters();
// Add some interactive hover effects
document.querySelectorAll('.feature-card').forEach(card => {
card.addEventListener('mouseenter', function () {
this.style.transform = 'translateY(-5px) scale(1.02)';
});
card.addEventListener('mouseleave', function () {
this.style.transform = 'translateY(0) scale(1)';
});
});
});
// Add keyboard shortcuts
document.addEventListener('keydown', function (e) {
// Ctrl/Cmd + Enter to run demo code
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
const runButton = document.getElementById('run-demo-code');
if (runButton) {
runButton.click();
}
}
// Escape to close mobile menu
if (e.key === 'Escape') {
const mobileMenu = document.querySelector('.md\\:hidden.bg-white');
if (mobileMenu) {
mobileMenu.remove();
mobileMenuOpen = false;
}
}
});
</script>
</body>
</html>