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