Spaces:
Running
Running
Download script.js from mtrausch0/animate-studio-pro: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/spaces/mtrausch0/animate-studio-pro/resolve/main/script.js
- Command line
-
hf download hf://spaces/mtrausch0/animate-studio-pro/script.js
-
curl -L -o script.js https://huggingface.co/spaces/mtrausch0/animate-studio-pro/resolve/main/script.js
1.84 kB
| // Shared JavaScript across all pages | |
| console.log('Animate Studio Pro loaded'); | |
| // Register service worker for PWA functionality | |
| if ('serviceWorker' in navigator) { | |
| window.addEventListener('load', function() { | |
| navigator.serviceWorker.register('/sw.js') | |
| .then(function(registration) { | |
| console.log('SW registered: ', registration); | |
| }) | |
| .catch(function(registrationError) { | |
| console.log('SW registration failed: ', registrationError); | |
| }); | |
| }); | |
| } | |
| // Theme toggle functionality | |
| function initThemeToggle() { | |
| const toggleButton = document.getElementById('theme-toggle'); | |
| if (!toggleButton) return; | |
| // Check for saved theme preference or respect OS preference | |
| const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)'); | |
| const currentTheme = localStorage.getItem('theme'); | |
| if (currentTheme === 'dark' || (!currentTheme && prefersDarkScheme.matches)) { | |
| document.documentElement.classList.add('dark'); | |
| } else { | |
| document.documentElement.classList.remove('dark'); | |
| } | |
| toggleButton.addEventListener('click', function() { | |
| document.documentElement.classList.toggle('dark'); | |
| // Save the current preference to localStorage | |
| const isDark = document.documentElement.classList.contains('dark'); | |
| localStorage.setItem('theme', isDark ? 'dark' : 'light'); | |
| }); | |
| } | |
| // Initialize when DOM is loaded | |
| document.addEventListener('DOMContentLoaded', function() { | |
| initThemeToggle(); | |
| }); | |
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function(e) { | |
| e.preventDefault(); | |
| const target = document.querySelector(this.getAttribute('href')); | |
| if (target) { | |
| target.scrollIntoView({ | |
| behavior: 'smooth', | |
| block: 'start' | |
| }); | |
| } | |
| }); | |
| }); |