Spaces:
Sleeping
Sleeping
Update templates/menu_page.html
Browse files- templates/menu_page.html +59 -221
templates/menu_page.html
CHANGED
@@ -5,245 +5,83 @@
|
|
5 |
<head>
|
6 |
<meta charset="UTF-8">
|
7 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
8 |
-
<title>Biryani Hub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
<style>
|
10 |
body {
|
11 |
font-family: Arial, sans-serif;
|
12 |
-
background-color: #
|
13 |
margin: 0;
|
14 |
-
padding:
|
15 |
-
}
|
16 |
-
.container {
|
17 |
-
max-width: 1200px;
|
18 |
-
margin: 50px auto;
|
19 |
text-align: center;
|
20 |
}
|
21 |
h1 {
|
22 |
-
|
23 |
-
color: #333;
|
24 |
}
|
25 |
-
.menu-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
border: none;
|
31 |
-
border-radius: 5px;
|
32 |
-
background-color: #007bff;
|
33 |
-
color: white;
|
34 |
-
}
|
35 |
-
.menu-option button:hover {
|
36 |
-
background-color: #0056b3;
|
37 |
}
|
38 |
.menu-item {
|
39 |
-
|
40 |
-
|
41 |
margin: 10px;
|
42 |
-
padding: 10px;
|
43 |
-
border: 1px solid #ddd;
|
44 |
-
border-radius: 5px;
|
45 |
-
background-color: #fff;
|
46 |
-
}
|
47 |
-
.menu-item img {
|
48 |
-
width: 100px;
|
49 |
-
height: 100px;
|
50 |
border-radius: 8px;
|
51 |
-
|
52 |
-
|
53 |
-
.cart-container {
|
54 |
-
margin-top: 30px;
|
55 |
-
padding: 10px;
|
56 |
-
border: 1px solid #ddd;
|
57 |
-
border-radius: 5px;
|
58 |
-
background-color: #eaf3e1;
|
59 |
-
display: none;
|
60 |
-
}
|
61 |
-
.cart-item {
|
62 |
-
display: flex;
|
63 |
-
justify-content: space-between;
|
64 |
-
margin-bottom: 10px;
|
65 |
-
}
|
66 |
-
.view-cart-container {
|
67 |
-
position: fixed;
|
68 |
-
bottom: 20px;
|
69 |
-
right: 20px;
|
70 |
-
z-index: 999;
|
71 |
}
|
72 |
-
.
|
73 |
-
|
74 |
-
color: #
|
75 |
-
padding: 10px 20px;
|
76 |
-
border-radius: 50px;
|
77 |
-
font-size: 1rem;
|
78 |
-
font-weight: bold;
|
79 |
-
text-decoration: none;
|
80 |
-
display: flex;
|
81 |
-
align-items: center;
|
82 |
-
justify-content: center;
|
83 |
}
|
84 |
-
.
|
85 |
-
|
86 |
-
|
87 |
}
|
88 |
</style>
|
89 |
</head>
|
90 |
<body>
|
91 |
-
|
92 |
-
<div class="container" id="
|
93 |
-
<
|
94 |
-
<div class="menu-option">
|
95 |
-
<button id="veg-btn" onclick="showMenu('veg')">Vegetarian Menu</button>
|
96 |
-
<button id="non-veg-btn" onclick="showMenu('nonVeg')">Non-Vegetarian Menu</button>
|
97 |
-
</div>
|
98 |
-
</div>
|
99 |
-
|
100 |
-
<div class="container" id="menu-container" style="display: none;">
|
101 |
-
<h1>Menu</h1>
|
102 |
-
<div id="menu-items" class="row">
|
103 |
-
<!-- Dynamically populated menu items will appear here -->
|
104 |
-
</div>
|
105 |
-
<button onclick="viewCart()">View Cart</button>
|
106 |
-
</div>
|
107 |
-
|
108 |
-
<div class="cart-container" id="cart-container">
|
109 |
-
<h2>Your Cart</h2>
|
110 |
-
<div id="cart-items"></div>
|
111 |
-
<button onclick="placeOrder()">Place Final Order</button>
|
112 |
-
</div>
|
113 |
-
|
114 |
-
<div class="view-cart-container">
|
115 |
-
<a href="javascript:void(0);" class="view-cart-button" onclick="viewCart()">
|
116 |
-
View Cart
|
117 |
-
</a>
|
118 |
</div>
|
119 |
-
|
120 |
-
<script>
|
121 |
-
// Menu data
|
122 |
-
const menuItems = {
|
123 |
-
veg: [
|
124 |
-
{ 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' },
|
125 |
-
{ 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' },
|
126 |
-
{ 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' }
|
127 |
-
],
|
128 |
-
nonVeg: [
|
129 |
-
{ 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' },
|
130 |
-
{ 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' },
|
131 |
-
{ 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' }
|
132 |
-
]
|
133 |
-
};
|
134 |
-
|
135 |
-
const cart = [];
|
136 |
-
|
137 |
-
// Speech Synthesis and Speech Recognition
|
138 |
-
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
139 |
-
recognition.lang = 'en-US';
|
140 |
-
recognition.interimResults = false;
|
141 |
-
recognition.maxAlternatives = 1;
|
142 |
-
|
143 |
-
// Function to speak text
|
144 |
-
function speak(text, callback) {
|
145 |
-
const msg = new SpeechSynthesisUtterance(text);
|
146 |
-
msg.onend = callback;
|
147 |
-
window.speechSynthesis.speak(msg);
|
148 |
-
}
|
149 |
-
|
150 |
-
// Function to show the menu based on selected type (veg or non-veg)
|
151 |
-
function showMenu(type) {
|
152 |
-
// Hide the welcome screen and show the menu
|
153 |
-
document.getElementById('welcome-container').style.display = 'none';
|
154 |
-
document.getElementById('menu-container').style.display = 'block';
|
155 |
-
|
156 |
-
const menuContainer = document.getElementById('menu-items');
|
157 |
-
menuContainer.innerHTML = ''; // Clear previous menu items
|
158 |
-
|
159 |
-
menuItems[type].forEach(item => {
|
160 |
-
const div = document.createElement('div');
|
161 |
-
div.classList.add('menu-item');
|
162 |
-
div.innerHTML = `<div class="details">
|
163 |
-
<img src="${item.imageUrl}" alt="${item.name}">
|
164 |
-
<div class="text">
|
165 |
-
<h3>${item.name}</h3>
|
166 |
-
<p>${item.description}</p>
|
167 |
-
<p><strong>Ingredients:</strong> ${item.ingredients}</p>
|
168 |
-
<p><strong>Price:</strong> $${item.price}</p>
|
169 |
-
<button onclick="addToCart('${item.name}')">Add to Cart</button>
|
170 |
-
</div>
|
171 |
-
</div>`;
|
172 |
-
menuContainer.appendChild(div);
|
173 |
-
});
|
174 |
-
}
|
175 |
-
|
176 |
-
// Function to add items to the cart
|
177 |
-
function addToCart(itemName) {
|
178 |
-
const quantity = prompt(`How many ${itemName} would you like to add?`, 1);
|
179 |
-
if (quantity && !isNaN(quantity) && quantity > 0) {
|
180 |
-
const item = menuItems.veg.concat(menuItems.nonVeg).find(item => item.name === itemName);
|
181 |
-
const cartItem = { ...item, quantity: parseInt(quantity) };
|
182 |
-
cart.push(cartItem);
|
183 |
-
speak(`${quantity} of ${itemName} added to your cart.`, () => {});
|
184 |
-
} else {
|
185 |
-
speak("Please enter a valid quantity.", () => {});
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
// Function to view the cart
|
190 |
-
function viewCart() {
|
191 |
-
const cartContainer = document.getElementById('cart-container');
|
192 |
-
const cartItemsContainer = document.getElementById('cart-items');
|
193 |
-
cartItemsContainer.innerHTML = '';
|
194 |
-
cart.forEach(cartItem => {
|
195 |
-
const div = document.createElement('div');
|
196 |
-
div.classList.add('cart-item');
|
197 |
-
div.innerHTML = `<span>${cartItem.name} (x${cartItem.quantity}) - $${cartItem.price * cartItem.quantity}</span>`;
|
198 |
-
cartItemsContainer.appendChild(div);
|
199 |
-
});
|
200 |
-
cartContainer.style.display = 'block';
|
201 |
-
}
|
202 |
-
|
203 |
-
// Function to place the final order
|
204 |
-
function placeOrder() {
|
205 |
-
if (cart.length > 0) {
|
206 |
-
speak("Your order has been placed successfully!", () => {});
|
207 |
-
cart.length = 0; // Clear the cart after placing the order
|
208 |
-
viewCart(); // Optionally, update cart view
|
209 |
-
} else {
|
210 |
-
speak("Your cart is empty. Please add items before placing the order.", () => {});
|
211 |
-
}
|
212 |
-
}
|
213 |
-
|
214 |
-
// Function to start voice recognition
|
215 |
-
function startVoiceRecognition() {
|
216 |
-
recognition.start();
|
217 |
-
}
|
218 |
-
|
219 |
-
// Speech recognition logic
|
220 |
-
recognition.onresult = (event) => {
|
221 |
-
const command = event.results[0][0].transcript.toLowerCase();
|
222 |
-
if (command.includes('vegetarian')) {
|
223 |
-
showMenu('veg');
|
224 |
-
speak("Here are the vegetarian items.", () => {});
|
225 |
-
} else if (command.includes('non-vegetarian')) {
|
226 |
-
showMenu('nonVeg');
|
227 |
-
speak("Here are the non-vegetarian items.", () => {});
|
228 |
-
} else {
|
229 |
-
speak("Please say vegetarian or non-vegetarian.", () => {
|
230 |
-
recognition.start();
|
231 |
-
});
|
232 |
-
}
|
233 |
-
};
|
234 |
-
|
235 |
-
recognition.onerror = (event) => {
|
236 |
-
console.error("Speech recognition error:", event.error);
|
237 |
-
speak("Sorry, I couldn't understand that. Please try again.", () => recognition.start());
|
238 |
-
};
|
239 |
-
|
240 |
-
// Welcome message and voice prompt when the page loads
|
241 |
-
window.onload = () => {
|
242 |
-
speak("Welcome to the Biryani Hub menu. Please say vegetarian or non-vegetarian to choose your menu.", () => {
|
243 |
-
startVoiceRecognition();
|
244 |
-
});
|
245 |
-
}
|
246 |
-
</script>
|
247 |
-
|
248 |
</body>
|
249 |
</html>
|
|
|
5 |
<head>
|
6 |
<meta charset="UTF-8">
|
7 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
8 |
+
<title>Menu - Biryani Hub</title>
|
9 |
+
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
|
10 |
+
<script>
|
11 |
+
// Function to fetch menu from the API
|
12 |
+
function fetchMenu() {
|
13 |
+
fetch("https://lokesh341-voicemenuwithregisterandloginnnwithmenuu.hf.space/menu")
|
14 |
+
.then(response => response.json())
|
15 |
+
.then(data => {
|
16 |
+
if (data.success) {
|
17 |
+
let menuContainer = document.getElementById("menu-list");
|
18 |
+
menuContainer.innerHTML = "";
|
19 |
+
|
20 |
+
data.menu.forEach(item => {
|
21 |
+
let menuItem = document.createElement("div");
|
22 |
+
menuItem.classList.add("menu-item");
|
23 |
+
|
24 |
+
menuItem.innerHTML = `
|
25 |
+
<h3>${item.name}</h3>
|
26 |
+
<p><strong>Price:</strong> $${item.price}</p>
|
27 |
+
<p><strong>Ingredients:</strong> ${item.ingredients}</p>
|
28 |
+
<p><strong>Category:</strong> ${item.category}</p>
|
29 |
+
`;
|
30 |
+
|
31 |
+
menuContainer.appendChild(menuItem);
|
32 |
+
});
|
33 |
+
} else {
|
34 |
+
document.getElementById("menu-list").innerHTML = "<p>Error fetching menu.</p>";
|
35 |
+
}
|
36 |
+
})
|
37 |
+
.catch(error => {
|
38 |
+
console.error("Error fetching menu:", error);
|
39 |
+
document.getElementById("menu-list").innerHTML = "<p>Unable to load menu.</p>";
|
40 |
+
});
|
41 |
+
}
|
42 |
+
|
43 |
+
// Load menu when page loads
|
44 |
+
window.onload = fetchMenu;
|
45 |
+
</script>
|
46 |
<style>
|
47 |
body {
|
48 |
font-family: Arial, sans-serif;
|
49 |
+
background-color: #f8f9fa;
|
50 |
margin: 0;
|
51 |
+
padding: 20px;
|
|
|
|
|
|
|
|
|
52 |
text-align: center;
|
53 |
}
|
54 |
h1 {
|
55 |
+
color: #ff5722;
|
|
|
56 |
}
|
57 |
+
.menu-container {
|
58 |
+
display: flex;
|
59 |
+
flex-wrap: wrap;
|
60 |
+
justify-content: center;
|
61 |
+
margin-top: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
}
|
63 |
.menu-item {
|
64 |
+
background-color: white;
|
65 |
+
padding: 15px;
|
66 |
margin: 10px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
border-radius: 8px;
|
68 |
+
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
|
69 |
+
width: 300px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
}
|
71 |
+
.menu-item h3 {
|
72 |
+
margin: 0;
|
73 |
+
color: #333;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
+
.menu-item p {
|
76 |
+
margin: 5px 0;
|
77 |
+
color: #555;
|
78 |
}
|
79 |
</style>
|
80 |
</head>
|
81 |
<body>
|
82 |
+
<h1>Restaurant Menu</h1>
|
83 |
+
<div class="menu-container" id="menu-list">
|
84 |
+
<p>Loading menu...</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
</body>
|
87 |
</html>
|