Update templates/index.html
Browse files- templates/index.html +64 -13
templates/index.html
CHANGED
@@ -143,13 +143,11 @@
|
|
143 |
} else {
|
144 |
alert("Speech Recognition API is not supported in this browser.");
|
145 |
}
|
146 |
-
|
147 |
function speak(text, callback) {
|
148 |
const speech = new SpeechSynthesisUtterance(text);
|
149 |
speech.onend = callback;
|
150 |
window.speechSynthesis.speak(speech);
|
151 |
}
|
152 |
-
|
153 |
function askLoginOrRegister() {
|
154 |
speak("Are you a new customer or an existing customer? Say 'new' to register or 'existing' to login.", function () {
|
155 |
recognition.start();
|
@@ -168,7 +166,6 @@
|
|
168 |
};
|
169 |
});
|
170 |
}
|
171 |
-
|
172 |
function showRegistrationForm() {
|
173 |
document.getElementById('welcomePage').style.display = 'none';
|
174 |
document.getElementById('registrationForm').style.display = 'block';
|
@@ -176,7 +173,6 @@
|
|
176 |
document.getElementById('confirmationPage').style.display = 'none';
|
177 |
document.getElementById('statusMessage').style.display = 'none';
|
178 |
}
|
179 |
-
|
180 |
function showLoginForm() {
|
181 |
document.getElementById('welcomePage').style.display = 'none';
|
182 |
document.getElementById('registrationForm').style.display = 'none';
|
@@ -184,7 +180,6 @@
|
|
184 |
document.getElementById('confirmationPage').style.display = 'none';
|
185 |
document.getElementById('statusMessage').style.display = 'none';
|
186 |
}
|
187 |
-
|
188 |
function captureName() {
|
189 |
speak("Please say your name.", function () {
|
190 |
recognition.start();
|
@@ -198,7 +193,6 @@
|
|
198 |
};
|
199 |
});
|
200 |
}
|
201 |
-
|
202 |
function confirmName(nameCaptured) {
|
203 |
recognition.start();
|
204 |
recognition.onresult = function (event) {
|
@@ -211,7 +205,6 @@
|
|
211 |
}
|
212 |
};
|
213 |
}
|
214 |
-
|
215 |
function captureEmail() {
|
216 |
speak("Now, say your email.", function () {
|
217 |
recognition.start();
|
@@ -225,7 +218,6 @@
|
|
225 |
};
|
226 |
});
|
227 |
}
|
228 |
-
|
229 |
function confirmEmail(emailCaptured) {
|
230 |
recognition.start();
|
231 |
recognition.onresult = function (event) {
|
@@ -238,7 +230,6 @@
|
|
238 |
}
|
239 |
};
|
240 |
}
|
241 |
-
|
242 |
function captureMobile() {
|
243 |
speak("Now, say your mobile number.", function () {
|
244 |
recognition.start();
|
@@ -252,7 +243,6 @@
|
|
252 |
};
|
253 |
});
|
254 |
}
|
255 |
-
|
256 |
function confirmMobile(mobileCaptured) {
|
257 |
recognition.start();
|
258 |
recognition.onresult = function (event) {
|
@@ -266,7 +256,6 @@
|
|
266 |
}
|
267 |
};
|
268 |
}
|
269 |
-
|
270 |
function showConfirmationPage() {
|
271 |
const name = document.getElementById('name').value;
|
272 |
const email = document.getElementById('email').value;
|
@@ -277,7 +266,6 @@
|
|
277 |
// Automatically submit the details after a delay
|
278 |
setTimeout(submitRegistration, 6000); // 6 seconds delay
|
279 |
}
|
280 |
-
|
281 |
function submitRegistration() {
|
282 |
const name = document.getElementById('name').value;
|
283 |
const email = document.getElementById('email').value;
|
@@ -310,7 +298,70 @@
|
|
310 |
document.getElementById('statusMessage').style.display = 'block';
|
311 |
});
|
312 |
}
|
313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
window.onload = function () {
|
315 |
askLoginOrRegister();
|
316 |
};
|
|
|
143 |
} else {
|
144 |
alert("Speech Recognition API is not supported in this browser.");
|
145 |
}
|
|
|
146 |
function speak(text, callback) {
|
147 |
const speech = new SpeechSynthesisUtterance(text);
|
148 |
speech.onend = callback;
|
149 |
window.speechSynthesis.speak(speech);
|
150 |
}
|
|
|
151 |
function askLoginOrRegister() {
|
152 |
speak("Are you a new customer or an existing customer? Say 'new' to register or 'existing' to login.", function () {
|
153 |
recognition.start();
|
|
|
166 |
};
|
167 |
});
|
168 |
}
|
|
|
169 |
function showRegistrationForm() {
|
170 |
document.getElementById('welcomePage').style.display = 'none';
|
171 |
document.getElementById('registrationForm').style.display = 'block';
|
|
|
173 |
document.getElementById('confirmationPage').style.display = 'none';
|
174 |
document.getElementById('statusMessage').style.display = 'none';
|
175 |
}
|
|
|
176 |
function showLoginForm() {
|
177 |
document.getElementById('welcomePage').style.display = 'none';
|
178 |
document.getElementById('registrationForm').style.display = 'none';
|
|
|
180 |
document.getElementById('confirmationPage').style.display = 'none';
|
181 |
document.getElementById('statusMessage').style.display = 'none';
|
182 |
}
|
|
|
183 |
function captureName() {
|
184 |
speak("Please say your name.", function () {
|
185 |
recognition.start();
|
|
|
193 |
};
|
194 |
});
|
195 |
}
|
|
|
196 |
function confirmName(nameCaptured) {
|
197 |
recognition.start();
|
198 |
recognition.onresult = function (event) {
|
|
|
205 |
}
|
206 |
};
|
207 |
}
|
|
|
208 |
function captureEmail() {
|
209 |
speak("Now, say your email.", function () {
|
210 |
recognition.start();
|
|
|
218 |
};
|
219 |
});
|
220 |
}
|
|
|
221 |
function confirmEmail(emailCaptured) {
|
222 |
recognition.start();
|
223 |
recognition.onresult = function (event) {
|
|
|
230 |
}
|
231 |
};
|
232 |
}
|
|
|
233 |
function captureMobile() {
|
234 |
speak("Now, say your mobile number.", function () {
|
235 |
recognition.start();
|
|
|
243 |
};
|
244 |
});
|
245 |
}
|
|
|
246 |
function confirmMobile(mobileCaptured) {
|
247 |
recognition.start();
|
248 |
recognition.onresult = function (event) {
|
|
|
256 |
}
|
257 |
};
|
258 |
}
|
|
|
259 |
function showConfirmationPage() {
|
260 |
const name = document.getElementById('name').value;
|
261 |
const email = document.getElementById('email').value;
|
|
|
266 |
// Automatically submit the details after a delay
|
267 |
setTimeout(submitRegistration, 6000); // 6 seconds delay
|
268 |
}
|
|
|
269 |
function submitRegistration() {
|
270 |
const name = document.getElementById('name').value;
|
271 |
const email = document.getElementById('email').value;
|
|
|
298 |
document.getElementById('statusMessage').style.display = 'block';
|
299 |
});
|
300 |
}
|
301 |
+
function captureLoginDetails() {
|
302 |
+
speak("Please say your email for login.", function () {
|
303 |
+
recognition.start();
|
304 |
+
recognition.onresult = function (event) {
|
305 |
+
let emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
306 |
+
document.getElementById('loginEmail').value = emailCaptured;
|
307 |
+
recognition.stop();
|
308 |
+
speak("You said " + emailCaptured + ". Is it correct?", function () {
|
309 |
+
confirmLoginEmail(emailCaptured);
|
310 |
+
});
|
311 |
+
};
|
312 |
+
});
|
313 |
+
}
|
314 |
+
function confirmLoginEmail(emailCaptured) {
|
315 |
+
recognition.start();
|
316 |
+
recognition.onresult = function (event) {
|
317 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
318 |
+
recognition.stop();
|
319 |
+
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
320 |
+
captureLoginMobile();
|
321 |
+
} else {
|
322 |
+
captureLoginDetails();
|
323 |
+
}
|
324 |
+
};
|
325 |
+
}
|
326 |
+
function captureLoginMobile() {
|
327 |
+
speak("Now, say your mobile number.", function () {
|
328 |
+
recognition.start();
|
329 |
+
recognition.onresult = function (event) {
|
330 |
+
let mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
331 |
+
document.getElementById('loginMobile').value = mobileCaptured;
|
332 |
+
recognition.stop();
|
333 |
+
speak("You said " + mobileCaptured + ". Is it correct?", function () {
|
334 |
+
confirmLoginMobile(mobileCaptured);
|
335 |
+
});
|
336 |
+
};
|
337 |
+
});
|
338 |
+
}
|
339 |
+
function confirmLoginMobile(mobileCaptured) {
|
340 |
+
recognition.start();
|
341 |
+
recognition.onresult = function (event) {
|
342 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
343 |
+
recognition.stop();
|
344 |
+
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
345 |
+
submitLogin();
|
346 |
+
} else {
|
347 |
+
captureLoginMobile();
|
348 |
+
}
|
349 |
+
};
|
350 |
+
}
|
351 |
+
function submitLogin() {
|
352 |
+
const loginEmail = document.getElementById('loginEmail').value;
|
353 |
+
const loginMobile = document.getElementById('loginMobile').value;
|
354 |
+
// Simulate login check
|
355 |
+
if (loginEmail && loginMobile) {
|
356 |
+
document.getElementById('statusText').textContent = 'Login successful! Redirecting...';
|
357 |
+
document.getElementById('statusMessage').style.display = 'block';
|
358 |
+
setTimeout(() => {
|
359 |
+
window.location.href = '/dashboard'; // Redirect to dashboard
|
360 |
+
}, 3000);
|
361 |
+
} else {
|
362 |
+
speak("Please enter valid login details.");
|
363 |
+
}
|
364 |
+
}
|
365 |
window.onload = function () {
|
366 |
askLoginOrRegister();
|
367 |
};
|