Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +73 -3
templates/index.html
CHANGED
@@ -198,7 +198,7 @@
|
|
198 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
199 |
recognition.stop();
|
200 |
if (confirmation.includes("ok") || confirmation.includes("yes")) {
|
201 |
-
speak("Great! Now tell your mobile number.", startListeningForMobileLogin);
|
202 |
} else {
|
203 |
speak("Let's try again. Please tell your email.", startListeningForLogin);
|
204 |
}
|
@@ -219,7 +219,7 @@
|
|
219 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
220 |
recognition.stop();
|
221 |
if (confirmation.includes("ok") || confirmation.includes("yes")) {
|
222 |
-
speak("Login successful!");
|
223 |
} else {
|
224 |
speak("Let's try again. Please tell your mobile number.", startListeningForMobileLogin);
|
225 |
}
|
@@ -257,8 +257,78 @@
|
|
257 |
function startListeningForEmail() {
|
258 |
recognition.start();
|
259 |
recognition.onresult = function(event) {
|
260 |
-
let emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
199 |
recognition.stop();
|
200 |
if (confirmation.includes("ok") || confirmation.includes("yes")) {
|
201 |
+
speak("Great! Now tell your mobile number.", startListeningForMobileLogin);
|
202 |
} else {
|
203 |
speak("Let's try again. Please tell your email.", startListeningForLogin);
|
204 |
}
|
|
|
219 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
220 |
recognition.stop();
|
221 |
if (confirmation.includes("ok") || confirmation.includes("yes")) {
|
222 |
+
speak("Great! Login successful!"); // Login success confirmation
|
223 |
} else {
|
224 |
speak("Let's try again. Please tell your mobile number.", startListeningForMobileLogin);
|
225 |
}
|
|
|
257 |
function startListeningForEmail() {
|
258 |
recognition.start();
|
259 |
recognition.onresult = function(event) {
|
260 |
+
let emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
261 |
+
document.getElementById('email').value = emailCaptured;
|
262 |
+
recognition.stop();
|
263 |
+
speak("You said " + emailCaptured + ". Is it correct?", function() {
|
264 |
+
recognition.start();
|
265 |
+
recognition.onresult = function(event) {
|
266 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
267 |
+
recognition.stop();
|
268 |
+
if (confirmation.includes("ok") || confirmation.includes("yes")) {
|
269 |
+
setTimeout(() => speak("Great! Now, tell me your mobile number.", startListeningForMobile), 500);
|
270 |
+
} else {
|
271 |
+
speak("Let's try again. Tell me your email.", startListeningForEmail);
|
272 |
+
}
|
273 |
+
};
|
274 |
+
});
|
275 |
+
};
|
276 |
+
}
|
277 |
|
278 |
+
function startListeningForMobile() {
|
279 |
+
recognition.start();
|
280 |
+
recognition.onresult = function(event) {
|
281 |
+
let mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
282 |
+
document.getElementById('mobile').value = mobileCaptured;
|
283 |
+
recognition.stop();
|
284 |
+
speak("You said " + mobileCaptured + ". Is it correct?", function() {
|
285 |
+
recognition.start();
|
286 |
+
recognition.onresult = function(event) {
|
287 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
288 |
+
recognition.stop();
|
289 |
+
if (confirmation.includes("ok") || confirmation.includes("yes")) {
|
290 |
+
speak("Login successful!"); // After confirming mobile number
|
291 |
+
} else {
|
292 |
+
speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
|
293 |
+
}
|
294 |
+
};
|
295 |
+
});
|
296 |
+
};
|
297 |
+
}
|
298 |
|
299 |
+
function autoConfirm() {
|
300 |
+
document.getElementById('confirmName').textContent = document.getElementById('name').value;
|
301 |
+
document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
|
302 |
+
document.getElementById('confirmPhone').textContent = document.getElementById('mobile').value;
|
303 |
+
document.getElementById('confirmation').style.display = 'block';
|
304 |
+
}
|
305 |
|
306 |
+
function autoSubmit() {
|
307 |
+
var name = document.getElementById('name').value;
|
308 |
+
var email = document.getElementById('email').value;
|
309 |
+
var phone = document.getElementById('mobile').value;
|
310 |
+
fetch('/submit', {
|
311 |
+
method: 'POST',
|
312 |
+
headers: { 'Content-Type': 'application/json' },
|
313 |
+
body: JSON.stringify({ name: name, email: email, phone: phone })
|
314 |
+
})
|
315 |
+
.then(response => response.json())
|
316 |
+
.then(data => {
|
317 |
+
if (data.success) {
|
318 |
+
document.getElementById('status').textContent = 'Your details were submitted successfully!';
|
319 |
+
document.getElementById('confirmation').style.display = 'none';
|
320 |
+
speak("Your registration is complete. Thank you for registering.");
|
321 |
+
setTimeout(() => location.reload(), 5000);
|
322 |
+
} else {
|
323 |
+
document.getElementById('status').textContent = 'There was an error submitting your details.';
|
324 |
+
speak("There was an error submitting your details. Please try again.");
|
325 |
+
}
|
326 |
+
});
|
327 |
+
}
|
328 |
|
329 |
+
window.onload = function () {
|
330 |
+
askLoginOrRegister(); // First, ask the user whether they are a new or existing user
|
331 |
+
};
|
332 |
+
</script>
|
333 |
+
</body>
|
334 |
+
</html>
|