Spaces:
Running
Running
Download script.js from Etalonphone/0ohn6zd: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/spaces/Etalonphone/0ohn6zd/resolve/main/script.js
- Command line
-
hf download hf://spaces/Etalonphone/0ohn6zd/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Etalonphone/0ohn6zd/resolve/main/script.js
1.8 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' | |
| }); | |
| }); | |
| }); | |
| // Mobile menu toggle | |
| function toggleMobileMenu() { | |
| const menu = document.getElementById('mobile-menu'); | |
| menu.classList.toggle('hidden'); | |
| } | |
| // Form validation | |
| function validateForm(form) { | |
| let isValid = true; | |
| const inputs = form.querySelectorAll('input[required], textarea[required]'); | |
| inputs.forEach(input => { | |
| if (!input.value.trim()) { | |
| input.classList.add('border-red-500'); | |
| isValid = false; | |
| } else { | |
| input.classList.remove('border-red-500'); | |
| } | |
| }); | |
| return isValid; | |
| } | |
| // Initialize tooltips | |
| function initTooltips() { | |
| const tooltipElements = document.querySelectorAll('[data-tooltip]'); | |
| tooltipElements.forEach(el => { | |
| const tooltip = document.createElement('div'); | |
| tooltip.textContent = el.getAttribute('data-tooltip'); | |
| tooltip.className = 'invisible absolute z-10 w-max p-2 text-sm text-white bg-gray-800 rounded opacity-0 transition'; | |
| el.appendChild(tooltip); | |
| el.addEventListener('mouseenter', () => { | |
| tooltip.classList.remove('invisible', 'opacity-0'); | |
| tooltip.classList.add('visible', 'opacity-100'); | |
| }); | |
| el.addEventListener('mouseleave', () => { | |
| tooltip.classList.remove('visible', 'opacity-100'); | |
| tooltip.classList.add('invisible', 'opacity-0'); | |
| }); | |
| }); | |
| } | |
| document.addEventListener('DOMContentLoaded', () => { | |
| initTooltips(); | |
| }); |