summaryrefslogtreecommitdiff
path: root/startpage/startpage.js
blob: 3fc9701c926d5f01c5eeed4bb13ad77025433a5b (plain)
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
(function () {
    function byId(id) {
        return document.getElementById(id);
    }

    function updateClock() {
        const dateEl = byId('realtime-date');
        const timeEl = byId('realtime-clock');
        if (!dateEl || !timeEl) return;

        const now = new Date();
        const options = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' };
        dateEl.textContent = now.toLocaleDateString(undefined, options).toUpperCase();
        timeEl.textContent = now.toLocaleTimeString();
    }

    setInterval(updateClock, 1000);
    updateClock();

    // Age Verification System
    let isVerified = false;

    const content = byId('age-restricted-content');
    const modal = byId('age-verification-modal');
    const yesBtn = byId('age-verify-yes');
    const noBtn = byId('age-verify-no');

    function unlockContent() {
        if (!content) return;
        content.classList.remove('locked');
        content.classList.add('unlocked');
        content.removeEventListener('click', handleContentClick);
        isVerified = true;
        localStorage.setItem('ageVerified', 'true');
    }

    function showAgeModal() {
        if (!modal) return;
        modal.classList.remove('hidden');
    }

    function hideAgeModal() {
        if (!modal) return;
        modal.classList.add('hidden');
    }

    function handleContentClick(e) {
        if (isVerified) return;

        e.preventDefault();
        e.stopPropagation();
        showAgeModal();
    }

    function confirmAge(isOfAge) {
        if (!modal) return;

        if (isOfAge) {
            unlockContent();
            hideAgeModal();
            alert('Age verified. You can now access restricted content.');
        } else {
            hideAgeModal();
            window.location.href = 'https://www.google.com';
        }
    }

    if (content && modal) {
        const storedVerification = localStorage.getItem('ageVerified');
        if (storedVerification === 'true') {
            unlockContent();
        } else {
            showAgeModal();
        }

        content.addEventListener('click', handleContentClick);

        if (yesBtn) yesBtn.addEventListener('click', function () { confirmAge(true); });
        if (noBtn) noBtn.addEventListener('click', function () { confirmAge(false); });

        document.addEventListener('keydown', function (e) {
            if (e.altKey && e.key === 'a') {
                showAgeModal();
            }
        });
    }
})();