lokesh341 commited on
Commit
3afd166
·
verified ·
1 Parent(s): 1fa20ea

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +27 -12
templates/index.html CHANGED
@@ -234,7 +234,7 @@
234
  let confirmation = event.results[0][0].transcript.trim().toLowerCase();
235
  recognition.stop();
236
  if (confirmation.includes("yes") || confirmation.includes("ok")) {
237
- // Automatically submit details
238
  submitRegistration();
239
  } else {
240
  captureMobile();
@@ -247,19 +247,34 @@
247
  const email = document.getElementById('email').value;
248
  const phone = document.getElementById('mobile').value;
249
 
250
- // Simulate submission to Salesforce
251
- setTimeout(() => {
252
- document.getElementById('statusText').textContent = `Thank you for registering, ${name}!`;
253
- document.getElementById('statusMessage').style.display = 'block';
 
 
 
 
 
 
 
254
 
255
- // After 6 seconds, show "Submitted Successfully" and refresh the page after 5 seconds
256
- setTimeout(() => {
257
- document.getElementById('statusText').textContent = 'Submitted Successfully!';
258
  setTimeout(() => {
259
- window.location.reload(); // Refresh after 5 seconds
260
- }, 5000);
261
- }, 6000);
262
- }, 1000);
 
 
 
 
 
 
 
 
 
 
263
  }
264
 
265
  function captureLoginDetails() {
 
234
  let confirmation = event.results[0][0].transcript.trim().toLowerCase();
235
  recognition.stop();
236
  if (confirmation.includes("yes") || confirmation.includes("ok")) {
237
+ // Automatically submit details to Salesforce after confirmation
238
  submitRegistration();
239
  } else {
240
  captureMobile();
 
247
  const email = document.getElementById('email').value;
248
  const phone = document.getElementById('mobile').value;
249
 
250
+ // Make a POST request to Salesforce (simulated)
251
+ fetch('/submit', {
252
+ method: 'POST',
253
+ headers: { 'Content-Type': 'application/json' },
254
+ body: JSON.stringify({ name, email, phone })
255
+ })
256
+ .then(response => response.json())
257
+ .then(data => {
258
+ if (data.success) {
259
+ document.getElementById('statusText').textContent = `Thank you for registering, ${name}!`;
260
+ document.getElementById('statusMessage').style.display = 'block';
261
 
262
+ // Show 'Submitted Successfully' after 6 seconds, then refresh the page after 5 seconds
 
 
263
  setTimeout(() => {
264
+ document.getElementById('statusText').textContent = 'Submitted Successfully!';
265
+ setTimeout(() => {
266
+ window.location.reload(); // Refresh after 5 seconds
267
+ }, 5000);
268
+ }, 6000);
269
+ } else {
270
+ document.getElementById('statusText').textContent = 'There was an error submitting your details. Please try again.';
271
+ document.getElementById('statusMessage').style.display = 'block';
272
+ }
273
+ })
274
+ .catch(error => {
275
+ document.getElementById('statusText').textContent = 'An error occurred. Please try again.';
276
+ document.getElementById('statusMessage').style.display = 'block';
277
+ });
278
  }
279
 
280
  function captureLoginDetails() {