Subbu1304 commited on
Commit
bac4f03
·
verified ·
1 Parent(s): 2e36cf4

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +61 -43
templates/index.html CHANGED
@@ -170,51 +170,69 @@
170
  }
171
 
172
  function showRegistrationForm() {
173
- document.getElementById('registrationForm').style.display = 'block';
174
- document.getElementById('loginForm').style.display = 'none';
175
- speak("Please say your name to begin registration.", startListeningForName);
176
- }
177
-
178
- function startListeningForName() {
179
- recognition.start();
180
- recognition.onresult = function(event) {
181
- document.getElementById('name').value = event.results[0][0].transcript.trim();
182
- recognition.stop();
183
- autoConfirm();
184
- };
185
- }
186
-
187
- function autoConfirm() {
188
- document.getElementById('confirmName').textContent = document.getElementById('name').value;
189
- document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
190
- document.getElementById('confirmPhone').textContent = document.getElementById('mobile').value;
191
- document.getElementById('confirmation').style.display = 'block';
192
- setTimeout(autoSubmit, 3000);
193
- }
194
-
195
- function autoSubmit() {
196
- var name = document.getElementById('name').value;
197
- var email = document.getElementById('email').value;
198
- var phone = document.getElementById('mobile').value;
199
- fetch('/submit', {
200
- method: 'POST',
201
- headers: { 'Content-Type': 'application/json' },
202
- body: JSON.stringify({ name: name, email: email, phone: phone })
203
- })
204
- .then(response => response.json())
205
- .then(data => {
206
- if (data.success) {
207
- speak("Your registration is complete. Thank you for registering.");
208
- setTimeout(() => location.reload(), 5000);
209
- } else {
210
- speak("There was an error submitting your details. Please try again.");
211
- }
212
- });
 
 
 
 
 
 
 
 
 
 
 
213
  }
 
214
 
215
- window.onload = function () {
216
- askLoginOrRegister();
217
- };
 
 
 
 
 
 
218
  </script>
219
  </body>
220
  </html>
 
170
  }
171
 
172
  function showRegistrationForm() {
173
+ document.getElementById('registrationForm').style.display = 'block';
174
+ speak("Please say your name to begin registration.", startListeningForName);
175
+ }
176
+
177
+ // Function to start listening for the name
178
+ function startListeningForName() {
179
+ recognition.start();
180
+ recognition.onresult = function(event) {
181
+ const name = event.results[0][0].transcript.trim();
182
+ nameField.value = name;
183
+ recognition.stop();
184
+ listeningText.textContent = "Listening for your email...";
185
+ step++;
186
+ setTimeout(startListeningForEmail, 500); // Wait a moment before listening for email
187
+ };
188
+ }
189
+
190
+ // Function to start listening for the email
191
+ function startListeningForEmail() {
192
+ recognition.start();
193
+ recognition.onresult = function(event) {
194
+ const email = event.results[0][0].transcript.trim();
195
+ emailField.value = email;
196
+ recognition.stop();
197
+ listeningText.textContent = "Listening for your mobile number...";
198
+ step++;
199
+ setTimeout(startListeningForMobile, 500); // Wait a moment before listening for mobile
200
+ };
201
+ }
202
+
203
+ // Function to start listening for the mobile number
204
+ function startListeningForMobile() {
205
+ recognition.start();
206
+ recognition.onresult = function(event) {
207
+ const mobile = event.results[0][0].transcript.trim();
208
+ mobileField.value = mobile;
209
+ recognition.stop();
210
+ listeningText.textContent = "Almost done...";
211
+ submitBtn.disabled = false; // Enable the submit button
212
+ };
213
+ }
214
+
215
+ // Function to submit the form
216
+ submitBtn.addEventListener('click', function() {
217
+ const name = nameField.value;
218
+ const email = emailField.value;
219
+ const mobile = mobileField.value;
220
+
221
+ if (name && email && mobile) {
222
+ alert(`Registration successful for ${name}`);
223
+ // Here, you can send the registration data to the backend or Salesforce
224
  }
225
+ });
226
 
227
+ // Function to speak a message (for better user interaction)
228
+ function speak(message, callback) {
229
+ const msg = new SpeechSynthesisUtterance(message);
230
+ window.speechSynthesis.speak(msg);
231
+ msg.onend = callback;
232
+ }
233
+
234
+ // Start the process by showing the registration form
235
+ showRegistrationForm();
236
  </script>
237
  </body>
238
  </html>