diff --git a/data/menu.json b/data/menu.json index 8044c14..f079e49 100644 --- a/data/menu.json +++ b/data/menu.json @@ -6,15 +6,10 @@ "price": 20, "image": "img/Aloo Samosa.png", "category": "Snacks", -newFeatures - "price": 30, - "originalPrice": 50, - "spice": "Medium", - main "rating": 4.8, "spice": "Medium", "dietary": ["vegan"], - "available" : false + "available": true }, { "id": "kachori-002", @@ -35,12 +30,7 @@ newFeatures "price": 30, "image": "img/paani puri.png", "category": "Chaat", - newFeatures - "price": 50, - "originalPrice": 70, - "rating": 4.9, -main "spice": "High", "dietary": ["vegan"], "available": true @@ -158,16 +148,8 @@ main "name": "Jalebi", "description": "Golden coiled sweet treat soaked in sugar syrup", "price": 20, -newFeatures -newFeatures - "originalPrice": 35, - "spice": "Low", - - "image": "img/7.avif", "image": "img/jalebi.png", -main "category": "Snacks", - main "rating": 4.7, "spice": "Low", "dietary": ["vegan"], @@ -178,17 +160,10 @@ main "name": "Idli with Sambar", "description": "Fluffy steamed rice cakes served with spiced lentil vegetable stew", "price": 35, -newFeatures -newFeatures - "originalPrice": 50, - - "image": "img/8.avif", "image": "img/Idli with Sambar.png", - main "category": "Chaat", "rating": 4.8, - main - "spice": "Medium", + "spice": "Low", "dietary": ["vegan", "gluten-free"], "available": true }, @@ -223,12 +198,7 @@ newFeatures "price": 28, "image": "img/Sev Tameta.png", "category": "Chaat", -newFeatures - "price": 45, - "originalPrice": 70, - "rating": 4.7, - main "spice": "High", "dietary": ["vegan"], "available": true diff --git a/js/main.js b/js/main.js index 0db96c1..aafbc11 100644 --- a/js/main.js +++ b/js/main.js @@ -20,9 +20,6 @@ function setupCartManager() { cartManager.subscribe((items) => { cart = [...items]; }); - - // Validate cart integrity - cartManager.validate(); } async function loadMenuData() { @@ -326,26 +323,6 @@ function createCard(item, highlightQuery = "") { - ${formatPrice(item.price)} - -main `; const addBtn = card.querySelector(".add-btn"); @@ -415,8 +390,7 @@ function renderRecentlyViewed() { recentItems.forEach(item => recentlyViewedContainer.appendChild(createCard(item))); } - newFeatures -// Unified Interactive Filter Engine ===== +// ===== Unified Interactive Filter Engine ===== function renderFavorites() { const favoritesContainer = document.getElementById("favorites-container"); if (!favoritesContainer) return; @@ -426,9 +400,7 @@ function renderFavorites() { favoritesContainer.innerHTML = ""; if (recentItems.length === 0) { - recentlyViewedSection.style.display = - "none"; - + favoritesContainer.innerHTML = `

No favorites yet.

`; return; } @@ -952,17 +924,15 @@ window.reorderOrder = function (orderId) { sidebar.classList.add("open"); } }; - newFeatures -// Cart Operations +// Cart Operations -// Toast Notification +// Toast Notification // ===== Toast Notification ===== - -main + function showToast(message) { const toast = document.getElementById("toast-notification"); if (!toast) return; @@ -1008,16 +978,8 @@ function addToCart(id) { function removeFromCart(id) { const cartIndex = cart.findIndex(ci => ci.item.id === id); if (cartIndex === -1) return; - - const removedItem = cart[cartIndex].item; - cartManager.decreaseQuantity(id); - const cartItem = cart.find( - (ci) => ci.item.id === id - ); - - if (!cartItem) return; - const removedItem = cartItem.item; + const removedItem = cart[cartIndex].item; if ( typeof cartManager.decreaseQuantity === @@ -1028,7 +990,7 @@ function removeFromCart(id) { cartManager.removeItem(id); } return true; -}; +} window.placeOrderFromCheckout = function (customerDetails, pricingInfo) { if (cart.length === 0) { @@ -1122,7 +1084,6 @@ window.reorderOrder = function (orderId) { updateCartCount(); updateFavCount(); renderCart(); - showToast(`🗑️ ${removedItem.name} removed from cart`); } // ===== Event Listeners ===== @@ -1236,7 +1197,7 @@ function setupSearchSuggestions() { if (!searchInput.contains(e.target) && !suggestionsContainer.contains(e.target)) { suggestionsContainer.style.display = "none"; } - ); + }); } function setupSearch() { @@ -1536,67 +1497,6 @@ async function init() { window.location.href = `orders.html?delivery=${result.deliveryAvailable}`; } }); - ); - - recognition.onresult = ( - event - ) => { - const transcript = - event.results[0][0].transcript; - - searchInput.value = transcript; - - applyAllFilters(); - - voiceBtn.innerHTML = "🎤"; - - // Bind interactive UI listeners immediately for instant input responsiveness (high INP) - setupCartToggle(); - setupFilterButtons(); - setupCouponListeners(); - setupOrderNowScroll(); - setupSearchSuggestions(); - setupSearch(); - setupAdvancedFilters(); - setupContactForm(); - setupNewsletterForm(); - setupActiveNavbar(); - setupDropdownFilterLinks(); - - if (checkoutBtn) { - checkoutBtn.addEventListener("click", (e) => { - e.preventDefault(); - if (cart.length === 0) { - alert("Your cart is empty!"); - return; - } - window.location.href = "orders.html"; - }); - } - voiceBtn.classList.remove( - "listening" - ); - }; - - recognition.onerror = () => { - voiceBtn.innerHTML = "🎤"; - - voiceBtn.classList.remove( - "listening" - ); - - alert( - "Voice recognition failed." - ); - }; - - recognition.onend = () => { - voiceBtn.innerHTML = "🎤"; - - voiceBtn.classList.remove( - "listening" - ); - }; } // Load menu data, then render @@ -1686,4 +1586,4 @@ if (toggleBtn) { localStorage.setItem("theme", document.body.classList.contains("dark") ? "dark" : "light"); }); } - +