lokesh341 commited on
Commit
96e9e1d
·
verified ·
1 Parent(s): fe03a0b

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +25 -24
templates/index.html CHANGED
@@ -76,7 +76,6 @@
76
 
77
  <script>
78
  let recognition;
79
- let isListening = false;
80
  let isNameCaptured = false;
81
  let isEmailCaptured = false;
82
 
@@ -102,10 +101,18 @@
102
  recognition.start();
103
  recognition.onresult = function(event) {
104
  const transcript = event.results[0][0].transcript.trim();
105
- nameInput.value = transcript;
106
- recognition.stop();
107
- // Now, prompt for email
108
- speak("Tell me your email", startListeningForEmail);
 
 
 
 
 
 
 
 
109
  };
110
  }
111
 
@@ -115,26 +122,20 @@
115
  status.textContent = "Listening for your email...";
116
  recognition.start();
117
  recognition.onresult = function(event) {
118
- const transcript = event.results[0][0].transcript.trim();
119
 
120
- // If name is captured, we now capture email
121
- if (isNameCaptured && !isEmailCaptured) {
122
- // Correct email input format by removing spaces and handling @ properly
123
- const cleanedEmail = transcript.replace(/\s/g, '').replace(/\bat\b/g, '@'); // Replace "at" with "@"
124
- emailInput.value = cleanedEmail; // Set the email field with cleaned input
125
- status.textContent = 'Registration complete.';
126
-
127
- // After registration, refresh the page after 20 seconds
128
- setTimeout(() => location.reload(), 20000); // Refresh after 20 seconds
129
- isEmailCaptured = true; // Mark email as captured
130
- } else if (!isNameCaptured) {
131
- // If name is not yet captured, capture name first
132
- nameInput.value = transcript;
133
- status.textContent = 'Listening for your email...'; // Prompt for email
134
- recognition.stop(); // Stop listening for name
135
- isNameCaptured = true; // Mark name as captured
136
- recognition.start(); // Start listening for email
137
- }
138
  };
139
  }
140
 
 
76
 
77
  <script>
78
  let recognition;
 
79
  let isNameCaptured = false;
80
  let isEmailCaptured = false;
81
 
 
101
  recognition.start();
102
  recognition.onresult = function(event) {
103
  const transcript = event.results[0][0].transcript.trim();
104
+
105
+ // Remove all spaces from the name
106
+ const cleanedName = transcript.replace(/\s+/g, '');
107
+
108
+ if (!isNameCaptured) {
109
+ // If name is not yet captured, capture name first
110
+ nameInput.value = cleanedName; // Set the cleaned name without spaces
111
+ status.textContent = 'Listening for your email...'; // Prompt for email
112
+ recognition.stop(); // Stop listening for name
113
+ isNameCaptured = true; // Mark name as captured
114
+ recognition.start(); // Start listening for email
115
+ }
116
  };
117
  }
118
 
 
122
  status.textContent = "Listening for your email...";
123
  recognition.start();
124
  recognition.onresult = function(event) {
125
+ let transcript = event.results[0][0].transcript.trim();
126
 
127
+ // Replace "at" with "@" for email
128
+ transcript = transcript.replace(/\bat\b/g, '@').trim();
129
+
130
+ // Clean any spaces around the email
131
+ const cleanedEmail = transcript.replace(/\s+/g, '');
132
+
133
+ emailInput.value = cleanedEmail; // Set the email field with cleaned input
134
+ status.textContent = 'Registration complete.';
135
+
136
+ // After registration, refresh the page after 20 seconds
137
+ setTimeout(() => location.reload(), 20000); // Refresh after 20 seconds
138
+ isEmailCaptured = true; // Mark email as captured
 
 
 
 
 
 
139
  };
140
  }
141