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