Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +21 -73
templates/index.html
CHANGED
@@ -134,8 +134,6 @@
|
|
134 |
|
135 |
<script>
|
136 |
let recognition;
|
137 |
-
let registrationMode = false; // Track whether it's registration or login
|
138 |
-
|
139 |
if ('webkitSpeechRecognition' in window) {
|
140 |
recognition = new webkitSpeechRecognition();
|
141 |
recognition.continuous = false;
|
@@ -158,11 +156,9 @@
|
|
158 |
let response = event.results[0][0].transcript.trim().toLowerCase();
|
159 |
recognition.stop();
|
160 |
if (response.includes("new")) {
|
161 |
-
registrationMode = true;
|
162 |
showRegistrationForm();
|
163 |
-
|
164 |
} else if (response.includes("existing")) {
|
165 |
-
registrationMode = false;
|
166 |
showLoginForm();
|
167 |
captureLoginEmail();
|
168 |
} else {
|
@@ -182,97 +178,49 @@
|
|
182 |
document.getElementById('registrationForm').style.display = 'none';
|
183 |
}
|
184 |
|
185 |
-
// Capture
|
186 |
-
function
|
187 |
-
speak("Please
|
188 |
recognition.start();
|
189 |
recognition.onresult = function (event) {
|
190 |
-
let
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
});
|
196 |
-
};
|
197 |
-
});
|
198 |
-
}
|
199 |
-
|
200 |
-
function confirmName(nameCaptured) {
|
201 |
-
recognition.start();
|
202 |
-
recognition.onresult = function (event) {
|
203 |
-
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
204 |
-
recognition.stop();
|
205 |
-
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
206 |
-
captureEmail();
|
207 |
-
} else {
|
208 |
-
captureName();
|
209 |
-
}
|
210 |
-
};
|
211 |
-
}
|
212 |
|
213 |
-
|
214 |
-
|
215 |
-
recognition.start();
|
216 |
-
recognition.onresult = function (event) {
|
217 |
-
let emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
218 |
document.getElementById('email').value = emailCaptured;
|
219 |
-
recognition.stop();
|
220 |
-
speak("You said " + emailCaptured + ". Is it correct?", function () {
|
221 |
-
confirmEmail(emailCaptured);
|
222 |
-
});
|
223 |
-
};
|
224 |
-
});
|
225 |
-
}
|
226 |
-
|
227 |
-
function confirmEmail(emailCaptured) {
|
228 |
-
recognition.start();
|
229 |
-
recognition.onresult = function (event) {
|
230 |
-
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
231 |
-
recognition.stop();
|
232 |
-
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
233 |
-
captureMobile();
|
234 |
-
} else {
|
235 |
-
captureEmail();
|
236 |
-
}
|
237 |
-
};
|
238 |
-
}
|
239 |
-
|
240 |
-
function captureMobile() {
|
241 |
-
speak("Now, say your mobile number.", function () {
|
242 |
-
recognition.start();
|
243 |
-
recognition.onresult = function (event) {
|
244 |
-
let mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
245 |
document.getElementById('mobile').value = mobileCaptured;
|
246 |
-
|
247 |
-
|
248 |
-
|
|
|
249 |
});
|
250 |
};
|
251 |
});
|
252 |
}
|
253 |
|
254 |
-
|
|
|
255 |
recognition.start();
|
256 |
recognition.onresult = function (event) {
|
257 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
258 |
recognition.stop();
|
259 |
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
260 |
-
showConfirmationDetails();
|
261 |
} else {
|
262 |
-
|
263 |
}
|
264 |
};
|
265 |
}
|
266 |
|
267 |
// Show the confirmation details to the user
|
268 |
-
function showConfirmationDetails() {
|
269 |
-
const name = document.getElementById('name').value;
|
270 |
-
const email = document.getElementById('email').value;
|
271 |
-
const phone = document.getElementById('mobile').value;
|
272 |
-
|
273 |
document.getElementById('confirmedName').textContent = "Name: " + name;
|
274 |
document.getElementById('confirmedEmail').textContent = "Email: " + email;
|
275 |
-
document.getElementById('confirmedPhone').textContent = "Phone: " +
|
276 |
|
277 |
document.getElementById('confirmationSection').style.display = 'block';
|
278 |
}
|
|
|
134 |
|
135 |
<script>
|
136 |
let recognition;
|
|
|
|
|
137 |
if ('webkitSpeechRecognition' in window) {
|
138 |
recognition = new webkitSpeechRecognition();
|
139 |
recognition.continuous = false;
|
|
|
156 |
let response = event.results[0][0].transcript.trim().toLowerCase();
|
157 |
recognition.stop();
|
158 |
if (response.includes("new")) {
|
|
|
159 |
showRegistrationForm();
|
160 |
+
captureDetailsForRegistration();
|
161 |
} else if (response.includes("existing")) {
|
|
|
162 |
showLoginForm();
|
163 |
captureLoginEmail();
|
164 |
} else {
|
|
|
178 |
document.getElementById('registrationForm').style.display = 'none';
|
179 |
}
|
180 |
|
181 |
+
// Capture all details for new registration without asking for fields
|
182 |
+
function captureDetailsForRegistration() {
|
183 |
+
speak("Please provide your name, email, and mobile number.", function () {
|
184 |
recognition.start();
|
185 |
recognition.onresult = function (event) {
|
186 |
+
let details = event.results[0][0].transcript.trim();
|
187 |
+
let detailsArray = details.split(" ");
|
188 |
+
let nameCaptured = detailsArray[0]; // First word is assumed to be the name
|
189 |
+
let emailCaptured = detailsArray[1]; // Second word assumed to be the email
|
190 |
+
let mobileCaptured = detailsArray[2]; // Third word assumed to be the mobile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
+
// Automatically fill in the fields
|
193 |
+
document.getElementById('name').value = nameCaptured;
|
|
|
|
|
|
|
194 |
document.getElementById('email').value = emailCaptured;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
document.getElementById('mobile').value = mobileCaptured;
|
196 |
+
|
197 |
+
// Confirm the details
|
198 |
+
speak(`You said: Name: ${nameCaptured}, Email: ${emailCaptured}, Mobile: ${mobileCaptured}. Is it correct?`, function () {
|
199 |
+
confirmRegistrationDetails(nameCaptured, emailCaptured, mobileCaptured);
|
200 |
});
|
201 |
};
|
202 |
});
|
203 |
}
|
204 |
|
205 |
+
// Confirm details for registration
|
206 |
+
function confirmRegistrationDetails(nameCaptured, emailCaptured, mobileCaptured) {
|
207 |
recognition.start();
|
208 |
recognition.onresult = function (event) {
|
209 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
210 |
recognition.stop();
|
211 |
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
212 |
+
showConfirmationDetails(nameCaptured, emailCaptured, mobileCaptured);
|
213 |
} else {
|
214 |
+
captureDetailsForRegistration();
|
215 |
}
|
216 |
};
|
217 |
}
|
218 |
|
219 |
// Show the confirmation details to the user
|
220 |
+
function showConfirmationDetails(name, email, mobile) {
|
|
|
|
|
|
|
|
|
221 |
document.getElementById('confirmedName').textContent = "Name: " + name;
|
222 |
document.getElementById('confirmedEmail').textContent = "Email: " + email;
|
223 |
+
document.getElementById('confirmedPhone').textContent = "Phone: " + mobile;
|
224 |
|
225 |
document.getElementById('confirmationSection').style.display = 'block';
|
226 |
}
|