File size: 3,910 Bytes
a0e60fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b366664
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a0e60fd
df8246b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b366664
 
 
 
 
 
 
df8246b
 
 
 
 
 
b366664
df8246b
 
b366664
df8246b
 
 
 
 
 
 
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

// Highlight active script section based on video time
if (video) {
    video.addEventListener('timeupdate', () => {
        const currentTime = video.currentTime;
        document.querySelectorAll('.section').forEach(section => {
            const timeRange = section.dataset.time;
            const [start, end] = timeRange.split('–').map(time => {
                const [mins, secs] = time.split(':').map(Number);
                return mins * 60 + secs;
            });

            if (currentTime >= start && currentTime <= end) {
                section.classList.add('active');
                section.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
            } else {
                section.classList.remove('active');
            }
        });
    });
}
// Video Generation Logic
let videoGenerationInterval;

function generateVideoFromScript() {
    const modal = document.getElementById('videoModal');
    const progressBar = document.getElementById('progressBar');
    const progressPercent = document.getElementById('progressPercent');
    const videoPreview = document.getElementById('videoPreview');
    const generatedVideo = document.getElementById('generatedVideo');
    const downloadBtn = document.getElementById('downloadBtn');
    
    modal.classList.remove('hidden');
    document.body.style.overflow = 'hidden';
    
    let progress = 0;
    videoGenerationInterval = setInterval(() => {
        progress += Math.random() * 10;
        if (progress > 100) progress = 100;
        
        progressBar.style.width = `${progress}%`;
        progressPercent.textContent = `${Math.floor(progress)}%`;
        
        if (progress === 100) {
            clearInterval(videoGenerationInterval);
            videoPreview.classList.remove('hidden');
            
            // In a real app, this would be the actual generated video URL
            const demoVideoUrl = 'https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_5mb.mp4';
            generatedVideo.src = demoVideoUrl;
            downloadBtn.href = demoVideoUrl;
            downloadBtn.download = 'generated_video.mp4';
        }
    }, 300);
}

function closeVideoModal() {
    clearInterval(videoGenerationInterval);
    document.getElementById('videoModal').classList.add('hidden');
    document.body.style.overflow = '';
}

// Initialize tooltips for script sections
document.addEventListener('DOMContentLoaded', function() {
    // Add hover effects to script sections
    const sections = document.querySelectorAll('.section');
    
    sections.forEach(section => {
        section.addEventListener('mouseenter', function() {
            this.style.transform = 'translateY(-6px)';
            this.style.boxShadow = '0 18px 36px rgba(2,8,20,0.6)';
        });
        
        section.addEventListener('mouseleave', function() {
            this.style.transform = '';
            this.style.boxShadow = '';
        });
    });
    // Event listeners
    document.getElementById('generateVideoBtn').addEventListener('click', generateVideoFromScript);
    document.getElementById('closeModal').addEventListener('click', closeVideoModal);
    document.getElementById('newVideoBtn').addEventListener('click', () => {
        document.getElementById('videoPreview').classList.add('hidden');
        generateVideoFromScript();
    });

    // Form submission handler
    const form = document.querySelector('form');
    if (form) {
        form.addEventListener('submit', function(e) {
            e.preventDefault();
            generateVideoFromScript();
        });
    }
// Make time indicators clickable to simulate playback
    document.querySelectorAll('.section').forEach(section => {
        const time = section.dataset.time;
        section.querySelector('.section-title').addEventListener('click', () => {
            console.log(`Jump to ${time} in the video`);
        });
    });
});