lokesh341 commited on
Commit
5d4cae7
·
verified ·
1 Parent(s): 77ef342

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +4 -32
templates/index.html CHANGED
@@ -119,13 +119,11 @@
119
  } else {
120
  alert("Speech Recognition API is not supported in this browser.");
121
  }
122
-
123
  function speak(text, callback) {
124
  const speech = new SpeechSynthesisUtterance(text);
125
  speech.onend = callback;
126
  window.speechSynthesis.speak(speech);
127
  }
128
-
129
  function askLoginOrRegister() {
130
  speak("Welcome to Biryani Hub.Are you a new customer or an existing customer? Say 'new' to register or 'existing' to login.", function () {
131
  recognition.start();
@@ -144,13 +142,11 @@
144
  };
145
  });
146
  }
147
-
148
  function showRegistrationForm() {
149
  document.getElementById('welcomePage').style.display = 'none';
150
  document.getElementById('registrationForm').style.display = 'block';
151
  document.getElementById('loginForm').style.display = 'none';
152
  }
153
-
154
  function showLoginForm() {
155
  document.getElementById('welcomePage').style.display = 'none';
156
  document.getElementById('registrationForm').style.display = 'none';
@@ -169,7 +165,6 @@ function captureName() {
169
  };
170
  });
171
  }
172
-
173
  function confirmName(nameCaptured) {
174
  recognition.start();
175
  recognition.onresult = function (event) {
@@ -182,7 +177,6 @@ function confirmName(nameCaptured) {
182
  }
183
  };
184
  }
185
-
186
  function captureEmail() {
187
  speak("Now, say your email.", function () {
188
  recognition.start();
@@ -196,7 +190,6 @@ function captureEmail() {
196
  };
197
  });
198
  }
199
-
200
  function confirmEmail(emailCaptured) {
201
  recognition.start();
202
  recognition.onresult = function (event) {
@@ -209,7 +202,6 @@ function confirmEmail(emailCaptured) {
209
  }
210
  };
211
  }
212
-
213
  function captureMobile() {
214
  speak("Now, say your mobile number.", function () {
215
  recognition.start();
@@ -223,7 +215,6 @@ function captureMobile() {
223
  };
224
  });
225
  }
226
-
227
  function confirmMobile(mobileCaptured) {
228
  recognition.start();
229
  recognition.onresult = function (event) {
@@ -236,24 +227,19 @@ function confirmMobile(mobileCaptured) {
236
  }
237
  };
238
  }
239
-
240
  function isConfirmation(confirmation) {
241
  const validResponses = ["yes", "ok", "yeah", "correct", "yep"];
242
  return validResponses.some(response => confirmation.includes(response));
243
  }
