File size: 2,140 Bytes
e488dab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
document.addEventListener('DOMContentLoaded', function() {
    // Smooth scrolling for anchor links
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
            e.preventDefault();
            document.querySelector(this.getAttribute('href')).scrollIntoView({
                behavior: 'smooth'
            });
        });
    });

    // Copy code blocks to clipboard
    document.querySelectorAll('.code-block').forEach(block => {
        const copyButton = document.createElement('button');
        copyButton.innerHTML = '<i data-feather="copy" class="w-4 h-4"></i>';
        copyButton.className = 'absolute top-2 right-2 p-1 rounded bg-gray-700 hover:bg-gray-600 text-gray-200';
        copyButton.title = 'Copy to clipboard';
        
        const header = block.querySelector('.code-header');
        if (header) {
            header.style.position = 'relative';
            header.appendChild(copyButton);
            
            copyButton.addEventListener('click', () => {
                const code = block.querySelector('.code-content').textContent;
                navigator.clipboard.writeText(code).then(() => {
                    copyButton.innerHTML = '<i data-feather="check" class="w-4 h-4"></i>';
                    setTimeout(() => {
                        copyButton.innerHTML = '<i data-feather="copy" class="w-4 h-4"></i>';
                        feather.replace();
                    }, 2000);
                });
            });
        }
    });

    // Highlight current step in viewport
    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                document.querySelectorAll('.step-card').forEach(card => {
                    card.classList.remove('border-blue-500', 'bg-blue-50');
                });
                entry.target.classList.add('border-blue-500', 'bg-blue-50');
            }
        });
    }, { threshold: 0.1 });

    document.querySelectorAll('.step-card').forEach(card => {
        observer.observe(card);
    });
});