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