Changed around line 1
+ // Mobile menu toggle
+ const mobileMenu = document.querySelector('.mobile-menu');
+ const navLinks = document.querySelector('.nav-links');
+
+ mobileMenu.addEventListener('click', () => {
+ navLinks.classList.toggle('active');
+ });
+
+ // Product comparison functionality
+ function addProduct(productNumber) {
+ const input = document.getElementById(`product${productNumber}`);
+ const productDetails = document.getElementById(`product${productNumber}-details`);
+
+ if (!input.value) {
+ alert('Please enter a product URL or ID');
+ return;
+ }
+
+ // Simulate product fetching
+ productDetails.innerHTML = `
+
+
Loading product details...
+
+ `;
+
+ // Simulate API call
+ setTimeout(() => {
+ displayProductDetails(productNumber, input.value);
+ }, 1000);
+ }
+
+ function displayProductDetails(productNumber, productId) {
+ // This is a mock function - in reality, you'd fetch real product data
+ const mockProduct = {
+ title: `Sample Product ${productNumber}`,
+ price: `$${Math.floor(Math.random() * 1000)}.99`,
+ rating: (Math.random() * 2 + 3).toFixed(1),
+ reviews: Math.floor(Math.random() * 1000),
+ features: [
+ 'Feature 1',
+ 'Feature 2',
+ 'Feature 3'
+ ]
+ };
+
+ const productDetails = document.getElementById(`product${productNumber}-details`);
+ productDetails.innerHTML = `
+
${mockProduct.title}
+
+ ⭐ ${mockProduct.rating} (${mockProduct.reviews} reviews)
+
+ ${mockProduct.features.map(feature => `
${feature}`).join('')}+
+ `;
+
+ saveToRecent(mockProduct);
+ }
+
+ function saveToRecent(product) {
+ let recent = JSON.parse(localStorage.getItem('recentComparisons') || '[]');
+ recent.unshift(product);
+ recent = recent.slice(0, 6); // Keep only 6 most recent
+ localStorage.setItem('recentComparisons', JSON.stringify(recent));
+ updateRecentComparisons();
+ }
+
+ function updateRecentComparisons() {
+ const recentContainer = document.getElementById('recent-comparisons');
+ const recent = JSON.parse(localStorage.getItem('recentComparisons') || '[]');
+
+ recentContainer.innerHTML = recent.map(product => `
+ `).join('');
+ }
+
+ // Initialize recent comparisons on page load
+ updateRecentComparisons();