document.addEventListener('DOMContentLoaded', function() { // Add copy buttons to all code blocks document.querySelectorAll('pre').forEach((pre) => { const button = document.createElement('button'); button.className = 'copy-btn'; button.innerHTML = ''; button.addEventListener('click', () => { const code = pre.querySelector('code').innerText; navigator.clipboard.writeText(code).then(() => { button.innerHTML = ''; setTimeout(() => { button.innerHTML = ''; feather.replace(); }, 2000); }); }); pre.style.position = 'relative'; pre.appendChild(button); }); // Create the animated hierarchy visualization const hierarchyContainer = document.getElementById('hierarchy-animation'); const hierarchyData = [ { name: "Programme COBOL", color: "bg-primary-500" }, { name: "Division", color: "bg-primary-400" }, { name: "Section", color: "bg-primary-300" }, { name: "Paragraphe", color: "bg-secondary-500" }, { name: "Phrase", color: "bg-secondary-400" }, { name: "Instruction", color: "bg-secondary-300" }, { name: "Chaîne de caractères", color: "bg-gray-300" } ]; // Build the hierarchy visualization let delay = 0; hierarchyData.forEach((item, index) => { setTimeout(() => { const element = document.createElement('div'); element.className = `hierarchy-item ${item.color} text-white animate-fade-in`; element.style.animationDelay = `${delay}s`; // Add indentation element.style.marginLeft = `${index * 1}rem`; // Add arrow for parent items if (index < hierarchyData.length - 1) { element.innerHTML = `${item.name} `; } else { element.textContent = item.name; } hierarchyContainer.appendChild(element); feather.replace(); }, delay * 300); delay += 0.3; }); // Add interactive code examples const codeExamples = document.querySelectorAll('pre code'); codeExamples.forEach((example) => { example.addEventListener('click', function() { this.classList.toggle('bg-gray-900'); this.classList.toggle('bg-gray-800'); }); }); });