Spaces:
Sleeping
Sleeping
Delete script.js
Browse files
script.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
document.querySelectorAll('.add-button, .food-image').forEach(item => {
|
| 2 |
-
item.addEventListener('click', function () {
|
| 3 |
-
const foodItem = this.dataset.item;
|
| 4 |
-
showModal(foodItem);
|
| 5 |
-
});
|
| 6 |
-
});
|
| 7 |
-
|
| 8 |
-
function showModal(foodItem) {
|
| 9 |
-
const modal = document.getElementById('suggestion-modal');
|
| 10 |
-
document.getElementById('selected-item').innerText = foodItem;
|
| 11 |
-
const suggestions = getSuggestions(foodItem);
|
| 12 |
-
const suggestionList = document.getElementById('suggestion-list');
|
| 13 |
-
suggestionList.innerHTML = suggestions.map(item => `<li>${item}</li>`).join('');
|
| 14 |
-
modal.style.display = 'flex';
|
| 15 |
-
|
| 16 |
-
document.querySelector('.close-button').addEventListener('click', () => {
|
| 17 |
-
modal.style.display = 'none';
|
| 18 |
-
});
|
| 19 |
-
|
| 20 |
-
document.getElementById('add-to-cart-button').addEventListener('click', () => {
|
| 21 |
-
addToCart(foodItem, suggestions);
|
| 22 |
-
modal.style.display = 'none';
|
| 23 |
-
});
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
function getSuggestions(foodItem) {
|
| 27 |
-
const suggestionData = {
|
| 28 |
-
'Veg Samosa': ['Green Chutney', 'Masala Tea'],
|
| 29 |
-
'Onion Pakoda': ['Tamarind Sauce', 'Hot Tea'],
|
| 30 |
-
// Add more combinations here
|
| 31 |
-
};
|
| 32 |
-
return suggestionData[foodItem] || [];
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
let cart = [];
|
| 36 |
-
|
| 37 |
-
function addToCart(foodItem, suggestions) {
|
| 38 |
-
const quantity = document.getElementById('quantity').value;
|
| 39 |
-
cart.push({ foodItem, quantity, suggestions });
|
| 40 |
-
alert(`Added to cart: ${foodItem} (x${quantity})`);
|
| 41 |
-
console.log('Cart:', cart);
|
| 42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|