File size: 4,378 Bytes
028f8f8
031dd25
53bf851
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1d4f33f
 
 
 
 
 
 
 
 
 
 
 
 
53bf851
 
028f8f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53bf851
 
031dd25
 
 
53bf851
 
031dd25
53bf851
031dd25
 
 
53bf851
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

document.addEventListener('DOMContentLoaded', function() {
    // Initialize feather icons
    feather.replace();
    
    // Mobile menu toggle
    const menuButton = document.querySelector('custom-header').shadowRoot.querySelector('.mobile-menu-button');
    const mobileMenu = document.querySelector('mobile-menu').shadowRoot.querySelector('.mobile-menu');
    const overlay = document.querySelector('custom-header').shadowRoot.querySelector('.overlay');
    
    if (menuButton && mobileMenu) {
        menuButton.addEventListener('click', () => {
            mobileMenu.classList.add('open');
            overlay.classList.add('active');
            document.body.style.overflow = 'hidden';
        });
        
        overlay.addEventListener('click', () => {
            mobileMenu.classList.remove('open');
            overlay.classList.remove('active');
            document.body.style.overflow = '';
        });
    }
    
    // Set active nav link based on current page
    const currentPath = window.location.pathname.split('/').pop() || 'index.html';
    const navLinks = document.querySelectorAll('custom-header nav a, mobile-menu nav a');
    
    navLinks.forEach(link => {
        const linkPath = link.getAttribute('href');
        if (currentPath === linkPath) {
            link.classList.add('active');
        } else {
            link.classList.remove('active');
        }
    });
    
    // Copy bonus code functionality
    document.querySelectorAll('.copy-bonus').forEach(button => {
        button.addEventListener('click', function() {
            const code = this.getAttribute('data-code');
            navigator.clipboard.writeText(code).then(() => {
                const originalText = this.textContent;
                this.textContent = 'Copied!';
                setTimeout(() => {
                    this.textContent = originalText;
                }, 2000);
            });
        });
    });
    
    // Quiz evaluation functionality
    const evaluateBtn = document.getElementById('evaluate-btn');
    if (evaluateBtn) {
        evaluateBtn.addEventListener('click', function() {
            const q1 = document.querySelector('input[name="q1"]:checked');
            const q2 = document.querySelector('input[name="q2"]:checked');
            const q3 = document.querySelector('input[name="q3"]:checked');
            
            if (!q1 || !q2 || !q3) {
                alert('Please answer all questions before evaluating.');
                return;
            }

            const answers = {
                q1: q1.nextElementSibling.textContent.toLowerCase(),
                q2: q2.nextElementSibling.textContent.toLowerCase(),
                q3: q3.nextElementSibling.textContent.toLowerCase()
            };

            let score = 0;
            if (answers.q1 === 'sometimes') score += 1;
            if (answers.q1 === 'often') score += 2;
            if (answers.q2 === 'sometimes') score += 1;
            if (answers.q2 === 'often') score += 2;
            if (answers.q3 === 'sometimes') score += 1;
            if (answers.q3 === 'often') score += 2;

            let riskLevel, message;
            if (score <= 2) {
                riskLevel = "Low Risk";
                message = "Your answers suggest your gambling habits are currently low risk. Continue to gamble responsibly and be aware of warning signs.";
            } else if (score <= 4) {
                riskLevel = "Moderate Risk";
                message = "Your answers indicate some potential risk factors. Consider setting stricter limits and monitoring your gambling more carefully.";
            } else {
                riskLevel = "High Risk";
                message = "Your answers suggest behaviors associated with problem gambling. We strongly recommend seeking support and considering self-exclusion tools.";
            }

            const modal = document.querySelector('custom-modal');
            modal.openModal(riskLevel, message);
        });
    }
    
    // Sticky header
    const header = document.querySelector('custom-header');
    if (header) {
        window.addEventListener('scroll', function() {
            if (window.scrollY > 50) {
                header.style.boxShadow = '0 2px 10px rgba(0, 0, 0, 0.1)';
            } else {
                header.style.boxShadow = 'none';
            }
        });
    }
});