Spaces:
Running
Running
| // Dark mode toggle functionality | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Check for saved dark mode preference or use system preference | |
| const isDarkMode = localStorage.getItem('darkMode') === 'true' || | |
| (!localStorage.getItem('darkMode') && window.matchMedia('(prefers-color-scheme: dark)').matches); | |
| // Apply initial dark mode state | |
| if (isDarkMode) { | |
| document.documentElement.classList.add('dark'); | |
| document.getElementById('darkModeToggle').innerHTML = '<i data-feather="sun"></i>'; | |
| } else { | |
| document.documentElement.classList.remove('dark'); | |
| document.getElementById('darkModeToggle').innerHTML = '<i data-feather="moon"></i>'; | |
| } | |
| // Initialize feather icons | |
| feather.replace(); | |
| // Set up dark mode toggle | |
| const darkModeToggle = document.getElementById('darkModeToggle'); | |
| if (darkModeToggle) { | |
| darkModeToggle.addEventListener('click', function() { | |
| const isDark = document.documentElement.classList.toggle('dark'); | |
| localStorage.setItem('darkMode', isDark); | |
| if (isDark) { | |
| this.innerHTML = '<i data-feather="sun"></i>'; | |
| } else { | |
| this.innerHTML = '<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' | |
| }); | |
| } | |
| }); | |
| }); | |
| // Form submission handling | |
| const contactForm = document.getElementById('contactForm'); | |
| if (contactForm) { | |
| contactForm.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| // Here you would typically send the form data to your server | |
| alert('Thank you for your message! We will contact you shortly.'); | |
| this.reset(); | |
| }); | |
| } | |
| }); |