Spaces:
Running
Running
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize tooltips | |
| const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); | |
| tooltipTriggerList.map(function (tooltipTriggerEl) { | |
| return new bootstrap.Tooltip(tooltipTriggerEl); | |
| }); | |
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| document.querySelector(this.getAttribute('href')).scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| }); | |
| }); | |
| // Add animation classes on scroll | |
| const animateOnScroll = function() { | |
| const elements = document.querySelectorAll('.animate-on-scroll'); | |
| elements.forEach(element => { | |
| const elementPosition = element.getBoundingClientRect().top; | |
| const screenPosition = window.innerHeight / 1.3; | |
| if (elementPosition < screenPosition) { | |
| element.classList.add('fade-in'); | |
| } | |
| }); | |
| }; | |
| window.addEventListener('scroll', animateOnScroll); | |
| animateOnScroll(); // Run once on load | |
| }); | |
| // Video generation functions | |
| function generateVideoFromPrompt(prompt) { | |
| // In a real implementation, this would call an AI video generation API | |
| console.log("Generating video for prompt:", prompt); | |
| return new Promise((resolve) => { | |
| setTimeout(() => { | |
| resolve({ | |
| videoUrl: "https://example.com/generated-video.mp4", | |
| thumbnail: "https://static.photos/futuristic/640x360/42", | |
| duration: 30 | |
| }); | |
| }, 2000); | |
| }); | |
| } | |
| // Color manipulation functions | |
| function hexToRgb(hex) { | |
| const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); | |
| return result ? { | |
| r: parseInt(result[1], 16), | |
| g: parseInt(result[2], 16), | |
| b: parseInt(result[3], 16) | |
| } : null; | |
| } | |
| function getContrastYIQ(hexcolor) { | |
| const rgb = hexToRgb(hexcolor); | |
| if (!rgb) return '#000000'; | |
| const yiq = ((rgb.r * 299) + (rgb.g * 587) + (rgb.b * 114)) / 1000; | |
| return (yiq >= 128) ? '#000000' : '#ffffff'; | |
| } |