lokesh341 commited on
Commit
cb1645b
ยท
verified ยท
1 Parent(s): 32e020f

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +18 -47
templates/index.html CHANGED
@@ -22,8 +22,6 @@
22
  <label for="mobile">Your Mobile Number</label>
23
  <input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
24
 
25
- <button type="button" id="confirmBtn">Confirm</button>
26
-
27
  <p class="info" id="infoMessage">Listening ๐Ÿ—ฃ๐ŸŽ™๏ธ...</p>
28
  <p class="status" id="status">๐Ÿ”Š...</p>
29
  </div>
@@ -33,7 +31,6 @@
33
  <p><strong>Name:</strong> <span id="confirmName"></span></p>
34
  <p><strong>Email:</strong> <span id="confirmEmail"></span></p>
35
  <p><strong>Phone:</strong> <span id="confirmPhone"></span></p>
36
- <button type="button" id="submitBtn">Submit</button>
37
  </div>
38
 
39
  <script>
@@ -41,7 +38,6 @@
41
  let nameCaptured = "";
42
  let emailCaptured = "";
43
  let mobileCaptured = "";
44
-
45
  if ('webkitSpeechRecognition' in window) {
46
  recognition = new webkitSpeechRecognition();
47
  recognition.continuous = false;
@@ -50,13 +46,11 @@
50
  } else {
51
  alert("Speech Recognition API is not supported in this browser.");
52
  }
53
-
54
  function speak(text, callback) {
55
  const speech = new SpeechSynthesisUtterance(text);
56
  speech.onend = callback;
57
  window.speechSynthesis.speak(speech);
58
  }
59
-
60
  function startListeningForName() {
61
  recognition.start();
62
  recognition.onresult = function(event) {
@@ -66,7 +60,6 @@
66
  setTimeout(confirmName, 500);
67
  };
68
  }
69
-
70
  function confirmName() {
71
  speak("You said " + nameCaptured + ". Is it okay, or do you want to change it?", function() {
72
  recognition.start();
@@ -81,7 +74,6 @@
81
  };
82
  });
83
  }
84
-
85
  function startListeningForEmail() {
86
  recognition.start();
87
  recognition.onresult = function(event) {
@@ -102,7 +94,6 @@
102
  });
103
  };
104
  }
105
-
106
  function startListeningForMobile() {
107
  recognition.start();
108
  recognition.onresult = function(event) {
@@ -115,8 +106,9 @@
115
  let confirmation = event.results[0][0].transcript.trim().toLowerCase();
116
  recognition.stop();
117
  if (confirmation.includes("ok") || confirmation.includes("yes")) {
118
- speak("Your registration is complete. Thank you for registering.");
119
- setTimeout(() => location.reload(), 20000);
 
120
  } else {
121
  speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
122
  }
@@ -124,46 +116,20 @@
124
  });
125
  };
126
  }
127
-
128
- function startProcess() {
129
- speak("Welcome to Biryani Hub", function() {
130
- speak("Tell me your name, and I will confirm it with you.", function() {
131
- setTimeout(startListeningForName, 500);
132
- });
133
- });
134
- }
135
-
136
- window.onload = function () {
137
- setTimeout(startProcess, 4000);
138
- };
139
-
140
- // When the Confirm button is clicked
141
- document.getElementById('confirmBtn').addEventListener('click', function() {
142
- var name = document.getElementById('name').value;
143
- var email = document.getElementById('email').value;
144
- var phone = document.getElementById('mobile').value;
145
-
146
- // Show confirmation details
147
- document.getElementById('confirmName').textContent = name;
148
- document.getElementById('confirmEmail').textContent = email;
149
- document.getElementById('confirmPhone').textContent = phone;
150
-
151
- // Hide the form and show confirmation
152
  document.getElementById('confirmation').style.display = 'block';
153
- document.getElementById('confirmBtn').style.display = 'none';
154
- });
155
-
156
- // When the Submit button is clicked, send the data to the backend
157
- document.getElementById('submitBtn').addEventListener('click', function() {
158
  var name = document.getElementById('name').value;
159
  var email = document.getElementById('email').value;
160
  var phone = document.getElementById('mobile').value;
161
-
162
  fetch('/submit', {
163
  method: 'POST',
164
- headers: {
165
- 'Content-Type': 'application/json'
166
- },
167
  body: JSON.stringify({ name: name, email: email, phone: phone })
168
  })
169
  .then(response => response.json())
@@ -171,12 +137,17 @@
171
  if (data.success) {
172
  document.getElementById('status').textContent = 'Your details were submitted successfully!';
173
  document.getElementById('confirmation').style.display = 'none';
 
 
174
  } else {
175
  document.getElementById('status').textContent = 'There was an error submitting your details.';
 
176
  }
177
- document.getElementById('status').style.display = 'block';
178
  });
