Spaces:
Sleeping
Sleeping
Update templates/menu_page.html
Browse files- templates/menu_page.html +54 -7
templates/menu_page.html
CHANGED
@@ -91,10 +91,11 @@
|
|
91 |
|
92 |
<h1>Restaurant Menu</h1>
|
93 |
|
94 |
-
<!-- Buttons
|
95 |
<div class="filter-buttons">
|
96 |
-
<button onclick="filterMenu('
|
97 |
-
<button onclick="filterMenu('
|
|
|
98 |
</div>
|
99 |
|
100 |
<!-- Menu Display -->
|
@@ -121,6 +122,8 @@
|
|
121 |
<button onclick="viewCart()">View Cart</button>
|
122 |
|
123 |
<script>
|
|
|
|
|
124 |
// ✅ Speech Synthesis - Welcome message
|
125 |
function speak(text, callback) {
|
126 |
const msg = new SpeechSynthesisUtterance(text);
|
@@ -144,10 +147,10 @@
|
|
144 |
recognition.onresult = function(event) {
|
145 |
const command = event.results[0][0].transcript.toLowerCase();
|
146 |
if (command.includes("vegetarian") || command.includes("veg")) {
|
147 |
-
filterMenu("
|
148 |
speak("Here are the vegetarian items.");
|
149 |
} else if (command.includes("non-vegetarian") || command.includes("non veg")) {
|
150 |
-
filterMenu("
|
151 |
speak("Here are the non-vegetarian items.");
|
152 |
} else {
|
153 |
speak("Sorry, I didn't understand. Please say Vegetarian or Non-Vegetarian.", function() {
|
@@ -161,9 +164,10 @@
|
|
161 |
function filterMenu(type) {
|
162 |
const allItems = document.querySelectorAll('.menu-item');
|
163 |
allItems.forEach(item => {
|
164 |
-
|
|
|
165 |
item.style.display = "block";
|
166 |
-
} else if (type === "
|
167 |
item.style.display = "block";
|
168 |
} else {
|
169 |
item.style.display = "none";
|
@@ -171,6 +175,49 @@
|
|
171 |
});
|
172 |
}
|
173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
// ✅ Welcome Message on Page Load
|
175 |
window.onload = askMenuType;
|
176 |
</script>
|
|
|
91 |
|
92 |
<h1>Restaurant Menu</h1>
|
93 |
|
94 |
+
<!-- Filter Buttons -->
|
95 |
<div class="filter-buttons">
|
96 |
+
<button onclick="filterMenu('Veg')">Vegetarian</button>
|
97 |
+
<button onclick="filterMenu('Non-Veg')">Non-Vegetarian</button>
|
98 |
+
<button onclick="resetMenu()">Show All</button>
|
99 |
</div>
|
100 |
|
101 |
<!-- Menu Display -->
|
|
|
122 |
<button onclick="viewCart()">View Cart</button>
|
123 |
|
124 |
<script>
|
125 |
+
let cart = [];
|
126 |
+
|
127 |
// ✅ Speech Synthesis - Welcome message
|
128 |
function speak(text, callback) {
|
129 |
const msg = new SpeechSynthesisUtterance(text);
|
|
|
147 |
recognition.onresult = function(event) {
|
148 |
const command = event.results[0][0].transcript.toLowerCase();
|
149 |
if (command.includes("vegetarian") || command.includes("veg")) {
|
150 |
+
filterMenu("Veg");
|
151 |
speak("Here are the vegetarian items.");
|
152 |
} else if (command.includes("non-vegetarian") || command.includes("non veg")) {
|
153 |
+
filterMenu("Non-Veg");
|
154 |
speak("Here are the non-vegetarian items.");
|
155 |
} else {
|
156 |
speak("Sorry, I didn't understand. Please say Vegetarian or Non-Vegetarian.", function() {
|
|
|
164 |
function filterMenu(type) {
|
165 |
const allItems = document.querySelectorAll('.menu-item');
|
166 |
allItems.forEach(item => {
|
167 |
+
const category = item.dataset.category.toLowerCase();
|
168 |
+
if (type === "Veg" && (category.includes("veg") || category.includes("paneer") || category.includes("channa"))) {
|
169 |
item.style.display = "block";
|
170 |
+
} else if (type === "Non-Veg" && (category.includes("chicken") || category.includes("mutton") || category.includes("fish") || category.includes("prawn"))) {
|
171 |
item.style.display = "block";
|
172 |
} else {
|
173 |
item.style.display = "none";
|
|
|
175 |
});
|
176 |
}
|
177 |
|
178 |
+
// ✅ Reset filter and show all items
|
179 |
+
function resetMenu() {
|
180 |
+
document.querySelectorAll('.menu-item').forEach(item => item.style.display = "block");
|
181 |
+
}
|
182 |
+
|
183 |
+
// ✅ Function to add items to cart
|
184 |
+
function addToCart(name, price) {
|
185 |
+
const existingItem = cart.find(item => item.name === name);
|
186 |
+
if (existingItem) {
|
187 |
+
existingItem.quantity += 1;
|
188 |
+
} else {
|
189 |
+
cart.push({ name, price, quantity: 1 });
|
190 |
+
}
|
191 |
+
speak(name + " added to cart!");
|
192 |
+
}
|
193 |
+
|
194 |
+
// ✅ Function to view cart
|
195 |
+
function viewCart() {
|
196 |
+
const cartContainer = document.getElementById("cart-container");
|
197 |
+
const cartItemsContainer = document.getElementById("cart-items");
|
198 |
+
|
199 |
+
cartItemsContainer.innerHTML = "";
|
200 |
+
cart.forEach(cartItem => {
|
201 |
+
const div = document.createElement("div");
|
202 |
+
div.classList.add("cart-item");
|
203 |
+
div.innerHTML = `<span>${cartItem.name} (x${cartItem.quantity}) - $${cartItem.price * cartItem.quantity}</span>`;
|
204 |
+
cartItemsContainer.appendChild(div);
|
205 |
+
});
|
206 |
+
|
207 |
+
cartContainer.style.display = "block";
|
208 |
+
}
|
209 |
+
|
210 |
+
// ✅ Function to checkout (Placeholder)
|
211 |
+
function checkout() {
|
212 |
+
if (cart.length > 0) {
|
213 |
+
speak("Your order has been placed successfully!");
|
214 |
+
cart = [];
|
215 |
+
viewCart();
|
216 |
+
} else {
|
217 |
+
speak("Your cart is empty. Please add items before placing the order.");
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
// ✅ Welcome Message on Page Load
|
222 |
window.onload = askMenuType;
|
223 |
</script>
|