lokesh341 commited on
Commit
bd009ae
·
verified ·
1 Parent(s): 8eee015

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +29 -49
templates/index.html CHANGED
@@ -228,65 +228,45 @@
228
  let confirmation = event.results[0][0].transcript.trim().toLowerCase();
229
  recognition.stop();
230
  if (confirmation.includes("yes") || confirmation.includes("ok")) {
231
- speak("Registration complete!");
 
232
  } else {
233
  captureMobile();
234
  }
235
  };
236
  }
237
 
238
- function captureLoginEmail() {
239
- speak("Please say your email for login.", function () {
240
- recognition.start();
241
- recognition.onresult = function (event) {
242
- let emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
243
- document.getElementById('loginEmail').value = emailCaptured;
244
- recognition.stop();
245
- speak("You said " + emailCaptured + ". Is it correct?", function () {
246
- confirmLoginEmail(emailCaptured);
247
- });
248
- };
249
- });
250
- }
251
-
252
- function confirmLoginEmail(emailCaptured) {
253
- recognition.start();
254
- recognition.onresult = function (event) {
255
- let confirmation = event.results[0][0].transcript.trim().toLowerCase();
256
- recognition.stop();
257
- if (confirmation.includes("yes") || confirmation.includes("ok")) {
258
- captureLoginMobile();
259
- } else {
260
- captureLoginEmail();
261
- }
262
- };
263
- }
264
 
265
- function captureLoginMobile() {
266
- speak("Now, say your mobile number.", function () {
267
- recognition.start();
268
- recognition.onresult = function (event) {
269
- let mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
270
- document.getElementById('loginMobile').value = mobileCaptured;
271
- recognition.stop();
272
- speak("You said " + mobileCaptured + ". Is it correct?", function () {
273
- confirmLoginMobile(mobileCaptured);
274
- });
275
- };
276
- });
277
- }
278
 
279
- function confirmLoginMobile(mobileCaptured) {
280
- recognition.start();
281
- recognition.onresult = function (event) {
282
- let confirmation = event.results[0][0].transcript.trim().toLowerCase();
283
- recognition.stop();
284
- if (confirmation.includes("yes") || confirmation.includes("ok")) {
285
- speak("Login successful!");
 
 
 
 
 
 
 
286
  } else {
287
- captureLoginMobile();
288
  }
289
- };
 
 
 
 
290
  }
291
 
292
  window.onload = function () {
 
228
  let confirmation = event.results[0][0].transcript.trim().toLowerCase();
229
  recognition.stop();
230
  if (confirmation.includes("yes") || confirmation.includes("ok")) {
231
+ // Confirmation successful, submit the details
232
+ confirmDetailsAndSubmit();
233
  } else {
234
  captureMobile();
235
  }
236
  };
237
  }
238
 
239
+ // Confirm details and automatically submit to the backend
240
+ function confirmDetailsAndSubmit() {
241
+ // Display confirmed details
242
+ const name = document.getElementById('name').value;
243
+ const email = document.getElementById('email').value;
244
+ const phone = document.getElementById('mobile').value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
 
246
+ speak(`Confirming details: Name: ${name}, Email: ${email}, Phone: ${phone}. Submitting now.`);
 
 
 
 
 
 
 
 
 
 
 
 
247
 
248
+ // Send the confirmed details to the backend for Salesforce submission
249
+ fetch('/submit', {
250
+ method: 'POST',
251
+ headers: { 'Content-Type': 'application/json' },
252
+ body: JSON.stringify({
253
+ name: name,
254
+ email: email,
255
+ phone: phone
256
+ })
257
+ })
258
+ .then(response => response.json())
259
+ .then(data => {
260
+ if (data.success) {
261
+ speak("Your details have been successfully submitted. Thank you!");
262
  } else {
263
+ speak("There was an error submitting your details. Please try again.");
264
  }
265
+ })
266
+ .catch(error => {
267
+ console.error('Error:', error);
268
+ speak("An error occurred while submitting the details.");
269
+ });
270
  }
271
 
272
  window.onload = function () {