Download script.js from Textricity/neuralnet-pulse-visualizer: direct link, hf CLI and curl.
- Browser
- Download file 3.15 kB
-
https://huggingface.co/spaces/Textricity/neuralnet-pulse-visualizer/resolve/main/script.js
- Command line
-
hf download hf://spaces/Textricity/neuralnet-pulse-visualizer/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Textricity/neuralnet-pulse-visualizer/resolve/main/script.js
3.15 kB
| document.addEventListener('DOMContentLoaded', function() { | |
| // Dark mode toggle | |
| const darkModeToggle = document.createElement('button'); | |
| darkModeToggle.className = 'p-2 rounded-full focus:outline-none'; | |
| darkModeToggle.innerHTML = '<i data-feather="moon"></i>'; | |
| darkModeToggle.setAttribute('aria-label', 'Toggle dark mode'); | |
| // Check for saved user preference or system 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'); | |
| darkModeToggle.innerHTML = '<i data-feather="sun"></i>'; | |
| } | |
| // Insert toggle into navbar | |
| const nav = document.querySelector('custom-navbar'); | |
| if (nav) { | |
| nav.shadowRoot.querySelector('.nav-container').appendChild(darkModeToggle); | |
| } | |
| // Toggle functionality | |
| darkModeToggle.addEventListener('click', function() { | |
| const isDark = document.documentElement.classList.toggle('dark'); | |
| localStorage.setItem('theme', isDark ? 'dark' : 'light'); | |
| darkModeToggle.innerHTML = isDark ? '<i data-feather="sun"></i>' : '<i data-feather="moon"></i>'; | |
| feather.replace(); | |
| }); | |
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function(e) { | |
| e.preventDefault(); | |
| const targetId = this.getAttribute('href'); | |
| if (targetId === '#') return; | |
| const targetElement = document.querySelector(targetId); | |
| if (targetElement) { | |
| targetElement.scrollIntoView({ | |
| behavior: 'smooth', | |
| block: 'start' | |
| }); | |
| } | |
| }); | |
| }); | |
| // Initialize tooltips | |
| document.querySelectorAll('.tooltip').forEach(el => { | |
| el.addEventListener('mouseenter', function() { | |
| const tooltip = this.querySelector('.tooltip-text'); | |
| if (tooltip) { | |
| tooltip.style.visibility = 'visible'; | |
| tooltip.style.opacity = '1'; | |
| } | |
| }); | |
| el.addEventListener('mouseleave', function() { | |
| const tooltip = this.querySelector('.tooltip-text'); | |
| if (tooltip) { | |
| tooltip.style.visibility = 'hidden'; | |
| tooltip.style.opacity = '0'; | |
| } | |
| }); | |
| }); | |
| // Animate cards when they come into view | |
| const observerOptions = { | |
| threshold: 0.1, | |
| rootMargin: '0px 0px -50px 0px' | |
| }; | |
| const observer = new IntersectionObserver((entries) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| entry.target.classList.add('card-animate'); | |
| observer.unobserve(entry.target); | |
| } | |
| }); | |
| }, observerOptions); | |
| document.querySelectorAll('.bg-white, .bg-gray-800').forEach(card => { | |
| observer.observe(card); | |
| }); | |
| }); |