Spaces:
Running
Running
Update templates/menu_page.html
Browse files- templates/menu_page.html +149 -156
templates/menu_page.html
CHANGED
@@ -62,162 +62,155 @@
|
|
62 |
display: none;
|
63 |
}
|
64 |
</style>
|
65 |
-
</head>
|
66 |
-
<body>
|
67 |
|
68 |
-
|
69 |
-
<
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
</
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
<
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
//
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
})
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
}
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
function
|
182 |
-
|
183 |
-
|
184 |
-
}
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
}
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
speak("Sorry, I couldn't understand that. Please say 'Main Course' or 'Appetizers'.");
|
217 |
}
|
218 |
-
|
219 |
-
};
|
220 |
-
</script>
|
221 |
|
222 |
-
</body>
|
223 |
-
</html>
|
|
|
62 |
display: none;
|
63 |
}
|
64 |
</style>
|
|
|
|
|
65 |
|
66 |
+
<div class="menu-container">
|
67 |
+
<h1>Welcome to Biryani Hub menu</h1>
|
68 |
+
<h3 id="category-title">Please select a category:</h3>
|
69 |
+
|
70 |
+
<!-- Buttons for selecting categories -->
|
71 |
+
<div id="category-buttons">
|
72 |
+
<button id="main-course-btn">Main Course</button>
|
73 |
+
<button id="appetizer-btn">Appetizers</button>
|
74 |
+
</div>
|
75 |
+
|
76 |
+
<!-- Dynamic Menu Item List -->
|
77 |
+
<div id="menu-items"></div>
|
78 |
+
|
79 |
+
<div id="cart-summary" style="display:none;">
|
80 |
+
<h2>Your Cart:</h2>
|
81 |
+
<div id="cart-details"></div>
|
82 |
+
<button id="place-order-btn">Place Final Order</button>
|
83 |
+
</div>
|
84 |
+
</div>
|
85 |
+
|
86 |
+
<script>
|
87 |
+
const cartSummary = document.getElementById("cart-summary");
|
88 |
+
const cartDetails = document.getElementById("cart-details");
|
89 |
+
const categoryButtons = document.getElementById("category-buttons");
|
90 |
+
let cart = []; // Global cart variable to store items
|
91 |
+
let menuData = {}; // Will store menu items based on categories
|
92 |
+
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
93 |
+
recognition.lang = "en-US";
|
94 |
+
recognition.interimResults = false;
|
95 |
+
// Function to speak text
|
96 |
+
function speak(text) {
|
97 |
+
const msg = new SpeechSynthesisUtterance(text);
|
98 |
+
window.speechSynthesis.speak(msg);
|
99 |
+
}
|
100 |
+
// Start voice recognition automatically on page load
|
101 |
+
window.onload = function() {
|
102 |
+
// Sample menu data for Main Course and Appetizers
|
103 |
+
menuData = {
|
104 |
+
'Main Course': [
|
105 |
+
{ name: "Chicken Biryani", price: 250 },
|
106 |
+
{ name: "Veg Biryani", price: 200 },
|
107 |
+
{ name: "Mutton Biryani", price: 300 }
|
108 |
+
],
|
109 |
+
'Appetizers': [
|
110 |
+
{ name: "Paneer Tikka", price: 180 },
|
111 |
+
{ name: "Chicken Wings", price: 220 }
|
112 |
+
]
|
113 |
+
};
|
114 |
+
// Populate categories dynamically
|
115 |
+
document.getElementById("main-course-btn").addEventListener("click", () => {
|
116 |
+
displayMenuItems('Main Course');
|
117 |
+
});
|
118 |
+
document.getElementById("appetizer-btn").addEventListener("click", () => {
|
119 |
+
displayMenuItems('Appetizers');
|
120 |
+
});
|
121 |
+
// Voice greeting for menu categories
|
122 |
+
speak("Welcome to Biryani Hub! We have the following categories: Main Course and Appetizers. Please say 'Main Course' or 'Appetizers' to select a category.");
|
123 |
+
// Automatically trigger voice recognition for category selection
|
124 |
+
recognition.start();
|
125 |
+
recognition.onresult = (event) => {
|
126 |
+
const categoryCommand = event.results[0][0].transcript.toLowerCase();
|
127 |
+
if (categoryCommand.includes("main course")) {
|
128 |
+
displayMenuItems('Main Course');
|
129 |
+
} else if (categoryCommand.includes("appetizers")) {
|
130 |
+
displayMenuItems('Appetizers');
|
131 |
+
} else {
|
132 |
+
speak("Sorry, I couldn't understand that. Please say 'Main Course' or 'Appetizers'.");
|
133 |
+
}
|
134 |
+
};
|
135 |
+
};
|
136 |
+
// Function to populate the menu based on selected category
|
137 |
+
function displayMenuItems(category) {
|
138 |
+
const menuContainer = document.getElementById('menu-items');
|
139 |
+
menuContainer.innerHTML = ''; // Clear previous menu
|
140 |
+
if (menuData[category]) {
|
141 |
+
menuData[category].forEach(item => {
|
142 |
+
const itemElement = document.createElement('div');
|
143 |
+
itemElement.classList.add('menu-item');
|
144 |
+
itemElement.innerHTML =
|
145 |
+
<div class="details">
|
146 |
+
<h3>${item.name}</h3>
|
147 |
+
<p class="price">Price: ₹${item.price}</p>
|
148 |
+
</div>
|
149 |
+
<button class="order-btn" onclick="addToCart('${item.name}', 1)">Order</button>
|
150 |
+
;
|
151 |
+
menuContainer.appendChild(itemElement);
|
152 |
+
});
|
153 |
+
// Automatically prompt the user to order
|
154 |
+
speak("Here are the items in the selected category. Please say the item you want to order.");
|
155 |
+
recognition.start();
|
156 |
+
recognition.onresult = (event) => {
|
157 |
+
const itemName = event.results[0][0].transcript.toLowerCase();
|
158 |
+
const item = findItem(itemName);
|
159 |
+
if (item) {
|
160 |
+
speak(You selected ${item.name}. How many would you like?);
|
161 |
+
recognition.start();
|
162 |
+
recognition.onresult = (event) => {
|
163 |
+
const quantity = parseInt(event.results[0][0].transcript);
|
164 |
+
if (quantity) {
|
165 |
+
addToCart(item.name, quantity);
|
166 |
+
speak(${quantity} ${item.name} added to your cart.);
|
167 |
+
askMoreItems();
|
168 |
+
} else {
|
169 |
+
speak("Please say a valid quantity.");
|
170 |
+
}
|
171 |
+
};
|
172 |
+
} else {
|
173 |
+
speak("Sorry, I couldn't find that item. Please try again.");
|
174 |
+
}
|
175 |
+
};
|
176 |
+
}
|
177 |
+
}
|
178 |
+
// Function to add an item to the cart
|
179 |
+
function addToCart(itemName, quantity) {
|
180 |
+
const item = findItem(itemName);
|
181 |
+
cart.push({ name: item.name, price: item.price, quantity: quantity });
|
182 |
+
}
|
183 |
+
// Function to show cart details
|
184 |
+
function showCartDetails() {
|
185 |
+
if (cart.length > 0) {
|
186 |
+
let cartHtml = "";
|
187 |
+
cart.forEach(item => {
|
188 |
+
cartHtml += <p>${item.quantity} x ${item.name} - ₹${item.price * item.quantity}</p>;
|
189 |
+
});
|
190 |
+
cartDetails.innerHTML = cartHtml;
|
191 |
+
cartSummary.style.display = "block";
|
192 |
+
speak(Your cart contains ${cart.length} items.);
|
193 |
+
} else {
|
194 |
+
speak("Your cart is empty.");
|
195 |
+
}
|
196 |
+
}
|
197 |
+
// Function to ask if the user wants to order more items
|
198 |
+
function askMoreItems() {
|
199 |
+
speak("Would you like to order more items?");
|
200 |
+
recognition.start();
|
201 |
+
recognition.onresult = (event) => {
|
202 |
+
const response = event.results[0][0].transcript.toLowerCase();
|
203 |
+
if (response.includes("yes")) {
|
204 |
+
recognition.start();
|
205 |
+
} else {
|
206 |
+
showCartDetails();
|
207 |
+
}
|
208 |
+
};
|
209 |
+
}
|
210 |
+
// Function to find item in the menu
|
211 |
+
function findItem(itemName) {
|
212 |
+
const menu = menuData['Main Course']; // Default category to check first
|
213 |
+
return menu.find(item => item.name.toLowerCase() === itemName.toLowerCase());
|
|
|
214 |
}
|
215 |
+
</script>
|
|
|
|
|
216 |
|
|
|
|