244
-
245
  function submitRegistration() {
246
  const name = document.getElementById('name')?.value.trim();
247
  const email = document.getElementById('email')?.value.trim();
248
  const phone = document.getElementById('mobile')?.value.trim();
249
-
250
  if (!name || !email || !phone) {
251
  alert("Please provide all required details.");
252
  return;
253
  }
254
-
255
  console.log("Sending data:", { name, email, phone });
256
-
257
  fetch('/submit', {
258
  method: 'POST',
259
  headers: { 'Content-Type': 'application/json' },
@@ -263,12 +249,12 @@ function submitRegistration() {
263
  .then(data => {
264
  console.log("Response Data:", data);
265
  if (data.success) {
266
- speak(Thank you for registering, ${name}!);
267
  let statusText = document.getElementById('statusText');
268
  let statusMessage = document.getElementById('statusMessage');
269
 
270
  if (statusText && statusMessage) {
271
- statusText.textContent = Thank you for registering, ${name}!;
272
  statusMessage.style.display = 'block';
273
  setTimeout(() => {
274
  statusText.textContent = 'Submitted Successfully!';
@@ -281,7 +267,6 @@ function submitRegistration() {
281
  speak("There was an error submitting your details. Please try again.");
282
  let statusText = document.getElementById('statusText');
283
  let statusMessage = document.getElementById('statusMessage');
284
-
285
  if (statusText && statusMessage) {
286
  statusText.textContent = 'There was an error submitting your details. Please try again.';
287
  statusMessage.style.display = 'block';
@@ -293,16 +278,12 @@ function submitRegistration() {
293
  speak("An error occurred. Please try again.");
294
  let statusText = document.getElementById('statusText');
295
  let statusMessage = document.getElementById('statusMessage');
296
-
297
  if (statusText && statusMessage) {
298
  statusText.textContent = 'An error occurred. Please try again.';
299
  statusMessage.style.display = 'block';
300
  }
301
  });
302
  }
303
-
304
-
305
-
306
  function speak(message, callback) {
307
  const utterance = new SpeechSynthesisUtterance(message);
308
  utterance.onend = function () {
@@ -310,8 +291,6 @@ function speak(message, callback) {
310
  };
311
  window.speechSynthesis.speak(utterance);
312
  }
313
-
314
-
315
  function captureLoginDetails() {
316
  speak("Please say your email for login.", function () {
317
  recognition.start();
@@ -325,7 +304,6 @@ function speak(message, callback) {
325
  };
326
  });
327
  }
328
-
329
  function confirmLoginEmail(emailCaptured) {
330
  recognition.start();
331
  recognition.onresult = function (event) {
@@ -338,7 +316,6 @@ function speak(message, callback) {
338
  }
339
  };
340
  }
341
-
342
  function captureLoginMobile() {
343
  speak("Now, say your mobile number.", function () {
344
  recognition.start();
@@ -352,7 +329,6 @@ function speak(message, callback) {
352
  };
353
  });
354
  }
355
-
356
  function confirmLoginMobile(mobileCaptured) {
357
  recognition.start();
358
  recognition.onresult = function (event) {
@@ -365,11 +341,9 @@ function speak(message, callback) {
365
  }
366
  };
367
  }
368
-
369
  // function submitLogin() {
370
  // const loginEmail = document.getElementById('loginEmail').value;
371
  // const loginMobile = document.getElementById('loginMobile').value;
372
-
373
  // // Simulate login check
374
  // if (loginEmail && loginMobile) {
375
  // window.location.href = '/menu'; // Redirect to menu after successful login
@@ -380,7 +354,6 @@ function speak(message, callback) {
380
  function submitLogin() {
381
  const loginEmail = document.getElementById('loginEmail').value;
382
  const loginMobile = document.getElementById('loginMobile').value;
383
-
384
  // Simulate login check by querying Salesforce
385
  if (loginEmail && loginMobile) {
386
  fetch('/validate-login', {
@@ -392,7 +365,7 @@ function speak(message, callback) {
392
  .then(data => {
393
  if (data.success) {
394
  const userName = data.name; // Retrieve the name from the response
395
- speak(Welcome, ${userName}!); // Speak the welcome message with the user's name
396
  window.location.href = '/menu'; // Redirect to menu after successful login
397
  } else {
398
  // alert("Invalid login details. Please try again.");
@@ -407,10 +380,9 @@ function speak(message, callback) {
407
  alert("Please provide both email and mobile number.");
408
  }
409
  }
410
-
411
  window.onload = function () {
412
  askLoginOrRegister();
413
  };
414
  </script>
415
  </body>
416
- </html>
 
119
  } else {
120
  alert("Speech Recognition API is not supported in this browser.");
121
  }
 
122
  function speak(text, callback) {
123
  const speech = new SpeechSynthesisUtterance(text);
124
  speech.onend = callback;
125
  window.speechSynthesis.speak(speech);
126
  }
 
127
  function askLoginOrRegister() {
128
  speak("Welcome to Biryani Hub.Are you a new customer or an existing customer? Say 'new' to register or 'existing' to login.", function () {
129
  recognition.start();
 
142
  };
143
  });
144
  }
 
145
  function showRegistrationForm() {
146
  document.getElementById('welcomePage').style.display = 'none';
147
  document.getElementById('registrationForm').style.display = 'block';
148
  document.getElementById('loginForm').style.display = 'none';
149
  }
 
150
  function showLoginForm() {
151
  document.getElementById('welcomePage').style.display = 'none';
152
  document.getElementById('registrationForm').style.display = 'none';
 
165
  };
166
  });
167
  }
 
168
  function confirmName(nameCaptured) {
169
  recognition.start();
170
  recognition.onresult = function (event) {
 
177
  }
178
  };
179
  }
 
180
  function captureEmail() {
181
  speak("Now, say your email.", function () {
182
  recognition.start();
 
190
  };
191
  });
192
  }
 
193
  function confirmEmail(emailCaptured) {
194
  recognition.start();
195
  recognition.onresult = function (event) {
 
202
  }
203
  };
204
  }
 
205
  function captureMobile() {
206
  speak("Now, say your mobile number.", function () {
207
  recognition.start();
 
215
  };
216
  });
217
  }
 
218
  function confirmMobile(mobileCaptured) {
219
  recognition.start();
220
  recognition.onresult = function (event) {
 
227
  }
228
  };
229
  }
 
230
  function isConfirmation(confirmation) {
231
  const validResponses = ["yes", "ok", "yeah", "correct", "yep"];
232
  return validResponses.some(response => confirmation.includes(response));
233
  }
 
234
  function submitRegistration() {
235
  const name = document.getElementById('name')?.value.trim();
236
  const email = document.getElementById('email')?.value.trim();
237
  const phone = document.getElementById('mobile')?.value.trim();
 
238
  if (!name || !email || !phone) {
239
  alert("Please provide all required details.");
240
  return;
241
  }
 
242
  console.log("Sending data:", { name, email, phone });
 
243
  fetch('/submit', {
244
  method: 'POST',
245
  headers: { 'Content-Type': 'application/json' },
 
249
  .then(data => {
250
  console.log("Response Data:", data);
251
  if (data.success) {
252
+ speak(`Thank you for registering, ${name}!`);
253
  let statusText = document.getElementById('statusText');
254
  let statusMessage = document.getElementById('statusMessage');
255
 
256
  if (statusText && statusMessage) {
257
+ statusText.textContent = `Thank you for registering, ${name}!`;
258
  statusMessage.style.display = 'block';
259
  setTimeout(() => {
260
  statusText.textContent = 'Submitted Successfully!';
 
267
  speak("There was an error submitting your details. Please try again.");
268
  let statusText = document.getElementById('statusText');
269
  let statusMessage = document.getElementById('statusMessage');
 
270
  if (statusText && statusMessage) {
271
  statusText.textContent = 'There was an error submitting your details. Please try again.';
272
  statusMessage.style.display = 'block';
 
278
  speak("An error occurred. Please try again.");
279
  let statusText = document.getElementById('statusText');
280
  let statusMessage = document.getElementById('statusMessage');
 
281
  if (statusText && statusMessage) {
282
  statusText.textContent = 'An error occurred. Please try again.';
283
  statusMessage.style.display = 'block';
284
  }
285
  });
286
  }
 
 
 
287
  function speak(message, callback) {
288
  const utterance = new SpeechSynthesisUtterance(message);
289
  utterance.onend = function () {
 
291
  };
292
  window.speechSynthesis.speak(utterance);
293
  }
 
 
294
  function captureLoginDetails() {
295
  speak("Please say your email for login.", function () {
296
  recognition.start();
 
304
  };
305
  });
306
  }
 
307
  function confirmLoginEmail(emailCaptured) {
308
  recognition.start();
309
  recognition.onresult = function (event) {
 
316
  }
317
  };
318
  }
 
319
  function captureLoginMobile() {
320
  speak("Now, say your mobile number.", function () {
321
  recognition.start();
 
329
  };
330
  });
331
  }
 
332
  function confirmLoginMobile(mobileCaptured) {
333
  recognition.start();
334
  recognition.onresult = function (event) {
 
341
  }
342
  };
343
  }
 
344
  // function submitLogin() {
345
  // const loginEmail = document.getElementById('loginEmail').value;
346
  // const loginMobile = document.getElementById('loginMobile').value;
 
347
  // // Simulate login check
348
  // if (loginEmail && loginMobile) {
349
  // window.location.href = '/menu'; // Redirect to menu after successful login
 
354
  function submitLogin() {
355
  const loginEmail = document.getElementById('loginEmail').value;
356
  const loginMobile = document.getElementById('loginMobile').value;
 
357
  // Simulate login check by querying Salesforce
358
  if (loginEmail && loginMobile) {
359
  fetch('/validate-login', {
 
365
  .then(data => {
366
  if (data.success) {
367
  const userName = data.name; // Retrieve the name from the response
368
+ speak(`Welcome, ${userName}!`); // Speak the welcome message with the user's name
369
  window.location.href = '/menu'; // Redirect to menu after successful login
370
  } else {
371
  // alert("Invalid login details. Please try again.");
 
380
  alert("Please provide both email and mobile number.");
381
  }
382
  }
 
383
  window.onload = function () {
384
  askLoginOrRegister();
385
  };
386
  </script>
387
  </body>
388
+ </html>