Erbytv/streamshare-effortless-media-queue-magic
0
1// Shared JavaScript across all pages2console.log('StreamShare App loaded');3 4// Initialize animations and interactions5document.addEventListener('DOMContentLoaded', function() {6 // Add fade-in animation to sections7 const sections = document.querySelectorAll('section');8 9 const observerOptions = {10 threshold: 0.1,11 rootMargin: '0px 0px -50px 0px'12 };13 14 const observer = new IntersectionObserver((entries) => {15 entries.forEach(entry => {16 if (entry.isIntersecting) {17 entry.target.classList.add('fade-in');18 }19 });20 }, observerOptions);21 22 sections.forEach(section => {23 observer.observe(section);24 });25 26 // Smooth scroll for anchor links27 document.querySelectorAll('a[href^="#"]').forEach(anchor => {28 anchor.addEventListener('click', function (e) {29 e.preventDefault();30 const target = document.querySelector(this.getAttribute('href'));31 if (target) {32 target.scrollIntoView({33 behavior: 'smooth',34 block: 'start'35 });36 }37 });38 });39 40 // Add loading states to buttons41 document.querySelectorAll('a[href="#"]').forEach(button => {42 button.addEventListener('click', function(e) {43 e.preventDefault();44 const originalText = this.textContent;45 this.textContent = 'Loading...';46 this.disabled = true;47 48 // Simulate loading (replace with actual functionality)49 setTimeout(() => {50 this.textContent = originalText;51 this.disabled = false;52 }, 2000);53 });54 });55 56 // Handle theme switching (though we're dark mode only)57 if (localStorage.getItem('theme') === 'light') {58 document.documentElement.classList.remove('dark');59 } else {60 document.documentElement.classList.add('dark');61 localStorage.setItem('theme', 'dark');62 }63});64 65// Utility functions66function formatCurrency(amount) {67 return new Intl.NumberFormat('en-US', {68 style: 'currency',69 currency: 'USD'70 }).format(amount);71}72 73function calculateCost(seconds, pricePerSecond) {74 return seconds * pricePerSecond;75}76 77// Export for use in other modules if needed78window.StreamShare = {79 formatCurrency,80 calculateCost81};