Spaces:
Running
Running
Update templates/menu_page.html
Browse files- templates/menu_page.html +45 -35
templates/menu_page.html
CHANGED
@@ -14,17 +14,24 @@
|
|
14 |
.text { margin-left: 10px; }
|
15 |
.menu-option { margin: 20px; font-size: 1.5rem; text-align: center; }
|
16 |
.menu-option button { font-size: 1.2rem; padding: 10px 20px; margin: 10px; cursor: pointer; }
|
|
|
|
|
17 |
</style>
|
18 |
</head>
|
19 |
<body>
|
20 |
<div class="menu-container">
|
21 |
<h1>Welcome to the Menu</h1>
|
22 |
<div id="menu-items"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
</div>
|
24 |
|
25 |
<script>
|
26 |
const menuItems = [
|
27 |
-
// Vegetarian Items
|
28 |
{ name: 'Samosa', price: 9, ingredients: 'Potatoes, Peas, Flour, Spices', description: 'Crispy fried pastry filled with spiced potatoes and peas.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
|
29 |
{ name: 'Onion Pakoda', price: 10, ingredients: 'Onions, Gram Flour, Spices', description: 'Deep-fried onion fritters seasoned with herbs and spices.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
|
30 |
{ name: 'Chilli Gobi', price: 12, ingredients: 'Cauliflower, Chili Sauce, Spices', description: 'Cauliflower florets tossed in a spicy chili sauce.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
|
@@ -59,57 +66,60 @@
|
|
59 |
];
|
60 |
|
61 |
const menuContainer = document.getElementById('menu-items');
|
|
|
62 |
|
63 |
-
// Function to automatically display
|
64 |
-
function showMenu(
|
65 |
menuContainer.innerHTML = ''; // Clear previous menu items
|
66 |
-
const filteredItems = menuItems.filter(item => item.category === type);
|
67 |
|
68 |
-
|
69 |
const div = document.createElement('div');
|
70 |
div.classList.add('menu-item');
|
71 |
-
div.innerHTML = `<div class="details"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
menuContainer.appendChild(div);
|
73 |
});
|
74 |
}
|
75 |
|
76 |
-
// Function to
|
77 |
-
function
|
78 |
-
const
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
if (command.includes('veg')) {
|
85 |
-
showMenu('veg');
|
86 |
-
speak('Here are the Veg items.');
|
87 |
-
} else if (command.includes('non-veg')) {
|
88 |
-
showMenu('non-veg');
|
89 |
-
speak('Here are the Non-Veg items.');
|
90 |
-
} else {
|
91 |
-
speak('Please say Veg or Non-Veg to choose the menu.');
|
92 |
-
recognition.start();
|
93 |
-
}
|
94 |
-
};
|
95 |
-
|
96 |
-
recognition.onerror = () => { speak('Sorry, I could not understand. Please try again.'); };
|
97 |
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
});
|
|
|
101 |
}
|
102 |
|
103 |
-
//
|
104 |
-
function speak(text
|
105 |
const msg = new SpeechSynthesisUtterance(text);
|
106 |
-
msg.onend = callback;
|
107 |
window.speechSynthesis.speak(msg);
|
108 |
}
|
109 |
|
110 |
-
window.onload =
|
111 |
</script>
|
112 |
</body>
|
113 |
</html>
|
114 |
-
|
115 |
-
|
|
|
14 |
.text { margin-left: 10px; }
|
15 |
.menu-option { margin: 20px; font-size: 1.5rem; text-align: center; }
|
16 |
.menu-option button { font-size: 1.2rem; padding: 10px 20px; margin: 10px; cursor: pointer; }
|
17 |
+
.cart-container { margin-top: 30px; padding: 10px; border: 1px solid #ddd; border-radius: 5px; background-color: #eaf3e1; }
|
18 |
+
.cart-item { display: flex; justify-content: space-between; margin-bottom: 10px; }
|
19 |
</style>
|
20 |
</head>
|
21 |
<body>
|
22 |
<div class="menu-container">
|
23 |
<h1>Welcome to the Menu</h1>
|
24 |
<div id="menu-items"></div>
|
25 |
+
<button onclick="viewCart()">View Cart</button>
|
26 |
+
</div>
|
27 |
+
|
28 |
+
<div class="cart-container" id="cart-container" style="display:none;">
|
29 |
+
<h2>Your Cart</h2>
|
30 |
+
<div id="cart-items"></div>
|
31 |
</div>
|
32 |
|
33 |
<script>
|
34 |
const menuItems = [
|
|
|
35 |
{ name: 'Samosa', price: 9, ingredients: 'Potatoes, Peas, Flour, Spices', description: 'Crispy fried pastry filled with spiced potatoes and peas.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
|
36 |
{ name: 'Onion Pakoda', price: 10, ingredients: 'Onions, Gram Flour, Spices', description: 'Deep-fried onion fritters seasoned with herbs and spices.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
|
37 |
{ name: 'Chilli Gobi', price: 12, ingredients: 'Cauliflower, Chili Sauce, Spices', description: 'Cauliflower florets tossed in a spicy chili sauce.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
|
|
|
66 |
];
|
67 |
|
68 |
const menuContainer = document.getElementById('menu-items');
|
69 |
+
const cart = [];
|
70 |
|
71 |
+
// Function to automatically display the menu
|
72 |
+
function showMenu() {
|
73 |
menuContainer.innerHTML = ''; // Clear previous menu items
|
|
|
74 |
|
75 |
+
menuItems.forEach(item => {
|
76 |
const div = document.createElement('div');
|
77 |
div.classList.add('menu-item');
|
78 |
+
div.innerHTML = `<div class="details">
|
79 |
+
<img src="${item.imageUrl}" alt="${item.name}">
|
80 |
+
<div class="text">
|
81 |
+
<h3>${item.name}</h3>
|
82 |
+
<p>${item.description}</p>
|
83 |
+
<p><strong>Ingredients:</strong> ${item.ingredients}</p>
|
84 |
+
<p><strong>Price:</strong> $${item.price}</p>
|
85 |
+
<p><strong>Quantity:</strong> <input type="number" id="quantity-${item.name}" value="1" min="1" /></p>
|
86 |
+
<button onclick="addToCart('${item.name}')">Add to Cart</button>
|
87 |
+
</div>
|
88 |
+
</div>`;
|
89 |
menuContainer.appendChild(div);
|
90 |
});
|
91 |
}
|
92 |
|
93 |
+
// Function to add items to the cart
|
94 |
+
function addToCart(itemName) {
|
95 |
+
const quantity = document.getElementById(`quantity-${itemName}`).value;
|
96 |
+
const item = menuItems.find(item => item.name === itemName);
|
97 |
+
const cartItem = { ...item, quantity: parseInt(quantity) };
|
98 |
+
cart.push(cartItem);
|
99 |
+
speak(`Added ${quantity} of ${itemName} to the cart.`);
|
100 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
+
// Function to view the cart
|
103 |
+
function viewCart() {
|
104 |
+
const cartContainer = document.getElementById('cart-container');
|
105 |
+
const cartItemsContainer = document.getElementById('cart-items');
|
106 |
+
cartItemsContainer.innerHTML = '';
|
107 |
+
cart.forEach(cartItem => {
|
108 |
+
const div = document.createElement('div');
|
109 |
+
div.classList.add('cart-item');
|
110 |
+
div.innerHTML = `<span>${cartItem.name} (x${cartItem.quantity}) - $${cartItem.price * cartItem.quantity}</span>`;
|
111 |
+
cartItemsContainer.appendChild(div);
|
112 |
});
|
113 |
+
cartContainer.style.display = 'block';
|
114 |
}
|
115 |
|
116 |
+
// Function for speech synthesis
|
117 |
+
function speak(text) {
|
118 |
const msg = new SpeechSynthesisUtterance(text);
|
|
|
119 |
window.speechSynthesis.speak(msg);
|
120 |
}
|
121 |
|
122 |
+
window.onload = showMenu;
|
123 |
</script>
|
124 |
</body>
|
125 |
</html>
|
|
|
|