Repository navigation
Expand file tree
/
Copy pathenhanced-interactivity.js
More file actions
826 lines (710 loc) · 28.7 KB
/
Copy pathenhanced-interactivity.js
File metadata and controls
826 lines (710 loc) · 28.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
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
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
// ============================================================================
// CLAUDE CODE DOCUMENTATION - ADVANCED INTERACTIVITY & ENHANCEMENT SYSTEM
// ============================================================================
// Version: 1.0.0
// Features: Advanced Search, Keyboard Nav, Animations, Syntax Highlighting,
// Progress Bar, Count-up Stats, Scroll Effects, Accessibility
// ============================================================================
// ============================================================================
// UTILITIES & HELPERS
// ============================================================================
// Debounce function for performance optimization
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
// Check if user prefers reduced motion
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
// Easing functions for smooth animations
const easing = {
easeOutQuad: t => t * (2 - t),
easeInOutCubic: t => t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1,
easeOutExpo: t => t === 1 ? 1 : 1 - Math.pow(2, -10 * t)
};
// ============================================================================
// READING PROGRESS BAR
// ============================================================================
function createProgressBar() {
const progressBar = document.createElement('div');
progressBar.id = 'reading-progress';
progressBar.style.cssText = `
position: fixed;
top: 0;
left: 0;
height: 3px;
background: linear-gradient(90deg, var(--primary), var(--secondary));
width: 0%;
z-index: 9999;
transition: width 0.1s ease;
`;
document.body.appendChild(progressBar);
const updateProgress = () => {
const windowHeight = window.innerHeight;
const documentHeight = document.documentElement.scrollHeight - windowHeight;
const scrolled = window.scrollY;
const progress = (scrolled / documentHeight) * 100;
progressBar.style.width = `${Math.min(progress, 100)}%`;
};
window.addEventListener('scroll', debounce(updateProgress, 10));
updateProgress();
}
// ============================================================================
// ADVANCED SEARCH SYSTEM WITH KEYBOARD NAVIGATION
// ============================================================================
function createAdvancedSearch() {
// Create search container in agents section
const agentsSection = document.getElementById('agents');
if (!agentsSection) return;
const searchContainer = document.createElement('div');
searchContainer.className = 'search-box';
searchContainer.style.marginTop = '2rem';
searchContainer.innerHTML = `
<span class="search-icon">🔍</span>
<input type="text" id="agent-search" class="search-input"
placeholder="Search agents... (try: accessibility, performance, security)"
autocomplete="off">
<div id="search-results" style="display: none; position: absolute; top: 100%; left: 0; right: 0;
background: var(--bg-secondary); border: 1px solid var(--border-primary);
border-radius: 0.5rem; margin-top: 0.5rem; max-height: 400px; overflow-y: auto; z-index: 100;">
</div>
`;
const agentsTitle = agentsSection.querySelector('h2');
agentsTitle.insertAdjacentElement('afterend', searchContainer);
const searchInput = document.getElementById('agent-search');
const searchResults = document.getElementById('search-results');
const agentCards = document.querySelectorAll('.agent-card');
let selectedIndex = -1;
let searchableItems = [];
// Build searchable index
agentCards.forEach(card => {
const title = card.querySelector('h3').textContent;
const description = card.querySelector('p').textContent;
const tags = Array.from(card.querySelectorAll('.tag')).map(t => t.textContent).join(' ');
searchableItems.push({
element: card,
title,
description,
tags,
searchText: `${title} ${description} ${tags}`.toLowerCase()
});
});
// Debounced search function
const performSearch = debounce((query) => {
if (!query.trim()) {
searchResults.style.display = 'none';
agentCards.forEach(card => card.style.display = '');
selectedIndex = -1;
return;
}
const searchTerm = query.toLowerCase();
const matches = searchableItems.filter(item =>
item.searchText.includes(searchTerm)
);
// Show/hide cards
agentCards.forEach(card => card.style.display = 'none');
matches.forEach(match => match.element.style.display = '');
// Show search results dropdown
if (matches.length > 0) {
searchResults.innerHTML = matches.map((match, index) => `
<div class="search-result-item" data-index="${index}" style="
padding: 1rem;
cursor: pointer;
border-bottom: 1px solid var(--border-primary);
transition: background 0.2s;
" onmouseover="this.style.background='var(--bg-tertiary)'"
onmouseout="this.style.background='transparent'">
<div style="font-weight: 600; color: var(--primary);">${highlightMatch(match.title, searchTerm)}</div>
<div style="font-size: 0.875rem; color: var(--text-secondary); margin-top: 0.25rem;">
${highlightMatch(match.description.substring(0, 100) + '...', searchTerm)}
</div>
</div>
`).join('');
searchResults.style.display = 'block';
} else {
searchResults.innerHTML = `
<div style="padding: 1rem; text-align: center; color: var(--text-tertiary);">
No agents found for "${query}"
</div>
`;
searchResults.style.display = 'block';
}
}, 300);
// Highlight matching text
function highlightMatch(text, query) {
const regex = new RegExp(`(${query})`, 'gi');
return text.replace(regex, '<mark style="background: var(--primary); color: var(--bg-primary); padding: 0 0.25rem; border-radius: 0.25rem;">$1</mark>');
}
// Keyboard navigation
searchInput.addEventListener('keydown', (e) => {
const items = searchResults.querySelectorAll('.search-result-item');
if (e.key === 'ArrowDown') {
e.preventDefault();
selectedIndex = Math.min(selectedIndex + 1, items.length - 1);
updateSelection(items);
} else if (e.key === 'ArrowUp') {
e.preventDefault();
selectedIndex = Math.max(selectedIndex - 1, -1);
updateSelection(items);
} else if (e.key === 'Enter' && selectedIndex >= 0) {
e.preventDefault();
const match = searchableItems.filter(item =>
item.searchText.includes(searchInput.value.toLowerCase())
)[selectedIndex];
if (match) {
match.element.scrollIntoView({ behavior: 'smooth', block: 'center' });
match.element.querySelector('details')?.setAttribute('open', '');
searchResults.style.display = 'none';
}
} else if (e.key === 'Escape') {
searchResults.style.display = 'none';
selectedIndex = -1;
}
});
function updateSelection(items) {
items.forEach((item, index) => {
if (index === selectedIndex) {
item.style.background = 'var(--bg-tertiary)';
item.scrollIntoView({ block: 'nearest' });
} else {
item.style.background = 'transparent';
}
});
}
searchInput.addEventListener('input', (e) => performSearch(e.target.value));
// Click outside to close
document.addEventListener('click', (e) => {
if (!searchContainer.contains(e.target)) {
searchResults.style.display = 'none';
}
});
}
// ============================================================================
// EXPANDABLE AGENT CARDS
// ============================================================================
function initializeExpandableCards() {
const agentCards = document.querySelectorAll('.agent-card');
let currentlyExpanded = null;
agentCards.forEach(card => {
const details = card.querySelector('details');
if (!details) return;
const summary = details.querySelector('summary');
// Add expand icon
const icon = document.createElement('span');
icon.textContent = ' ▼';
icon.style.cssText = `
display: inline-block;
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
font-size: 0.75rem;
margin-left: 0.5rem;
`;
summary.appendChild(icon);
details.addEventListener('toggle', () => {
if (!prefersReducedMotion) {
if (details.open) {
// Close previously expanded card
if (currentlyExpanded && currentlyExpanded !== details) {
currentlyExpanded.removeAttribute('open');
}
currentlyExpanded = details;
// Rotate icon
icon.style.transform = 'rotate(180deg)';
// Smooth expand animation
const content = details.querySelector('div');
if (content) {
content.style.animation = 'slideDown 0.3s ease-out';
}
// Scroll card into view
setTimeout(() => {
card.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}, 100);
} else {
icon.style.transform = 'rotate(0deg)';
}
}
});
});
// Add CSS animation
const style = document.createElement('style');
style.textContent = `
@keyframes slideDown {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
`;
document.head.appendChild(style);
}
// ============================================================================
// SYNTAX HIGHLIGHTING (Inline - Lightweight)
// ============================================================================
function initializeSyntaxHighlighting() {
// Lightweight syntax highlighter (inline)
const codeBlocks = document.querySelectorAll('pre code');
codeBlocks.forEach(block => {
const code = block.textContent;
// Simple syntax highlighting for common patterns
let highlighted = code
// Comments
.replace(/(#.*$)/gm, '<span style="color: #6A9955;">$1</span>')
// Strings
.replace(/(['"])(.+?)\1/g, '<span style="color: #CE9178;">$1$2$1</span>')
// Keywords (bash, powershell)
.replace(/\b(cd|ls|cat|npm|npx|git|Set-ExecutionPolicy|function|if|else|for|while|return)\b/g,
'<span style="color: #569CD6;">$1</span>')
// Commands/functions
.replace(/\b([a-z_]+)(?=\()/g, '<span style="color: #DCDCAA;">$1</span>')
// Variables
.replace(/\$\w+/g, '<span style="color: #9CDCFE;">$&</span>')
// Flags
.replace(/--?\w+/g, '<span style="color: #C586C0;">$&</span>');
block.innerHTML = highlighted;
// Add language badge
const pre = block.parentElement;
const badge = document.createElement('div');
badge.textContent = detectLanguage(code);
badge.style.cssText = `
position: absolute;
top: 0.5rem;
left: 0.5rem;
background: var(--bg-tertiary);
color: var(--text-tertiary);
padding: 0.25rem 0.5rem;
border-radius: 0.25rem;
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
`;
pre.appendChild(badge);
});
}
function detectLanguage(code) {
if (code.includes('npm') || code.includes('npx')) return 'bash';
if (code.includes('Set-ExecutionPolicy')) return 'powershell';
if (code.includes('import') || code.includes('export')) return 'javascript';
if (code.includes('---\nname:')) return 'yaml';
return 'code';
}
// ============================================================================
// ANIMATED STATISTICS (Count-up Effect)
// ============================================================================
function animateStatistics() {
const stats = document.querySelectorAll('.stat-value');
const observerOptions = {
threshold: 0.5,
rootMargin: '0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting && !entry.target.dataset.animated) {
entry.target.dataset.animated = 'true';
animateValue(entry.target);
}
});
}, observerOptions);
stats.forEach(stat => observer.observe(stat));
}
function animateValue(element) {
const text = element.textContent;
const isPercentage = text.includes('%');
const targetValue = parseInt(text.replace(/[^\d]/g, ''));
const duration = 2000;
const startTime = performance.now();
function update(currentTime) {
const elapsed = currentTime - startTime;
const progress = Math.min(elapsed / duration, 1);
const easedProgress = easing.easeOutExpo(progress);
const currentValue = Math.floor(easedProgress * targetValue);
element.textContent = isPercentage ? `${currentValue}%` : currentValue;
if (progress < 1) {
requestAnimationFrame(update);
} else {
element.textContent = text; // Restore original text
}
}
if (!prefersReducedMotion) {
requestAnimationFrame(update);
}
}
// ============================================================================
// SCROLL ANIMATIONS (Intersection Observer)
// ============================================================================
function initializeScrollAnimations() {
if (prefersReducedMotion) return;
const style = document.createElement('style');
style.textContent = `
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.animate-on-scroll {
opacity: 0;
}
.animate-on-scroll.visible {
animation: fadeInUp 0.6s ease-out forwards;
}
`;
document.head.appendChild(style);
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry, index) => {
if (entry.isIntersecting) {
// Stagger animation delay
setTimeout(() => {
entry.target.classList.add('visible');
}, index * 100);
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Observe cards
document.querySelectorAll('.card, .agent-card').forEach(card => {
card.classList.add('animate-on-scroll');
observer.observe(card);
});
}
// ============================================================================
// PARALLAX EFFECT ON HERO
// ============================================================================
function initializeParallax() {
if (prefersReducedMotion) return;
const hero = document.getElementById('hero');
if (!hero) return;
const handleScroll = () => {
const scrolled = window.scrollY;
const parallaxSpeed = 0.5;
requestAnimationFrame(() => {
hero.style.transform = `translateY(${scrolled * parallaxSpeed}px)`;
hero.style.opacity = 1 - (scrolled / 600);
});
};
window.addEventListener('scroll', debounce(handleScroll, 10));
}
// ============================================================================
// NAVIGATION & ACTIVE STATE
// ============================================================================
const sections = document.querySelectorAll('.section');
const navLinks = document.querySelectorAll('.nav-links a');
function updateActiveLink() {
const scrollPos = window.scrollY + 100;
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.offsetHeight;
const sectionId = section.getAttribute('id');
if (scrollPos >= sectionTop && scrollPos < sectionTop + sectionHeight) {
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href') === `#${sectionId}`) {
link.classList.add('active');
}
});
}
});
}
window.addEventListener('scroll', updateActiveLink);
// Mobile nav toggle
const navToggle = document.querySelector('.nav-toggle');
const navLinksContainer = document.querySelector('.nav-links');
if (navToggle && navLinksContainer) {
navToggle.addEventListener('click', () => {
navLinksContainer.classList.toggle('active');
});
// Close mobile nav on link click
navLinks.forEach(link => {
link.addEventListener('click', () => {
navLinksContainer.classList.remove('active');
});
});
}
// ============================================================================
// ENHANCED SEARCH FUNCTIONALITY (Troubleshooting & FAQ)
// ============================================================================
const troubleshootingSearch = document.getElementById('troubleshooting-search');
const troubleshootingList = document.getElementById('troubleshooting-list');
if (troubleshootingSearch) {
troubleshootingSearch.addEventListener('input', debounce((e) => {
const searchTerm = e.target.value.toLowerCase();
const details = troubleshootingList.querySelectorAll('details');
details.forEach(detail => {
const text = detail.textContent.toLowerCase();
if (text.includes(searchTerm)) {
detail.style.display = 'block';
// Auto-expand if searching
if (searchTerm.length > 2) {
detail.setAttribute('open', '');
}
} else {
detail.style.display = 'none';
}
});
}, 300));
}
const faqSearch = document.getElementById('faq-search');
const faqList = document.getElementById('faq-list');
if (faqSearch) {
faqSearch.addEventListener('input', debounce((e) => {
const searchTerm = e.target.value.toLowerCase();
const details = faqList.querySelectorAll('details');
details.forEach(detail => {
const text = detail.textContent.toLowerCase();
if (text.includes(searchTerm)) {
detail.style.display = 'block';
if (searchTerm.length > 2) {
detail.setAttribute('open', '');
}
} else {
detail.style.display = 'none';
}
});
}, 300));
}
// ============================================================================
// COPY CODE BUTTON WITH ENHANCED FEEDBACK
// ============================================================================
document.querySelectorAll('pre').forEach(pre => {
const button = document.createElement('button');
button.className = 'copy-button';
button.textContent = 'Copy';
button.addEventListener('click', () => {
const code = pre.querySelector('code').textContent;
navigator.clipboard.writeText(code).then(() => {
button.textContent = 'Copied!';
button.style.background = 'var(--success)';
setTimeout(() => {
button.textContent = 'Copy';
button.style.background = '';
}, 2000);
}).catch(err => {
button.textContent = 'Failed';
setTimeout(() => {
button.textContent = 'Copy';
}, 2000);
});
});
pre.style.position = 'relative';
pre.appendChild(button);
});
// ============================================================================
// READING TIME ESTIMATOR
// ============================================================================
function addReadingTime() {
const sections = document.querySelectorAll('.section');
const wordsPerMinute = 200;
sections.forEach(section => {
const text = section.textContent;
const wordCount = text.trim().split(/\s+/).length;
const readingTime = Math.ceil(wordCount / wordsPerMinute);
const heading = section.querySelector('h2');
if (heading && readingTime > 1) {
const badge = document.createElement('span');
badge.textContent = `${readingTime} min read`;
badge.style.cssText = `
display: inline-block;
margin-left: 1rem;
padding: 0.25rem 0.75rem;
background: var(--bg-tertiary);
color: var(--text-tertiary);
border-radius: 9999px;
font-size: 0.875rem;
font-weight: 500;
`;
heading.appendChild(badge);
}
});
}
// ============================================================================
// ACCESSIBILITY: FOCUS INDICATORS & SKIP LINK
// ============================================================================
function enhanceAccessibility() {
const style = document.createElement('style');
style.textContent = `
*:focus-visible {
outline: 2px solid var(--primary);
outline-offset: 2px;
border-radius: 0.25rem;
}
a:focus-visible, button:focus-visible {
outline: 3px solid var(--primary);
}
/* Skip to main content link */
.skip-to-main {
position: absolute;
top: -40px;
left: 0;
background: var(--primary);
color: var(--bg-primary);
padding: 0.5rem 1rem;
text-decoration: none;
z-index: 10000;
}
.skip-to-main:focus {
top: 0;
}
`;
document.head.appendChild(style);
// Add skip to main content link
const skipLink = document.createElement('a');
skipLink.href = '#hero';
skipLink.className = 'skip-to-main';
skipLink.textContent = 'Skip to main content';
document.body.insertBefore(skipLink, document.body.firstChild);
}
// ============================================================================
// PERFORMANCE: LAZY LOAD IMAGES
// ============================================================================
function lazyLoadImages() {
const imageObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const img = entry.target;
if (img.dataset.src) {
img.src = img.dataset.src;
img.classList.remove('lazy');
imageObserver.unobserve(img);
}
}
});
});
document.querySelectorAll('img[data-src]').forEach(img => {
imageObserver.observe(img);
});
}
// ============================================================================
// SMOOTH SCROLL BEHAVIOR
// ============================================================================
function enableSmoothScroll() {
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'
});
}
});
});
}
// ============================================================================
// TABLE OF CONTENTS GENERATOR
// ============================================================================
function generateTableOfContents() {
const headings = document.querySelectorAll('h2, h3');
if (headings.length < 5) return; // Only generate if there are enough headings
const tocContainer = document.createElement('div');
tocContainer.id = 'table-of-contents';
tocContainer.style.cssText = `
position: fixed;
right: 2rem;
top: 100px;
width: 250px;
max-height: calc(100vh - 150px);
overflow-y: auto;
background: var(--bg-secondary);
border: 1px solid var(--border-primary);
border-radius: 0.5rem;
padding: 1rem;
display: none;
z-index: 100;
`;
const tocTitle = document.createElement('h4');
tocTitle.textContent = 'Table of Contents';
tocTitle.style.cssText = `
color: var(--primary);
margin-bottom: 1rem;
font-size: 1rem;
`;
tocContainer.appendChild(tocTitle);
const tocList = document.createElement('ul');
tocList.style.cssText = `
list-style: none;
padding: 0;
margin: 0;
`;
headings.forEach((heading, index) => {
const id = heading.id || `heading-${index}`;
heading.id = id;
const li = document.createElement('li');
li.style.cssText = `
margin: 0.5rem 0;
padding-left: ${heading.tagName === 'H3' ? '1rem' : '0'};
`;
const link = document.createElement('a');
link.href = `#${id}`;
link.textContent = heading.textContent.replace(/\d+\smin\sread/, '').trim();
link.style.cssText = `
color: var(--text-secondary);
font-size: 0.875rem;
text-decoration: none;
transition: color 0.2s;
`;
link.addEventListener('mouseover', () => link.style.color = 'var(--primary)');
link.addEventListener('mouseout', () => link.style.color = 'var(--text-secondary)');
li.appendChild(link);
tocList.appendChild(li);
});
tocContainer.appendChild(tocList);
document.body.appendChild(tocContainer);
// Show/hide TOC on larger screens
if (window.innerWidth > 1400) {
tocContainer.style.display = 'block';
}
window.addEventListener('resize', debounce(() => {
tocContainer.style.display = window.innerWidth > 1400 ? 'block' : 'none';
}, 300));
}
// ============================================================================
// INITIALIZE ALL FEATURES
// ============================================================================
document.addEventListener('DOMContentLoaded', () => {
// Core features
updateActiveLink();
// Advanced features
createProgressBar();
createAdvancedSearch();
initializeExpandableCards();
initializeSyntaxHighlighting();
animateStatistics();
initializeScrollAnimations();
initializeParallax();
addReadingTime();
enhanceAccessibility();
lazyLoadImages();
enableSmoothScroll();
generateTableOfContents();
// Log initialization (for debugging)
console.log('%c🌟 Claude Code Documentation Enhanced!',
'color: #3DD6C7; font-size: 16px; font-weight: bold;');
console.log('%cFeatures Loaded:', 'color: #6366F1; font-size: 12px; font-weight: bold;');
console.log('%c✓ Advanced Search with Keyboard Navigation', 'color: #34D399; font-size: 11px;');
console.log('%c✓ Expandable Agent Cards', 'color: #34D399; font-size: 11px;');
console.log('%c✓ Syntax Highlighting', 'color: #34D399; font-size: 11px;');
console.log('%c✓ Reading Progress Bar', 'color: #34D399; font-size: 11px;');
console.log('%c✓ Animated Statistics', 'color: #34D399; font-size: 11px;');
console.log('%c✓ Scroll Animations', 'color: #34D399; font-size: 11px;');
console.log('%c✓ Parallax Effects', 'color: #34D399; font-size: 11px;');
console.log('%c✓ Reading Time Estimator', 'color: #34D399; font-size: 11px;');
console.log('%c✓ Accessibility Enhancements', 'color: #34D399; font-size: 11px;');
console.log('%c✓ Table of Contents', 'color: #34D399; font-size: 11px;');
});