Spaces:
Running
Running
Update templates/menu_page.html
Browse files- templates/menu_page.html +11 -0
templates/menu_page.html
CHANGED
@@ -130,17 +130,20 @@
|
|
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
|
@@ -148,6 +151,7 @@
|
|
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');
|
@@ -164,6 +168,7 @@
|
|
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);
|
@@ -176,6 +181,7 @@
|
|
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');
|
@@ -189,6 +195,7 @@
|
|
189 |
});
|
190 |
cartContainer.style.display = 'block';
|
191 |
}
|
|
|
192 |
// Function to place the final order
|
193 |
function placeOrder() {
|
194 |
if (cart.length > 0) {
|
@@ -199,10 +206,12 @@
|
|
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();
|
@@ -218,10 +227,12 @@
|
|
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.", () => {
|
|
|
130 |
]
|
131 |
};
|
132 |
const cart = [];
|
133 |
+
|
134 |
// Speech Synthesis and Speech Recognition
|
135 |
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
136 |
recognition.lang = 'en-US';
|
137 |
recognition.interimResults = false;
|
138 |
recognition.maxAlternatives = 1;
|
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 |
// Function to show the menu based on selected type (veg or non-veg)
|
148 |
function showMenu(type) {
|
149 |
// Hide the welcome screen and show the menu
|
|
|
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');
|
|
|
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);
|
|
|
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');
|
|
|
195 |
});
|
196 |
cartContainer.style.display = 'block';
|
197 |
}
|
198 |
+
|
199 |
// Function to place the final order
|
200 |
function placeOrder() {
|
201 |
if (cart.length > 0) {
|
|
|
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();
|
|
|
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.", () => recognition.start());
|
234 |
};
|
235 |
+
|
236 |
// Welcome message and voice prompt when the page loads
|
237 |
window.onload = () => {
|
238 |
speak("Welcome to the Biryani Hub menu. Please say vegetarian or non-vegetarian to choose your menu.", () => {
|