File size: 2,630 Bytes
8198c28
ad5df0f
8198c28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ad5df0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

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 = '<i data-feather="copy"></i>';
        button.addEventListener('click', () => {
            const code = pre.querySelector('code').innerText;
            navigator.clipboard.writeText(code).then(() => {
                button.innerHTML = '<i data-feather="check"></i>';
                setTimeout(() => {
                    button.innerHTML = '<i data-feather="copy"></i>';
                    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} <i data-feather="chevron-down" class="inline ml-2"></i>`;
            } 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');
        });
    });
});