Dashboard Temp Share Shortlinks Frames API

HTMLify

script.js
Views: 2 | 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
document.addEventListener('DOMContentLoaded', () => {
    // 1. Scroll Animation Observer for Fade-Ins
    const observerOptions = {
        root: null,
        rootMargin: '0px',
        threshold: 0.1
    };

    const observer = new IntersectionObserver((entries, observer) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                entry.target.classList.add('visible');
                observer.unobserve(entry.target);
            }
        });
    }, observerOptions);

    document.querySelectorAll('.fade-in').forEach(el => {
        observer.observe(el);
    });

    // 2. Video Player Mock Interaction (Simulating Play)
    const videoPlayerMock = document.querySelector('.video-player-mock');
    if (videoPlayerMock) {
        videoPlayerMock.addEventListener('click', () => {
            alert('Video stream initiated! (This is a mock player for demonstration)');
            // In a real app, this would load the actual video element
        });
    }

    // 3. Download Button Mock (For Library Page)
    document.querySelectorAll('.btn-download').forEach(button => {
        button.addEventListener('click', (e) => {
            e.preventDefault();
            const filename = e.target.getAttribute('data-filename');
            alert(`Preparing download for: ${filename}. (File download simulated for APK export context)`);
        });
    });

    // 4. Share Verse Functionality
    const shareButton = document.querySelector('.btn-share');
    if (shareButton) {
        shareButton.addEventListener('click', () => {
            const verseText = document.querySelector('.verse-content').innerText;
            
            // Check for Web Share API (for actual mobile devices/browsers)
            if (navigator.share) {
                navigator.share({
                    title: 'Quran 50M Daily Verse',
                    text: verseText
                }).catch((error) => {
                    console.error('Error sharing:', error);
                    // Fallback for environments where share fails (like simple web view)
                    fallbackShare(verseText);
                });
            } else {
                // Fallback for desktop or unsupported environments
                fallbackShare(verseText);
            }
        });
    }

    function fallbackShare(text) {
        // Simple copy to clipboard fallback
        navigator.clipboard.writeText(text).then(() => {
            alert('Verse copied to clipboard!\n\n' + text.substring(0, 100) + '...');
        }).catch(err => {
            alert('Could not copy verse. Please copy manually:\n\n' + text);
        });
    }
});