Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +54 -5
templates/index.html
CHANGED
|
@@ -175,7 +175,7 @@
|
|
| 175 |
recognition.onresult = function (event) {
|
| 176 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
| 177 |
recognition.stop();
|
| 178 |
-
if (
|
| 179 |
captureEmail();
|
| 180 |
} else {
|
| 181 |
captureName();
|
|
@@ -202,7 +202,7 @@
|
|
| 202 |
recognition.onresult = function (event) {
|
| 203 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
| 204 |
recognition.stop();
|
| 205 |
-
if (
|
| 206 |
captureMobile();
|
| 207 |
} else {
|
| 208 |
captureEmail();
|
|
@@ -229,7 +229,7 @@
|
|
| 229 |
recognition.onresult = function (event) {
|
| 230 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
| 231 |
recognition.stop();
|
| 232 |
-
if (
|
| 233 |
submitRegistration();
|
| 234 |
} else {
|
| 235 |
captureMobile();
|
|
@@ -237,6 +237,11 @@
|
|
| 237 |
};
|
| 238 |
}
|
| 239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
function submitRegistration() {
|
| 241 |
const name = document.getElementById('name').value;
|
| 242 |
const email = document.getElementById('email').value;
|
|
@@ -276,7 +281,7 @@
|
|
| 276 |
recognition.onresult = function (event) {
|
| 277 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
| 278 |
recognition.stop();
|
| 279 |
-
if (
|
| 280 |
captureLoginMobile();
|
| 281 |
} else {
|
| 282 |
captureLoginDetails();
|
|
@@ -284,4 +289,48 @@
|
|
| 284 |
};
|
| 285 |
}
|
| 286 |
|
| 287 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
recognition.onresult = function (event) {
|
| 176 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
| 177 |
recognition.stop();
|
| 178 |
+
if (isConfirmation(confirmation)) {
|
| 179 |
captureEmail();
|
| 180 |
} else {
|
| 181 |
captureName();
|
|
|
|
| 202 |
recognition.onresult = function (event) {
|
| 203 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
| 204 |
recognition.stop();
|
| 205 |
+
if (isConfirmation(confirmation)) {
|
| 206 |
captureMobile();
|
| 207 |
} else {
|
| 208 |
captureEmail();
|
|
|
|
| 229 |
recognition.onresult = function (event) {
|
| 230 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
| 231 |
recognition.stop();
|
| 232 |
+
if (isConfirmation(confirmation)) {
|
| 233 |
submitRegistration();
|
| 234 |
} else {
|
| 235 |
captureMobile();
|
|
|
|
| 237 |
};
|
| 238 |
}
|
| 239 |
|
| 240 |
+
function isConfirmation(confirmation) {
|
| 241 |
+
const validResponses = ["yes", "ok", "yeah", "correct", "yep"];
|
| 242 |
+
return validResponses.some(response => confirmation.includes(response));
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
function submitRegistration() {
|
| 246 |
const name = document.getElementById('name').value;
|
| 247 |
const email = document.getElementById('email').value;
|
|
|
|
| 281 |
recognition.onresult = function (event) {
|
| 282 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
| 283 |
recognition.stop();
|
| 284 |
+
if (isConfirmation(confirmation)) {
|
| 285 |
captureLoginMobile();
|
| 286 |
} else {
|
| 287 |
captureLoginDetails();
|
|
|
|
| 289 |
};
|
| 290 |
}
|
| 291 |
|
| 292 |
+
function captureLoginMobile() {
|
| 293 |
+
speak("Now, say your mobile number.", function () {
|
| 294 |
+
recognition.start();
|
| 295 |
+
recognition.onresult = function (event) {
|
| 296 |
+
let mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
| 297 |
+
document.getElementById('loginMobile').value = mobileCaptured;
|
| 298 |
+
recognition.stop();
|
| 299 |
+
speak("You said " + mobileCaptured + ". Is it correct?", function () {
|
| 300 |
+
confirmLoginMobile(mobileCaptured);
|
| 301 |
+
});
|
| 302 |
+
};
|
| 303 |
+
});
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
function confirmLoginMobile(mobileCaptured) {
|
| 307 |
+
recognition.start();
|
| 308 |
+
recognition.onresult = function (event) {
|
| 309 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
| 310 |
+
recognition.stop();
|
| 311 |
+
if (isConfirmation(confirmation)) {
|
| 312 |
+
submitLogin();
|
| 313 |
+
} else {
|
| 314 |
+
captureLoginMobile();
|
| 315 |
+
}
|
| 316 |
+
};
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
function submitLogin() {
|
| 320 |
+
const loginEmail = document.getElementById('loginEmail').value;
|
| 321 |
+
const loginMobile = document.getElementById('loginMobile').value;
|
| 322 |
+
|
| 323 |
+
// Simulate login check
|
| 324 |
+
if (loginEmail && loginMobile) {
|
| 325 |
+
window.location.href = '/menu'; // Redirect to menu after successful login
|
| 326 |
+
} else {
|
| 327 |
+
alert("Invalid login details. Please try again.");
|
| 328 |
+
}
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
window.onload = function () {
|
| 332 |
+
askLoginOrRegister();
|
| 333 |
+
};
|
| 334 |
+
</script>
|
| 335 |
+
</body>
|
| 336 |
+
</html>
|