Spaces:
Sleeping
Sleeping
Update templates/menu_page.html
Browse files- templates/menu_page.html +70 -191
templates/menu_page.html
CHANGED
@@ -3,241 +3,120 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>Biryani Hub
|
7 |
<style>
|
|
|
8 |
body {
|
9 |
font-family: Arial, sans-serif;
|
10 |
background-color: #f8f8f8;
|
11 |
margin: 0;
|
12 |
padding: 0;
|
13 |
}
|
14 |
-
|
|
|
15 |
max-width: 1200px;
|
16 |
-
margin:
|
17 |
-
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
h1 {
|
|
|
20 |
font-size: 2.5rem;
|
21 |
color: #333;
|
22 |
-
|
23 |
-
.menu-option button {
|
24 |
-
font-size: 1.2rem;
|
25 |
-
padding: 10px 20px;
|
26 |
-
margin: 20px;
|
27 |
-
cursor: pointer;
|
28 |
-
border: none;
|
29 |
-
border-radius: 5px;
|
30 |
-
background-color: #007bff;
|
31 |
-
color: white;
|
32 |
-
}
|
33 |
-
.menu-option button:hover {
|
34 |
-
background-color: #0056b3;
|
35 |
}
|
36 |
.menu-item {
|
37 |
-
|
38 |
-
|
39 |
-
margin: 10px;
|
40 |
-
padding: 10px;
|
41 |
-
border: 1px solid #ddd;
|
42 |
-
border-radius: 5px;
|
43 |
-
background-color: #fff;
|
44 |
-
}
|
45 |
-
.menu-item img {
|
46 |
-
width: 100px;
|
47 |
-
height: 100px;
|
48 |
-
border-radius: 8px;
|
49 |
-
margin-bottom: 10px;
|
50 |
-
}
|
51 |
-
.cart-container {
|
52 |
-
margin-top: 30px;
|
53 |
-
padding: 10px;
|
54 |
-
border: 1px solid #ddd;
|
55 |
-
border-radius: 5px;
|
56 |
-
background-color: #eaf3e1;
|
57 |
-
display: none;
|
58 |
-
}
|
59 |
-
.cart-item {
|
60 |
display: flex;
|
61 |
justify-content: space-between;
|
62 |
-
|
63 |
}
|
64 |
-
.
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
69 |
}
|
70 |
-
.
|
71 |
-
background-color: #
|
72 |
-
|
|
|
73 |
padding: 10px 20px;
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
81 |
}
|
82 |
-
|
83 |
-
background-color: #
|
84 |
-
text-decoration: none;
|
85 |
}
|
86 |
</style>
|
87 |
</head>
|
88 |
<body>
|
89 |
|
90 |
-
<div class="
|
91 |
-
<h1>Welcome to the
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
</div>
|
103 |
-
|
104 |
-
</div>
|
105 |
|
106 |
-
|
107 |
-
<
|
108 |
-
<div id="cart-items"></div>
|
109 |
-
<button onclick="placeOrder()">Place Final Order</button>
|
110 |
-
</div>
|
111 |
-
|
112 |
-
<div class="view-cart-container">
|
113 |
-
<a href="javascript:void(0);" class="view-cart-button" onclick="viewCart()">
|
114 |
-
View Cart
|
115 |
-
</a>
|
116 |
</div>
|
117 |
|
118 |
<script>
|
119 |
-
|
120 |
-
const menuItems = {
|
121 |
-
veg: [
|
122 |
-
{ 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' },
|
123 |
-
{ 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' },
|
124 |
-
{ 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' }
|
125 |
-
],
|
126 |
-
nonVeg: [
|
127 |
-
{ name: 'Chicken Biryani', price: 14, ingredients: 'Chicken, Basmati Rice, Spices', description: 'Aromatic basmati rice cooked with tender chicken and spices.', imageUrl: 'https://via.placeholder.com/100' },
|
128 |
-
{ name: 'Mutton Biryani', price: 16, ingredients: 'Mutton, Basmati Rice, Spices', description: 'Flavorful rice dish made with succulent mutton and aromatic spices.', imageUrl: 'https://via.placeholder.com/100' },
|
129 |
-
{ name: 'Butter Chicken', price: 15, ingredients: 'Chicken, Tomato, Butter, Cream', description: 'Tender chicken cooked in a rich, creamy tomato sauce.', imageUrl: 'https://via.placeholder.com/100' }
|
130 |
-
]
|
131 |
-
};
|
132 |
-
const cart = [];
|
133 |
-
|
134 |
-
// Speech Synthesis and Speech Recognition
|
135 |
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
136 |
-
recognition.lang =
|
137 |
recognition.interimResults = false;
|
138 |
-
|
139 |
-
|
140 |
-
// Function to speak text
|
141 |
-
function speak(text, callback) {
|
142 |
const msg = new SpeechSynthesisUtterance(text);
|
143 |
-
msg.onend = callback;
|
144 |
window.speechSynthesis.speak(msg);
|
145 |
}
|
146 |
-
|
147 |
-
|
148 |
-
function showMenu(type) {
|
149 |
-
// Hide the welcome screen and show the menu
|
150 |
-
document.getElementById('welcome-container').style.display = 'none';
|
151 |
-
document.getElementById('menu-container').style.display = 'block';
|
152 |
-
const menuContainer = document.getElementById('menu-items');
|
153 |
-
menuContainer.innerHTML = ''; // Clear previous menu items
|
154 |
-
|
155 |
-
menuItems[type].forEach(item => {
|
156 |
-
const div = document.createElement('div');
|
157 |
-
div.classList.add('menu-item');
|
158 |
-
div.innerHTML = `<div class="details">
|
159 |
-
<img src="${item.imageUrl}" alt="${item.name}">
|
160 |
-
<div class="text">
|
161 |
-
<h3>${item.name}</h3>
|
162 |
-
<p>${item.description}</p>
|
163 |
-
<p><strong>Ingredients:</strong> ${item.ingredients}</p>
|
164 |
-
<p><strong>Price:</strong> $${item.price}</p>
|
165 |
-
<button onclick="addToCart('${item.name}')">Add to Cart</button>
|
166 |
-
</div>
|
167 |
-
</div>`;
|
168 |
-
menuContainer.appendChild(div);
|
169 |
-
});
|
170 |
-
}
|
171 |
-
|
172 |
-
// Function to add items to the cart
|
173 |
-
function addToCart(itemName) {
|
174 |
-
const quantity = prompt(`How many ${itemName} would you like to add?`, 1);
|
175 |
-
if (quantity && !isNaN(quantity) && quantity > 0) {
|
176 |
-
const item = menuItems.veg.concat(menuItems.nonVeg).find(item => item.name === itemName);
|
177 |
-
const cartItem = { ...item, quantity: parseInt(quantity) };
|
178 |
-
cart.push(cartItem);
|
179 |
-
speak(`${quantity} of ${itemName} added to your cart.`, () => {});
|
180 |
-
} else {
|
181 |
-
speak("Please enter a valid quantity.", () => {});
|
182 |
-
}
|
183 |
-
}
|
184 |
-
|
185 |
-
// Function to view the cart
|
186 |
-
function viewCart() {
|
187 |
-
const cartContainer = document.getElementById('cart-container');
|
188 |
-
const cartItemsContainer = document.getElementById('cart-items');
|
189 |
-
cartItemsContainer.innerHTML = '';
|
190 |
-
cart.forEach(cartItem => {
|
191 |
-
const div = document.createElement('div');
|
192 |
-
div.classList.add('cart-item');
|
193 |
-
div.innerHTML = `<span>${cartItem.name} (x${cartItem.quantity}) - $${cartItem.price * cartItem.quantity}</span>`;
|
194 |
-
cartItemsContainer.appendChild(div);
|
195 |
-
});
|
196 |
-
cartContainer.style.display = 'block';
|
197 |
-
}
|
198 |
-
|
199 |
-
// Function to place the final order
|
200 |
-
function placeOrder() {
|
201 |
-
if (cart.length > 0) {
|
202 |
-
speak("Your order has been placed successfully!", () => {});
|
203 |
-
cart.length = 0; // Clear the cart after placing the order
|
204 |
-
viewCart(); // Optionally, update cart view
|
205 |
-
} else {
|
206 |
-
speak("Your cart is empty. Please add items before placing the order.", () => {});
|
207 |
-
}
|
208 |
-
}
|
209 |
-
|
210 |
-
// Function to start voice recognition
|
211 |
-
function startVoiceRecognition() {
|
212 |
recognition.start();
|
213 |
-
}
|
214 |
-
|
215 |
-
// Speech recognition logic
|
216 |
recognition.onresult = (event) => {
|
217 |
const command = event.results[0][0].transcript.toLowerCase();
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
speak("Here are the non-vegetarian items.", () => {});
|
224 |
-
} else {
|
225 |
-
speak("Please say vegetarian or non-vegetarian.", () => {
|
226 |
-
recognition.start();
|
227 |
-
});
|
228 |
}
|
229 |
};
|
230 |
-
|
231 |
recognition.onerror = (event) => {
|
232 |
console.error("Speech recognition error:", event.error);
|
233 |
-
speak("Sorry, I couldn't understand that. Please try again."
|
234 |
};
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
|
|
240 |
});
|
|
|
241 |
}
|
242 |
</script>
|
243 |
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Menu - Biryani Hub</title>
|
7 |
<style>
|
8 |
+
/* General Body Styling */
|
9 |
body {
|
10 |
font-family: Arial, sans-serif;
|
11 |
background-color: #f8f8f8;
|
12 |
margin: 0;
|
13 |
padding: 0;
|
14 |
}
|
15 |
+
/* Container for the menu */
|
16 |
+
.menu-container {
|
17 |
max-width: 1200px;
|
18 |
+
margin: 0 auto;
|
19 |
+
padding: 20px;
|
20 |
+
background-color: #fff;
|
21 |
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
22 |
+
border-radius: 8px;
|
23 |
+
margin-top: 50px;
|
24 |
}
|
25 |
h1 {
|
26 |
+
text-align: center;
|
27 |
font-size: 2.5rem;
|
28 |
color: #333;
|
29 |
+
margin-bottom: 30px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
.menu-item {
|
32 |
+
border-bottom: 1px solid #eee;
|
33 |
+
padding: 15px 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
display: flex;
|
35 |
justify-content: space-between;
|
36 |
+
align-items: center;
|
37 |
}
|
38 |
+
.order-btn {
|
39 |
+
padding: 10px 20px;
|
40 |
+
background-color: #4CAF50;
|
41 |
+
color: white;
|
42 |
+
border: none;
|
43 |
+
border-radius: 5px;
|
44 |
+
cursor: pointer;
|
45 |
}
|
46 |
+
.order-btn:hover {
|
47 |
+
background-color: #45a049;
|
48 |
+
}
|
49 |
+
#listen-btn {
|
50 |
padding: 10px 20px;
|
51 |
+
background-color: #4CAF50;
|
52 |
+
color: white;
|
53 |
+
border: none;
|
54 |
+
border-radius: 5px;
|
55 |
+
cursor: pointer;
|
56 |
+
font-size: 1.2rem;
|
57 |
+
display: block;
|
58 |
+
margin: 30px auto;
|
59 |
}
|
60 |
+
#listen-btn:hover {
|
61 |
+
background-color: #45a049;
|
|
|
62 |
}
|
63 |
</style>
|
64 |
</head>
|
65 |
<body>
|
66 |
|
67 |
+
<div class="menu-container">
|
68 |
+
<h1>Welcome to the Menu</h1>
|
69 |
+
|
70 |
+
{% for item in menu_items %}
|
71 |
+
<div class="menu-item">
|
72 |
+
<div class="details">
|
73 |
+
<h3>{{ item.name }}</h3>
|
74 |
+
<p><strong>Ingredients:</strong> {{ item.ingredients }}</p>
|
75 |
+
<p><strong>Category:</strong> {{ item.category }}</p>
|
76 |
+
<p class="price">Price: ${{ item.price }}</p>
|
77 |
+
</div>
|
78 |
+
<button class="order-btn">Order</button>
|
79 |
</div>
|
80 |
+
{% endfor %}
|
|
|
81 |
|
82 |
+
<!-- Button for triggering voice recognition -->
|
83 |
+
<button id="listen-btn">Say "Order" to order an item</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
</div>
|
85 |
|
86 |
<script>
|
87 |
+
const listenButton = document.getElementById("listen-btn");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
89 |
+
recognition.lang = "en-US";
|
90 |
recognition.interimResults = false;
|
91 |
+
function speak(text) {
|
|
|
|
|
|
|
92 |
const msg = new SpeechSynthesisUtterance(text);
|
|
|
93 |
window.speechSynthesis.speak(msg);
|
94 |
}
|
95 |
+
listenButton.addEventListener("click", () => {
|
96 |
+
speak("Please say the item you want to order.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
recognition.start();
|
98 |
+
});
|
|
|
|
|
99 |
recognition.onresult = (event) => {
|
100 |
const command = event.results[0][0].transcript.toLowerCase();
|
101 |
+
console.log("User said:", command);
|
102 |
+
// Add logic to recognize specific items or trigger actions based on the command
|
103 |
+
if (command.includes("order")) {
|
104 |
+
// For example, navigate or process an order (customize as needed)
|
105 |
+
speak("Your order has been placed.");
|
|
|
|
|
|
|
|
|
|
|
106 |
}
|
107 |
};
|
|
|
108 |
recognition.onerror = (event) => {
|
109 |
console.error("Speech recognition error:", event.error);
|
110 |
+
speak("Sorry, I couldn't understand that. Please try again.");
|
111 |
};
|
112 |
+
// Voice reading of menu items on page load
|
113 |
+
window.onload = function() {
|
114 |
+
const menuItems = document.querySelectorAll('.menu-item h3');
|
115 |
+
let itemsText = "The menu includes: ";
|
116 |
+
menuItems.forEach(item => {
|
117 |
+
itemsText += item.textContent + ", ";
|
118 |
});
|
119 |
+
speak(itemsText); // Speak all the item names
|
120 |
}
|
121 |
</script>
|
122 |
|