Download script.js from learncode/grandmaster-s-gambit-academy: direct link, hf CLI and curl.
- Browser
- Download file 2.36 kB
-
https://huggingface.co/spaces/learncode/grandmaster-s-gambit-academy/resolve/main/script.js
- Command line
-
hf download hf://spaces/learncode/grandmaster-s-gambit-academy/script.js
-
curl -L -o script.js https://huggingface.co/spaces/learncode/grandmaster-s-gambit-academy/resolve/main/script.js
2.36 kB
| // Mobile menu toggle | |
| document.addEventListener('DOMContentLoaded', function() { | |
| const mobileMenuButton = document.querySelector('[data-collapse-toggle="mobile-menu"]'); | |
| const mobileMenu = document.getElementById('mobile-menu'); | |
| if (mobileMenuButton && mobileMenu) { | |
| mobileMenuButton.addEventListener('click', function() { | |
| mobileMenu.classList.toggle('hidden'); | |
| const icon = mobileMenuButton.querySelector('svg'); | |
| if (mobileMenu.classList.contains('hidden')) { | |
| icon.setAttribute('data-feather', 'menu'); | |
| } else { | |
| icon.setAttribute('data-feather', 'x'); | |
| } | |
| feather.replace(); | |
| }); | |
| } | |
| // 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' | |
| }); | |
| }); | |
| }); | |
| // Testimonial carousel (if needed) | |
| let currentTestimonial = 0; | |
| const testimonials = document.querySelectorAll('.testimonial'); | |
| function showTestimonial(index) { | |
| testimonials.forEach((testimonial, i) => { | |
| testimonial.classList.toggle('hidden', i !== index); | |
| }); | |
| } | |
| // Initialize first testimonial | |
| if (testimonials.length > 0) { | |
| showTestimonial(0); | |
| } | |
| // Form submission handling | |
| const forms = document.querySelectorAll('form'); | |
| forms.forEach(form => { | |
| form.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| // Add your form submission logic here | |
| console.log('Form submitted:', this); | |
| // Example: You could add a fetch request to your backend | |
| }); | |
| }); | |
| }); | |
| // Intersection Observer for animations | |
| const observerOptions = { | |
| threshold: 0.1 | |
| }; | |
| const observer = new IntersectionObserver(function(entries, observer) { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| entry.target.classList.add('animate-fadeIn'); | |
| observer.unobserve(entry.target); | |
| } | |
| }); | |
| }, observerOptions); | |
| document.querySelectorAll('.animate-on-scroll').forEach(element => { | |
| observer.observe(element); | |
| }); |