Download script.js from techaman/futuroscript-visionary-tech-narrator: direct link, hf CLI and curl.
- Browser
- Download file 3.91 kB
-
https://huggingface.co/spaces/techaman/futuroscript-visionary-tech-narrator/resolve/main/script.js
- Command line
-
hf download hf://spaces/techaman/futuroscript-visionary-tech-narrator/script.js
-
curl -L -o script.js https://huggingface.co/spaces/techaman/futuroscript-visionary-tech-narrator/resolve/main/script.js
3.91 kB
| // 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`); | |
| }); | |
| }); | |
| }); |