Dashboard Temp Share Shortlinks Frames API

HTMLify

script.js
Views: 12 | Author: karbonsites
 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
document.addEventListener('DOMContentLoaded', () => {
    // 1. Simulate CTA button click on Dashboard
    const uploadBtn = document.getElementById('uploadBtn');
    if (uploadBtn) {
        uploadBtn.addEventListener('click', () => {
            alert('Simulating file upload and analysis initiation... Redirecting to detailed report.');
            window.location.href = 'analysis.html';
        });
    }

    // 2. Settings Page Navigation Logic
    const settingsContent = document.querySelector('.settings-content');
    if (settingsContent) {
        const settingsNavLinks = document.querySelectorAll('.settings-nav a');
        const sections = settingsContent.querySelectorAll('section');

        settingsNavLinks.forEach(link => {
            link.addEventListener('click', (e) => {
                e.preventDefault();
                
                // Update active link styling
                settingsNavLinks.forEach(l => l.classList.remove('active'));
                link.classList.add('active');

                // Show correct section
                const targetId = link.getAttribute('href').substring(1);
                sections.forEach(section => {
                    if (section.id === targetId) {
                        section.style.display = 'block';
                    } else {
                        section.style.display = 'none';
                    }
                });
            });
        });
        
        // Initial state setup for settings based on URL hash if present
        const initialHash = window.location.hash;
        if(initialHash) {
            const initialLink = document.querySelector(`.settings-nav a[href="${initialHash}"]`);
            if(initialLink) {
                initialLink.click();
            } else {
                 // Default to account if hash is invalid or missing on load
                document.querySelector('.settings-nav a[href="#account"]').classList.add('active');
                document.getElementById('account').style.display = 'block';
            }
        } else {
            // Ensure 'Account Details' is shown by default if no hash is present
            document.querySelector('.settings-nav a[href="#account"]').classList.add('active');
            document.getElementById('account').style.display = 'block';
        }
    }

    // 3. Range Slider Display for Hook Weighting
    const hookWeightInput = document.getElementById('hookWeight');
    const hookValueDisplay = document.getElementById('hookValueDisplay');
    if (hookWeightInput && hookValueDisplay) {
        hookValueDisplay.textContent = `${hookWeightInput.value}%`;
        hookWeightInput.addEventListener('input', () => {
            hookValueDisplay.textContent = `${hookWeightInput.value}%`;
        });
    }

    // 4. Automation Page Specific Logic (Webhook Test)
    const testAutomationBtn = document.getElementById('testAutomationBtn');
    const testResult = document.getElementById('testResult');
    if (testAutomationBtn && testResult) {
        testAutomationBtn.addEventListener('click', () => {
            testResult.textContent = 'Sending test ping to webhook... Standby...';
            testResult.style.color = 'var(--color-warning)';
            
            setTimeout(() => {
                // Simulate successful webhook processing and analysis completion
                const analysisTime = (Math.random() * 3 + 1).toFixed(1);
                testResult.textContent = `Success! Test analysis completed in ${analysisTime} seconds. Report available on Dashboard.`;
                testResult.style.color = 'var(--color-success)';
                
                // Update last hook time simulation
                const lastHookTimeEl = document.getElementById('lastHookTime');
                if(lastHookTimeEl) {
                    lastHookTimeEl.textContent = 'Just now (Simulated Test)';
                }
            }, 2000);
        });
    }
});