Download script.js from arefamer/codegenius-wizardry-wand: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/spaces/arefamer/codegenius-wizardry-wand/resolve/main/script.js
- Command line
-
hf download hf://spaces/arefamer/codegenius-wizardry-wand/script.js
-
curl -L -o script.js https://huggingface.co/spaces/arefamer/codegenius-wizardry-wand/resolve/main/script.js
1.58 kB
| // 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' | |
| }); | |
| }); | |
| }); | |
| // Theme toggle functionality | |
| const themeToggle = document.getElementById('theme-toggle'); | |
| if (themeToggle) { | |
| themeToggle.addEventListener('click', () => { | |
| document.body.classList.toggle('dark-theme'); | |
| localStorage.setItem('theme', document.body.classList.contains('dark-theme') ? 'dark' : 'light'); | |
| }); | |
| } | |
| // Initialize theme from localStorage | |
| if (localStorage.getItem('theme') === 'dark') { | |
| document.body.classList.add('dark-theme'); | |
| } | |
| // Dynamic year for footer | |
| document.querySelectorAll('.current-year').forEach(el => { | |
| el.textContent = new Date().getFullYear(); | |
| }); | |
| // Animation on scroll | |
| const animateOnScroll = () => { | |
| const elements = document.querySelectorAll('.animate'); | |
| elements.forEach(el => { | |
| const elementPosition = el.getBoundingClientRect().top; | |
| const screenPosition = window.innerHeight / 1.3; | |
| if (elementPosition < screenPosition) { | |
| el.classList.add('animated'); | |
| } | |
| }); | |
| }; | |
| window.addEventListener('scroll', animateOnScroll); | |
| window.addEventListener('load', animateOnScroll); | |
| // Weather widget API key (replace with your own) | |
| const WEATHER_API_KEY = 'YOUR_OPENWEATHERMAP_API_KEY'; | |
| // Initialize weather widgets | |
| document.querySelectorAll('weather-widget').forEach(widget => { | |
| widget.setAttribute('api-key', WEATHER_API_KEY); | |
| }); | |