Spaces:
Running
Running
Download script.js from docker1/cpanel-site-hosting: direct link, hf CLI and curl.
- Browser
- Download file 1.98 kB
-
https://huggingface.co/spaces/docker1/cpanel-site-hosting/resolve/main/script.js
- Command line
-
hf download hf://spaces/docker1/cpanel-site-hosting/script.js
-
curl -L -o script.js https://huggingface.co/spaces/docker1/cpanel-site-hosting/resolve/main/script.js
1.98 kB
| // Simple vanilla JavaScript for cPanel hosting | |
| // No frameworks required - works everywhere! | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Mobile menu toggle (if needed) | |
| const mobileMenuBtn = document.getElementById('mobile-menu-btn'); | |
| const mobileMenu = document.getElementById('mobile-menu'); | |
| if (mobileMenuBtn && mobileMenu) { | |
| mobileMenuBtn.addEventListener('click', function() { | |
| mobileMenu.classList.toggle('active'); | |
| }); | |
| } | |
| // Smooth scroll 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' | |
| }); | |
| } | |
| }); | |
| }); | |
| // Form validation enhancement | |
| const forms = document.querySelectorAll('form'); | |
| forms.forEach(form => { | |
| form.addEventListener('submit', function(e) { | |
| const requiredFields = form.querySelectorAll('[required]'); | |
| let valid = true; | |
| requiredFields.forEach(field => { | |
| if (!field.value.trim()) { | |
| valid = false; | |
| field.classList.add('border-red-500'); | |
| } else { | |
| field.classList.remove('border-red-500'); | |
| } | |
| }); | |
| if (!valid) { | |
| e.preventDefault(); | |
| alert('Please fill in all required fields'); | |
| } | |
| }); | |
| }); | |
| // Add current year to footer | |
| const yearSpans = document.querySelectorAll('.current-year'); | |
| yearSpans.forEach(span => { | |
| span.textContent = new Date().getFullYear(); | |
| }); | |
| console.log('Website loaded successfully!'); | |
| }); |