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
71 changes: 5 additions & 66 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 @@ -325,27 +322,7 @@ function createCard(item, highlightQuery = "") {
${outOfStockBadge}
</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 @@ -356,7 +333,6 @@ newFeatures
</button>

</div>
main
`;

const addBtn = card.querySelector(".add-btn");
Expand Down Expand Up @@ -414,8 +390,6 @@ function renderRecentlyViewed() {
recentlyViewedSection.style.display = "block";
recentItems.forEach(item => recentlyViewedContainer.appendChild(createCard(item)));
}

newFeatures
// Unified Interactive Filter Engine =====
function renderFavorites() {
const favoritesContainer = document.getElementById("favorites-container");
Expand Down Expand Up @@ -952,7 +926,6 @@ window.reorderOrder = function (orderId) {
sidebar.classList.add("open");
}
};
newFeatures

// Cart Operations

Expand All @@ -961,8 +934,6 @@ window.reorderOrder = function (orderId) {


// ===== Toast Notification =====

main
function showToast(message) {
const toast = document.getElementById("toast-notification");
if (!toast) return;
Expand Down Expand Up @@ -1008,27 +979,17 @@ 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 ===
"function"
) {
if (typeof cartManager.decreaseQuantity === "function") {
cartManager.decreaseQuantity(id);
} else {
cartManager.removeItem(id);
}

return true;
};
}

window.placeOrderFromCheckout = function (customerDetails, pricingInfo) {
if (cart.length === 0) {
Expand Down Expand Up @@ -1236,27 +1197,6 @@ function setupSearchSuggestions() {
if (!searchInput.contains(e.target) && !suggestionsContainer.contains(e.target)) {
suggestionsContainer.style.display = "none";
}
);
}

function setupSearch() {
const searchInput = document.getElementById("search-input");
const searchBtn = document.getElementById("search-btn");
if (!searchInput || !searchBtn) return;

function handleSearchClick() {
const menuSection = document.getElementById("menu") || document.querySelector(".menu-page");
if (menuSection) menuSection.scrollIntoView({ behavior: "smooth" });
applyAllFilters();
}

searchBtn.addEventListener("click", handleSearchClick);
searchInput.addEventListener("keydown", (e) => {
if (e.key === "Enter") {
handleSearchClick();
const suggestionsContainer = document.getElementById("search-suggestions");
if (suggestionsContainer) suggestionsContainer.style.display = "none";
}
});
}

Expand Down Expand Up @@ -1536,7 +1476,6 @@ async function init() {
window.location.href = `orders.html?delivery=${result.deliveryAvailable}`;
}
});
);

recognition.onresult = (
event
Expand Down
25 changes: 21 additions & 4 deletions js/recommendations.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/// ===== SMART RECOMMENDATION ENGINE =====

// Load cart from localStorage
let cart = JSON.parse(localStorage.getItem("chaatCart")) || [];

// ===== FOOD PAIRINGS =====

const foodPairings = {

"Samosa": [
Expand Down Expand Up @@ -365,3 +361,24 @@ document.addEventListener("DOMContentLoaded", () => {

renderComboPage();
});
function setupSearch() {
const searchInput = document.getElementById("search-input");
const searchBtn = document.getElementById("search-btn");
if (!searchInput || !searchBtn) return;

function handleSearchClick() {
const menuSection = document.getElementById("menu") || document.querySelector(".menu-page");
if (menuSection) menuSection.scrollIntoView({ behavior: "smooth" });
applyAllFilters();
}

searchBtn.addEventListener("click", handleSearchClick);
searchInput.addEventListener("keydown", (e) => {
if (e.key === "Enter") {
handleSearchClick();
const suggestionsContainer = document.getElementById("search-suggestions");
if (suggestionsContainer) suggestionsContainer.style.display = "none";
}
});
}

1 change: 1 addition & 0 deletions menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,6 @@ <h3>Contact Us</h3>
<script src="js/loyalty.js"></script>
<script src="js/main.js"></script>
<script src="js/auth.js"></script>
<script src="js/recommendations.js"></script>
</body>
</html>