Subbu1304 commited on
Commit
0023f40
·
verified ·
1 Parent(s): bac4f03

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +59 -60
templates/index.html CHANGED
@@ -170,69 +170,68 @@
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>
 
 
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
+ let nameField = document.getElementById('name');
178
+ let emailField = document.getElementById('email');
179
+ let mobileField = document.getElementById('mobile');
180
+ let infoMessage = document.getElementById('infoMessage');
181
+
182
+ function startListeningForName() {
183
+ recognition.start();
184
+ recognition.onresult = function(event) {
185
+ const name = event.results[0][0].transcript.trim();
186
+ nameField.value = name;
187
+ recognition.stop();
188
+ infoMessage.textContent = "Listening for your email...";
189
+ setTimeout(startListeningForEmail, 500); // Wait a moment before listening for email
190
+ };
191
+ }
192
+
193
+ function startListeningForEmail() {
194
+ recognition.start();
195
+ recognition.onresult = function(event) {
196
+ const email = event.results[0][0].transcript.trim();
197
+ emailField.value = email;
198
+ recognition.stop();
199
+ infoMessage.textContent = "Listening for your mobile number...";
200
+ setTimeout(startListeningForMobile, 500); // Wait a moment before listening for mobile
201
+ };
202
+ }
203
+
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
+ infoMessage.textContent = "Almost done...";
211
+ showConfirmation();
212
+ };
213
+ }
214
+
215
+ function showConfirmation() {
216
+ document.getElementById('confirmName').textContent = nameField.value;
217
+ document.getElementById('confirmEmail').textContent = emailField.value;
218
+ document.getElementById('confirmPhone').textContent = mobileField.value;
219
+ document.getElementById('confirmation').style.display = 'block';
220
+ }
221
+
222
+ function autoSubmit() {
223
+ const name = nameField.value;
224
+ const email = emailField.value;
225
+ const phone = mobileField.value;
226
+ // You can submit this data to your backend or Salesforce here
227
  alert(`Registration successful for ${name}`);
228
+ // For demo purposes, reload the page after 5 seconds
229
+ setTimeout(() => location.reload(), 5000);
230
  }
 
231
 
232
+ // Start the process by asking for registration or login
233
+ window.onload = askLoginOrRegister;
 
 
 
 
 
 
 
234
  </script>
235
  </body>
236
  </html>
237
+