lokesh341 commited on
Commit
9e11fb3
·
verified ·
1 Parent(s): 20aff3f

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +1 -84
templates/index.html CHANGED
@@ -275,7 +275,7 @@
275
  setTimeout(() => {
276
  // Refresh the page after 10 seconds
277
  window.location.reload();
278
- }, 5000);
279
  }, 6000);
280
  }
281
  } else {
@@ -300,89 +300,6 @@
300
  });
301
  }
302
 
303
- function captureLoginDetails() {
304
- speak("Please say your email for login.", function () {
305
- recognition.start();
306
- recognition.onresult = function (event) {
307
- let emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
308
- document.getElementById('loginEmail').value = emailCaptured;
309
- recognition.stop();
310
- speak("You said " + emailCaptured + ". Is it correct?", function () {
311
- confirmLoginEmail(emailCaptured);
312
- });
313
- };
314
- });
315
- }
316
-
317
- function confirmLoginEmail(emailCaptured) {
318
- recognition.start();
319
- recognition.onresult = function (event) {
320
- let confirmation = event.results[0][0].transcript.trim().toLowerCase();
321
- recognition.stop();
322
- if (isConfirmation(confirmation)) {
323
- captureLoginMobile();
324
- } else {
325
- captureLoginDetails();
326
- }
327
- };
328
- }
329
-
330
- function captureLoginMobile() {
331
- speak("Now, say your mobile number.", function () {
332
- recognition.start();
333
- recognition.onresult = function (event) {
334
- let mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
335
- document.getElementById('loginMobile').value = mobileCaptured;
336
- recognition.stop();
337
- speak("You said " + mobileCaptured + ". Is it correct?", function () {
338
- confirmLoginMobile(mobileCaptured);
339
- });
340
- };
341
- });
342
- }
343
-
344
- function confirmLoginMobile(mobileCaptured) {
345
- recognition.start();
346
- recognition.onresult = function (event) {
347
- let confirmation = event.results[0][0].transcript.trim().toLowerCase();
348
- recognition.stop();
349
- if (isConfirmation(confirmation)) {
350
- submitLogin();
351
- } else {
352
- captureLoginMobile();
353
- }
354
- };
355
- }
356
-
357
- function submitLogin() {
358
- const loginEmail = document.getElementById('loginEmail').value;
359
- const loginMobile = document.getElementById('loginMobile').value;
360
- // Simulate login check by querying Salesforce
361
- if (loginEmail && loginMobile) {
362
- fetch('/validate-login', {
363
- method: 'POST',
364
- headers: { 'Content-Type': 'application/json' },
365
- body: JSON.stringify({ email: loginEmail, mobile: loginMobile })
366
- })
367
- .then(response => response.json())
368
- .then(data => {
369
- if (data.success) {
370
- const userName = data.name; // Retrieve the name from the response
371
- speak(`Welcome, ${userName}!`); // Speak the welcome message with the user's name
372
- window.location.href = '/menu'; // Redirect to menu after successful login
373
- } else {
374
- speak("Invalid login details. Please try again.");
375
- }
376
- })
377
- .catch(error => {
378
- console.error('Login validation failed:', error);
379
- alert("An error occurred. Please try again.");
380
- });
381
- } else {
382
- alert("Please provide both email and mobile number.");
383
- }
384
- }
385
-
386
  window.onload = function () {
387
  askLoginOrRegister();
388
  };
 
275
  setTimeout(() => {
276
  // Refresh the page after 10 seconds
277
  window.location.reload();
278
+ }, 10000); // Refreshes after 10 seconds
279
  }, 6000);
280
  }
281
  } else {
 
300
  });
301
  }
302
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  window.onload = function () {
304
  askLoginOrRegister();
305
  };