179
- });
 
 
 
180
  </script>
181
  </body>
182
  </html>
 
22
  <label for="mobile">Your Mobile Number</label>
23
  <input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
24
 
 
 
25
  <p class="info" id="infoMessage">Listening ๐Ÿ—ฃ๐ŸŽ™๏ธ...</p>
26
  <p class="status" id="status">๐Ÿ”Š...</p>
27
  </div>
 
31
  <p><strong>Name:</strong> <span id="confirmName"></span></p>
32
  <p><strong>Email:</strong> <span id="confirmEmail"></span></p>
33
  <p><strong>Phone:</strong> <span id="confirmPhone"></span></p>
 
34
  </div>
35
 
36
  <script>
 
38
  let nameCaptured = "";
39
  let emailCaptured = "";
40
  let mobileCaptured = "";
 
41
  if ('webkitSpeechRecognition' in window) {
42
  recognition = new webkitSpeechRecognition();
43
  recognition.continuous = false;
 
46
  } else {
47
  alert("Speech Recognition API is not supported in this browser.");
48
  }
 
49
  function speak(text, callback) {
50
  const speech = new SpeechSynthesisUtterance(text);
51
  speech.onend = callback;
52
  window.speechSynthesis.speak(speech);
53
  }
 
54
  function startListeningForName() {
55
  recognition.start();
56
  recognition.onresult = function(event) {
 
60
  setTimeout(confirmName, 500);
61
  };
62
  }
 
63
  function confirmName() {
64
  speak("You said " + nameCaptured + ". Is it okay, or do you want to change it?", function() {
65
  recognition.start();
 
74
  };
75
  });
76
  }
 
77
  function startListeningForEmail() {
78
  recognition.start();
79
  recognition.onresult = function(event) {
 
94
  });
95
  };
96
  }
 
97
  function startListeningForMobile() {
98
  recognition.start();
99
  recognition.onresult = function(event) {
 
106
  let confirmation = event.results[0][0].transcript.trim().toLowerCase();
107
  recognition.stop();
108
  if (confirmation.includes("ok") || confirmation.includes("yes")) {
109
+ speak("All details are captured. Confirming your registration.", function() {
110
+ autoConfirm();
111
+ });
112
  } else {
113
  speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
114
  }
 
116
  });
117
  };
118
  }
119
+ function autoConfirm() {
120
+ document.getElementById('confirmName').textContent = document.getElementById('name').value;
121
+ document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
122
+ document.getElementById('confirmPhone').textContent = document.getElementById('mobile').value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  document.getElementById('confirmation').style.display = 'block';
124
+ setTimeout(autoSubmit, 3000);
125
+ }
126
+ function autoSubmit() {
 
 
127
  var name = document.getElementById('name').value;
128
  var email = document.getElementById('email').value;
129
  var phone = document.getElementById('mobile').value;
 
130
  fetch('/submit', {
131
  method: 'POST',
132
+ headers: { 'Content-Type': 'application/json' },
 
 
133
  body: JSON.stringify({ name: name, email: email, phone: phone })
134
  })
135
  .then(response => response.json())
 
137
  if (data.success) {
138
  document.getElementById('status').textContent = 'Your details were submitted successfully!';
139
  document.getElementById('confirmation').style.display = 'none';
140
+ speak("Your registration is complete. Thank you for registering.");
141
+ setTimeout(() => location.reload(), 5000);
142
  } else {
143
  document.getElementById('status').textContent = 'There was an error submitting your details.';
144
+ speak("There was an error submitting your details. Please try again.");
145
  }
 
146
  });
147
+ }
148
+ window.onload = function () {
149
+ setTimeout(startProcess, 4000);
150
+ };
151
  </script>
152
  </body>
153
  </html>