Spaces:
Running
Running
Download script.js from hlenkao/smartfinance-wizardry: direct link, hf CLI and curl.
- Browser
- Download file 1.66 kB
-
https://huggingface.co/spaces/hlenkao/smartfinance-wizardry/resolve/main/script.js
- Command line
-
hf download hf://spaces/hlenkao/smartfinance-wizardry/script.js
-
curl -L -o script.js https://huggingface.co/spaces/hlenkao/smartfinance-wizardry/resolve/main/script.js
1.66 kB
| // Main JavaScript file for shared functionality | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // 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' | |
| }); | |
| }); | |
| }); | |
| // Sticky navbar with shadow on scroll | |
| const navbar = document.querySelector('custom-navbar').shadowRoot.querySelector('.navbar'); | |
| window.addEventListener('scroll', () => { | |
| if (window.scrollY > 10) { | |
| navbar.classList.add('scrolled'); | |
| } else { | |
| navbar.classList.remove('scrolled'); | |
| } | |
| }); | |
| // Mobile menu toggle (would need to be implemented in navbar component) | |
| const mobileMenuButton = document.querySelector('custom-navbar').shadowRoot.querySelector('button.md\\:hidden'); | |
| const mobileMenu = document.createElement('div'); | |
| mobileMenu.className = 'mobile-menu'; | |
| ['inicio', 'servicos', 'beneficios', 'sobre', 'contato'].forEach(id => { | |
| const link = document.createElement('a'); | |
| link.href = `#${id}`; | |
| link.className = 'nav-link text-white hover:text-[#22FFC4] py-2 px-4'; | |
| link.textContent = document.querySelector(`a[href="#${id}"]`).textContent; | |
| mobileMenu.appendChild(link); | |
| }); | |
| document.querySelector('custom-navbar').shadowRoot.appendChild(mobileMenu); | |
| mobileMenuButton.addEventListener('click', () => { | |
| mobileMenu.classList.toggle('active'); | |
| }); | |
| }); | |