Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ // Mobile menu toggle
+ const mobileMenu = document.querySelector('.mobile-menu');
+ const navLinks = document.querySelector('.nav-links');
+
+ mobileMenu.addEventListener('click', () => {
+ navLinks.classList.toggle('active');
+ const spans = mobileMenu.querySelectorAll('span');
+ spans[0].style.transform = navLinks.classList.contains('active') ? 'rotate(45deg) translate(8px, 8px)' : 'none';
+ spans[1].style.opacity = navLinks.classList.contains('active') ? '0' : '1';
+ spans[2].style.transform = navLinks.classList.contains('active') ? 'rotate(-45deg) translate(7px, -7px)' : 'none';
+ });
+
+ // Smooth scroll for anchor links
+ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
+ anchor.addEventListener('click', function (e) {
+ e.preventDefault();
+ document.querySelector(this.getAttribute('href')).scrollIntoView({
+ behavior: 'smooth'
+ });
+ });
+ });
+
+ // Form submission
+ const submitForm = document.getElementById('submitForm');
+ if (submitForm) {
+ submitForm.addEventListener('submit', (e) => {
+ e.preventDefault();
+ const formData = {
+ title: document.getElementById('title').value,
+ description: document.getElementById('description').value,
+ code: document.getElementById('code').value
+ };
+
+ // Here you would typically send the data to a server
+ console.log('Form submitted:', formData);
+ alert('Thank you for your submission!');
+ submitForm.reset();
+ });
+ }
+
+ // Active nav link highlighting
+ const sections = document.querySelectorAll('section');
+ const navItems = document.querySelectorAll('.nav-links a');
+
+ window.addEventListener('scroll', () => {
+ let current = '';
+ sections.forEach(section => {
+ const sectionTop = section.offsetTop;
+ if (pageYOffset >= sectionTop - 60) {
+ current = section.getAttribute('id');
+ }
+ });
+
+ navItems.forEach(item => {
+ item.classList.remove('active');
+ if (item.getAttribute('href').includes(current)) {
+ item.classList.add('active');
+ }
+ });
+ });
+ });