Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +25 -10
templates/index.html
CHANGED
@@ -88,7 +88,7 @@
|
|
88 |
<!-- Welcome Page -->
|
89 |
<div class="container" id="welcomePage">
|
90 |
<h1>Welcome to Biriyani Hub 🍽</h1>
|
91 |
-
|
92 |
<p class="status" id="status">🔊 Please say 'new' to register or 'existing' to login.</p>
|
93 |
</div>
|
94 |
|
@@ -127,6 +127,7 @@
|
|
127 |
<p class="details"><strong>Email:</strong> <span id="confirmEmail"></span></p>
|
128 |
<p class="details"><strong>Phone:</strong> <span id="confirmPhone"></span></p>
|
129 |
</div>
|
|
|
130 |
</div>
|
131 |
|
132 |
<div id="statusMessage" style="display: none;">
|
@@ -143,14 +144,15 @@
|
|
143 |
} else {
|
144 |
alert("Speech Recognition API is not supported in this browser.");
|
145 |
}
|
|
|
146 |
function speak(text, callback) {
|
147 |
const speech = new SpeechSynthesisUtterance(text);
|
148 |
speech.onend = callback;
|
149 |
window.speechSynthesis.speak(speech);
|
150 |
}
|
|
|
151 |
function askLoginOrRegister() {
|
152 |
-
|
153 |
-
speak(" Welcome to Biriyani Hub Are you a new customer or an existing customer? Say 'new' to register or 'existing' to login.", function () {
|
154 |
recognition.start();
|
155 |
recognition.onresult = function (event) {
|
156 |
let response = event.results[0][0].transcript.trim().toLowerCase();
|
@@ -167,6 +169,7 @@
|
|
167 |
};
|
168 |
});
|
169 |
}
|
|
|
170 |
function showRegistrationForm() {
|
171 |
document.getElementById('welcomePage').style.display = 'none';
|
172 |
document.getElementById('registrationForm').style.display = 'block';
|
@@ -174,6 +177,7 @@
|
|
174 |
document.getElementById('confirmationPage').style.display = 'none';
|
175 |
document.getElementById('statusMessage').style.display = 'none';
|
176 |
}
|
|
|
177 |
function showLoginForm() {
|
178 |
document.getElementById('welcomePage').style.display = 'none';
|
179 |
document.getElementById('registrationForm').style.display = 'none';
|
@@ -181,6 +185,7 @@
|
|
181 |
document.getElementById('confirmationPage').style.display = 'none';
|
182 |
document.getElementById('statusMessage').style.display = 'none';
|
183 |
}
|
|
|
184 |
function captureName() {
|
185 |
speak("Please say your name.", function () {
|
186 |
recognition.start();
|
@@ -194,6 +199,7 @@
|
|
194 |
};
|
195 |
});
|
196 |
}
|
|
|
197 |
function confirmName(nameCaptured) {
|
198 |
recognition.start();
|
199 |
recognition.onresult = function (event) {
|
@@ -206,6 +212,7 @@
|
|
206 |
}
|
207 |
};
|
208 |
}
|
|
|
209 |
function captureEmail() {
|
210 |
speak("Now, say your email.", function () {
|
211 |
recognition.start();
|
@@ -219,6 +226,7 @@
|
|
219 |
};
|
220 |
});
|
221 |
}
|
|
|
222 |
function confirmEmail(emailCaptured) {
|
223 |
recognition.start();
|
224 |
recognition.onresult = function (event) {
|
@@ -231,6 +239,7 @@
|
|
231 |
}
|
232 |
};
|
233 |
}
|
|
|
234 |
function captureMobile() {
|
235 |
speak("Now, say your mobile number.", function () {
|
236 |
recognition.start();
|
@@ -244,19 +253,20 @@
|
|
244 |
};
|
245 |
});
|
246 |
}
|
|
|
247 |
function confirmMobile(mobileCaptured) {
|
248 |
recognition.start();
|
249 |
recognition.onresult = function (event) {
|
250 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
251 |
recognition.stop();
|
252 |
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
253 |
-
// Show confirmation page with details
|
254 |
showConfirmationPage();
|
255 |
} else {
|
256 |
captureMobile();
|
257 |
}
|
258 |
};
|
259 |
}
|
|
|
260 |
function showConfirmationPage() {
|
261 |
const name = document.getElementById('name').value;
|
262 |
const email = document.getElementById('email').value;
|
@@ -264,9 +274,9 @@
|
|
264 |
document.getElementById('confirmName').textContent = name;
|
265 |
document.getElementById('confirmEmail').textContent = email;
|
266 |
document.getElementById('confirmPhone').textContent = phone;
|
267 |
-
|
268 |
-
setTimeout(submitRegistration, 6000); // 6 seconds delay
|
269 |
}
|
|
|
270 |
function submitRegistration() {
|
271 |
const name = document.getElementById('name').value;
|
272 |
const email = document.getElementById('email').value;
|
@@ -280,15 +290,14 @@
|
|
280 |
.then(response => response.json())
|
281 |
.then(data => {
|
282 |
if (data.success) {
|
283 |
-
document.getElementById('statusText').textContent = `
|
284 |
document.getElementById('statusMessage').style.display = 'block';
|
285 |
-
// Show 'Submitted Successfully' after 6 seconds, then refresh the page after 5 seconds
|
286 |
setTimeout(() => {
|
287 |
-
document.getElementById('statusText').textContent = '
|
288 |
setTimeout(() => {
|
289 |
window.location.reload(); // Refresh after 5 seconds
|
290 |
}, 5000);
|
291 |
-
},
|
292 |
} else {
|
293 |
document.getElementById('statusText').textContent = 'There was an error submitting your details. Please try again.';
|
294 |
document.getElementById('statusMessage').style.display = 'block';
|
@@ -299,6 +308,7 @@
|
|
299 |
document.getElementById('statusMessage').style.display = 'block';
|
300 |
});
|
301 |
}
|
|
|
302 |
function captureLoginDetails() {
|
303 |
speak("Please say your email for login.", function () {
|
304 |
recognition.start();
|
@@ -312,6 +322,7 @@
|
|
312 |
};
|
313 |
});
|
314 |
}
|
|
|
315 |
function confirmLoginEmail(emailCaptured) {
|
316 |
recognition.start();
|
317 |
recognition.onresult = function (event) {
|
@@ -324,6 +335,7 @@
|
|
324 |
}
|
325 |
};
|
326 |
}
|
|
|
327 |
function captureLoginMobile() {
|
328 |
speak("Now, say your mobile number.", function () {
|
329 |
recognition.start();
|
@@ -337,6 +349,7 @@
|
|
337 |
};
|
338 |
});
|
339 |
}
|
|
|
340 |
function confirmLoginMobile(mobileCaptured) {
|
341 |
recognition.start();
|
342 |
recognition.onresult = function (event) {
|
@@ -349,6 +362,7 @@
|
|
349 |
}
|
350 |
};
|
351 |
}
|
|
|
352 |
function submitLogin() {
|
353 |
const loginEmail = document.getElementById('loginEmail').value;
|
354 |
const loginMobile = document.getElementById('loginMobile').value;
|
@@ -363,6 +377,7 @@
|
|
363 |
speak("Please enter valid login details.");
|
364 |
}
|
365 |
}
|
|
|
366 |
window.onload = function () {
|
367 |
askLoginOrRegister();
|
368 |
};
|
|
|
88 |
<!-- Welcome Page -->
|
89 |
<div class="container" id="welcomePage">
|
90 |
<h1>Welcome to Biriyani Hub 🍽</h1>
|
91 |
+
<h2 class="info" id="infoMessage">Welcome! Are you a new customer or an existing one?</h2>
|
92 |
<p class="status" id="status">🔊 Please say 'new' to register or 'existing' to login.</p>
|
93 |
</div>
|
94 |
|
|
|
127 |
<p class="details"><strong>Email:</strong> <span id="confirmEmail"></span></p>
|
128 |
<p class="details"><strong>Phone:</strong> <span id="confirmPhone"></span></p>
|
129 |
</div>
|
130 |
+
<button class="confirm-button" onclick="submitRegistration()">Confirm & Submit</button>
|
131 |
</div>
|
132 |
|
133 |
<div id="statusMessage" style="display: none;">
|
|
|
144 |
} else {
|
145 |
alert("Speech Recognition API is not supported in this browser.");
|
146 |
}
|
147 |
+
|
148 |
function speak(text, callback) {
|
149 |
const speech = new SpeechSynthesisUtterance(text);
|
150 |
speech.onend = callback;
|
151 |
window.speechSynthesis.speak(speech);
|
152 |
}
|
153 |
+
|
154 |
function askLoginOrRegister() {
|
155 |
+
speak("Are you a new customer or an existing customer? Say 'new' to register or 'existing' to login.", function () {
|
|
|
156 |
recognition.start();
|
157 |
recognition.onresult = function (event) {
|
158 |
let response = event.results[0][0].transcript.trim().toLowerCase();
|
|
|
169 |
};
|
170 |
});
|
171 |
}
|
172 |
+
|
173 |
function showRegistrationForm() {
|
174 |
document.getElementById('welcomePage').style.display = 'none';
|
175 |
document.getElementById('registrationForm').style.display = 'block';
|
|
|
177 |
document.getElementById('confirmationPage').style.display = 'none';
|
178 |
document.getElementById('statusMessage').style.display = 'none';
|
179 |
}
|
180 |
+
|
181 |
function showLoginForm() {
|
182 |
document.getElementById('welcomePage').style.display = 'none';
|
183 |
document.getElementById('registrationForm').style.display = 'none';
|
|
|
185 |
document.getElementById('confirmationPage').style.display = 'none';
|
186 |
document.getElementById('statusMessage').style.display = 'none';
|
187 |
}
|
188 |
+
|
189 |
function captureName() {
|
190 |
speak("Please say your name.", function () {
|
191 |
recognition.start();
|
|
|
199 |
};
|
200 |
});
|
201 |
}
|
202 |
+
|
203 |
function confirmName(nameCaptured) {
|
204 |
recognition.start();
|
205 |
recognition.onresult = function (event) {
|
|
|
212 |
}
|
213 |
};
|
214 |
}
|
215 |
+
|
216 |
function captureEmail() {
|
217 |
speak("Now, say your email.", function () {
|
218 |
recognition.start();
|
|
|
226 |
};
|
227 |
});
|
228 |
}
|
229 |
+
|
230 |
function confirmEmail(emailCaptured) {
|
231 |
recognition.start();
|
232 |
recognition.onresult = function (event) {
|
|
|
239 |
}
|
240 |
};
|
241 |
}
|
242 |
+
|
243 |
function captureMobile() {
|
244 |
speak("Now, say your mobile number.", function () {
|
245 |
recognition.start();
|
|
|
253 |
};
|
254 |
});
|
255 |
}
|
256 |
+
|
257 |
function confirmMobile(mobileCaptured) {
|
258 |
recognition.start();
|
259 |
recognition.onresult = function (event) {
|
260 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
261 |
recognition.stop();
|
262 |
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
|
|
263 |
showConfirmationPage();
|
264 |
} else {
|
265 |
captureMobile();
|
266 |
}
|
267 |
};
|
268 |
}
|
269 |
+
|
270 |
function showConfirmationPage() {
|
271 |
const name = document.getElementById('name').value;
|
272 |
const email = document.getElementById('email').value;
|
|
|
274 |
document.getElementById('confirmName').textContent = name;
|
275 |
document.getElementById('confirmEmail').textContent = email;
|
276 |
document.getElementById('confirmPhone').textContent = phone;
|
277 |
+
document.getElementById('confirmationPage').style.display = 'block';
|
|
|
278 |
}
|
279 |
+
|
280 |
function submitRegistration() {
|
281 |
const name = document.getElementById('name').value;
|
282 |
const email = document.getElementById('email').value;
|
|
|
290 |
.then(response => response.json())
|
291 |
.then(data => {
|
292 |
if (data.success) {
|
293 |
+
document.getElementById('statusText').textContent = `Hi ${name}, successfully registered!`;
|
294 |
document.getElementById('statusMessage').style.display = 'block';
|
|
|
295 |
setTimeout(() => {
|
296 |
+
document.getElementById('statusText').textContent = 'Thank you for registering!';
|
297 |
setTimeout(() => {
|
298 |
window.location.reload(); // Refresh after 5 seconds
|
299 |
}, 5000);
|
300 |
+
}, 5000);
|
301 |
} else {
|
302 |
document.getElementById('statusText').textContent = 'There was an error submitting your details. Please try again.';
|
303 |
document.getElementById('statusMessage').style.display = 'block';
|
|
|
308 |
document.getElementById('statusMessage').style.display = 'block';
|
309 |
});
|
310 |
}
|
311 |
+
|
312 |
function captureLoginDetails() {
|
313 |
speak("Please say your email for login.", function () {
|
314 |
recognition.start();
|
|
|
322 |
};
|
323 |
});
|
324 |
}
|
325 |
+
|
326 |
function confirmLoginEmail(emailCaptured) {
|
327 |
recognition.start();
|
328 |
recognition.onresult = function (event) {
|
|
|
335 |
}
|
336 |
};
|
337 |
}
|
338 |
+
|
339 |
function captureLoginMobile() {
|
340 |
speak("Now, say your mobile number.", function () {
|
341 |
recognition.start();
|
|
|
349 |
};
|
350 |
});
|
351 |
}
|
352 |
+
|
353 |
function confirmLoginMobile(mobileCaptured) {
|
354 |
recognition.start();
|
355 |
recognition.onresult = function (event) {
|
|
|
362 |
}
|
363 |
};
|
364 |
}
|
365 |
+
|
366 |
function submitLogin() {
|
367 |
const loginEmail = document.getElementById('loginEmail').value;
|
368 |
const loginMobile = document.getElementById('loginMobile').value;
|
|
|
377 |
speak("Please enter valid login details.");
|
378 |
}
|
379 |
}
|
380 |
+
|
381 |
window.onload = function () {
|
382 |
askLoginOrRegister();
|
383 |
};
|