File size: 1,290 Bytes
e6731bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Main application script
document.addEventListener('DOMContentLoaded', function() {
    // Initialize clipboard functionality
    const copyButtons = document.querySelectorAll('.copy-button');
    
    copyButtons.forEach(button => {
        button.addEventListener('click', async () => {
            const codeBlock = button.parentElement.nextElementSibling.querySelector('code');
            try {
                await navigator.clipboard.writeText(codeBlock.textContent);
                button.innerHTML = '<i data-feather="check" class="w-4 h-4 inline mr-1"></i> Copied!';
                feather.replace();
                setTimeout(() => {
                    button.innerHTML = '<i data-feather="copy" class="w-4 h-4 inline mr-1"></i> Copy';
                    feather.replace();
                }, 2000);
            } catch (err) {
                console.error('Failed to copy text: ', err);
            }
        });
    });

    // 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'
            });
        });
    });
});