// 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' }); }); }); // Active navigation highlighting window.addEventListener('scroll', () => { const sections = document.querySelectorAll('section'); const navLinks = document.querySelectorAll('nav a'); let current = ''; sections.forEach(section => { const sectionTop = section.offsetTop; const sectionHeight = section.clientHeight; if (pageYOffset >= (sectionTop - 100)) { current = section.getAttribute('id'); } }); navLinks.forEach(link => { link.classList.remove('active'); if (link.getAttribute('href') === `#${current}`) { link.classList.add('active'); } }); }); // Dynamic project content loader document.addEventListener('DOMContentLoaded', () => { const urlParams = new URLSearchParams(window.location.search); const projectId = urlParams.get('project'); if (projectId && document.querySelector('#project-content')) { // In a real app, you would fetch project data from an API // This is just a placeholder for the demo const projects = { '1': { title: 'Quantum Simulation', description: 'Advanced quantum computing simulations using Qiskit framework', category: 'Quantum Computing', date: 'May 2023', technologies: ['Python', 'Qiskit', 'Quantum'] }, '2': { title: 'Neural Networks', description: 'Deep learning models for medical image analysis', category: 'Artificial Intelligence', date: 'March 2023', technologies: ['Python', 'TensorFlow', 'AI'] }, '3': { title: 'Research Portal', description: 'Platform for academic collaboration and paper sharing', category: 'Web Development', date: 'January 2023', technologies: ['React', 'Node.js', 'MongoDB'] } }; const project = projects[projectId]; if (project) { document.title = `${project.title} | Quantum Coder Nexus`; document.querySelector('#project-title').textContent = project.title; document.querySelector('#project-description').textContent = project.description; // Update other elements similarly... } } }); // Form submission handler const contactForm = document.querySelector('form'); if (contactForm) { contactForm.addEventListener('submit', (e) => { e.preventDefault(); alert('Thank you for your message! I will get back to you soon.'); contactForm.reset(); }); }