Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 2 additions & 32 deletions data/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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"],
Expand All @@ -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
},
Expand Down Expand Up @@ -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
Expand Down
118 changes: 9 additions & 109 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ function setupCartManager() {
cartManager.subscribe((items) => {
cart = [...items];
});

// Validate cart integrity
cartManager.validate();
}

async function loadMenuData() {
Expand Down Expand Up @@ -326,26 +323,6 @@ function createCard(item, highlightQuery = "") {
</div>

<div class="card-footer">
newFeatures
<div class="price-section">
<span class="original-price">
₹${item.originalPrice}
</span>

<span class="price">
${formatPrice(item.price)}
</span>

<span class="discount-badge">
${Math.round(((item.originalPrice - item.price) / item.originalPrice) * 100)}% OFF
</span>
</div>

<button class="add-btn" aria-label="Add ${item.name} to cart">
Add
</button>
</div>

<span class="price">${formatPrice(item.price)}</span>
<button class="add-btn"
aria-label="Add ${item.name} to cart"
Expand All @@ -354,9 +331,7 @@ newFeatures
>
Add
</button>

</div>
main
`;

const addBtn = card.querySelector(".add-btn");
Expand Down Expand Up @@ -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;
Expand All @@ -426,9 +400,7 @@ function renderFavorites() {
favoritesContainer.innerHTML = "";

if (recentItems.length === 0) {
recentlyViewedSection.style.display =
"none";

favoritesContainer.innerHTML = `<p style="text-align:center;color:#5d4037;margin-top:2rem;">No favorites yet.</p>`;
return;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 ===
Expand All @@ -1028,7 +990,7 @@ function removeFromCart(id) {
cartManager.removeItem(id);
}
return true;
};
}

window.placeOrderFromCheckout = function (customerDetails, pricingInfo) {
if (cart.length === 0) {
Expand Down Expand Up @@ -1122,7 +1084,6 @@ window.reorderOrder = function (orderId) {
updateCartCount();
updateFavCount();
renderCart();
showToast(`🗑️ ${removedItem.name} removed from cart`);
}

// ===== Event Listeners =====
Expand Down Expand Up @@ -1236,7 +1197,7 @@ function setupSearchSuggestions() {
if (!searchInput.contains(e.target) && !suggestionsContainer.contains(e.target)) {
suggestionsContainer.style.display = "none";
}
);
});
}

function setupSearch() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1686,4 +1586,4 @@ if (toggleBtn) {
localStorage.setItem("theme", document.body.classList.contains("dark") ? "dark" : "light");
});
}