Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +15 -3
templates/index.html
CHANGED
@@ -107,13 +107,15 @@
|
|
107 |
} else {
|
108 |
alert("Speech Recognition API is not supported in this browser.");
|
109 |
}
|
110 |
-
|
|
|
111 |
function speak(text, callback) {
|
112 |
const speech = new SpeechSynthesisUtterance(text);
|
113 |
speech.onend = callback;
|
114 |
window.speechSynthesis.speak(speech);
|
115 |
}
|
116 |
|
|
|
117 |
function askLoginOrRegister() {
|
118 |
speak("Are you a new customer or an existing customer? Say 'new' to register or 'existing' to login.", function () {
|
119 |
recognition.start();
|
@@ -133,6 +135,7 @@
|
|
133 |
});
|
134 |
}
|
135 |
|
|
|
136 |
function captureEmail() {
|
137 |
speak("Please say your email address.", function () {
|
138 |
recognition.start();
|
@@ -149,13 +152,14 @@
|
|
149 |
});
|
150 |
}
|
151 |
|
|
|
152 |
function isValidEmail(email) {
|
153 |
return /\S+@\S+\.\S+/.test(email);
|
154 |
}
|
155 |
|
|
|
156 |
function checkEmailExists(email) {
|
157 |
-
|
158 |
-
const existingEmails = ["[email protected]"];
|
159 |
if (existingEmails.includes(email)) {
|
160 |
speak("Welcome back! You are logged in.");
|
161 |
document.getElementById('loginForm').style.display = 'block';
|
@@ -166,16 +170,19 @@
|
|
166 |
}
|
167 |
}
|
168 |
|
|
|
169 |
function showRegistrationForm() {
|
170 |
document.getElementById('registrationForm').style.display = 'block';
|
171 |
document.getElementById('loginForm').style.display = 'none';
|
172 |
}
|
173 |
|
|
|
174 |
function showLoginForm() {
|
175 |
document.getElementById('loginForm').style.display = 'block';
|
176 |
document.getElementById('registrationForm').style.display = 'none';
|
177 |
}
|
178 |
|
|
|
179 |
function captureMobile() {
|
180 |
speak("Please say your 12-digit mobile number.", function () {
|
181 |
recognition.start();
|
@@ -194,10 +201,12 @@
|
|
194 |
});
|
195 |
}
|
196 |
|
|
|
197 |
function isValidPhone(phone) {
|
198 |
return /^\d{12}$/.test(phone);
|
199 |
}
|
200 |
|
|
|
201 |
function confirmMobile(mobileCaptured) {
|
202 |
recognition.start();
|
203 |
recognition.onresult = function (event) {
|
@@ -211,6 +220,7 @@
|
|
211 |
};
|
212 |
}
|
213 |
|
|
|
214 |
function showConfirmationPage() {
|
215 |
const name = document.getElementById('name').value;
|
216 |
const email = document.getElementById('email').value;
|
@@ -221,6 +231,7 @@
|
|
221 |
setTimeout(submitRegistration, 6000);
|
222 |
}
|
223 |
|
|
|
224 |
function submitRegistration() {
|
225 |
const name = document.getElementById('name').value;
|
226 |
const email = document.getElementById('email').value;
|
@@ -252,6 +263,7 @@
|
|
252 |
});
|
253 |
}
|
254 |
|
|
|
255 |
window.onload = function () {
|
256 |
askLoginOrRegister();
|
257 |
};
|
|
|
107 |
} else {
|
108 |
alert("Speech Recognition API is not supported in this browser.");
|
109 |
}
|
110 |
+
|
111 |
+
// This function will speak the text and trigger the callback after it finishes
|
112 |
function speak(text, callback) {
|
113 |
const speech = new SpeechSynthesisUtterance(text);
|
114 |
speech.onend = callback;
|
115 |
window.speechSynthesis.speak(speech);
|
116 |
}
|
117 |
|
118 |
+
// Function to ask whether the user is new or existing
|
119 |
function askLoginOrRegister() {
|
120 |
speak("Are you a new customer or an existing customer? Say 'new' to register or 'existing' to login.", function () {
|
121 |
recognition.start();
|
|
|
135 |
});
|
136 |
}
|
137 |
|
138 |
+
// Function to capture the email
|
139 |
function captureEmail() {
|
140 |
speak("Please say your email address.", function () {
|
141 |
recognition.start();
|
|
|
152 |
});
|
153 |
}
|
154 |
|
155 |
+
// Function to validate email format
|
156 |
function isValidEmail(email) {
|
157 |
return /\S+@\S+\.\S+/.test(email);
|
158 |
}
|
159 |
|
160 |
+
// Simulate email existence check (this is where you could call your server)
|
161 |
function checkEmailExists(email) {
|
162 |
+
const existingEmails = ["[email protected]"]; // Replace with actual check
|
|
|
163 |
if (existingEmails.includes(email)) {
|
164 |
speak("Welcome back! You are logged in.");
|
165 |
document.getElementById('loginForm').style.display = 'block';
|
|
|
170 |
}
|
171 |
}
|
172 |
|
173 |
+
// Show registration form
|
174 |
function showRegistrationForm() {
|
175 |
document.getElementById('registrationForm').style.display = 'block';
|
176 |
document.getElementById('loginForm').style.display = 'none';
|
177 |
}
|
178 |
|
179 |
+
// Show login form
|
180 |
function showLoginForm() {
|
181 |
document.getElementById('loginForm').style.display = 'block';
|
182 |
document.getElementById('registrationForm').style.display = 'none';
|
183 |
}
|
184 |
|
185 |
+
// Function to capture mobile number
|
186 |
function captureMobile() {
|
187 |
speak("Please say your 12-digit mobile number.", function () {
|
188 |
recognition.start();
|
|
|
201 |
});
|
202 |
}
|
203 |
|
204 |
+
// Function to validate mobile phone number
|
205 |
function isValidPhone(phone) {
|
206 |
return /^\d{12}$/.test(phone);
|
207 |
}
|
208 |
|
209 |
+
// Function to confirm mobile number
|
210 |
function confirmMobile(mobileCaptured) {
|
211 |
recognition.start();
|
212 |
recognition.onresult = function (event) {
|
|
|
220 |
};
|
221 |
}
|
222 |
|
223 |
+
// Function to show confirmation page
|
224 |
function showConfirmationPage() {
|
225 |
const name = document.getElementById('name').value;
|
226 |
const email = document.getElementById('email').value;
|
|
|
231 |
setTimeout(submitRegistration, 6000);
|
232 |
}
|
233 |
|
234 |
+
// Function to simulate registration submission (you can replace this with actual submission)
|
235 |
function submitRegistration() {
|
236 |
const name = document.getElementById('name').value;
|
237 |
const email = document.getElementById('email').value;
|
|
|
263 |
});
|
264 |
}
|
265 |
|
266 |
+
// Start the process when the page loads
|
267 |
window.onload = function () {
|
268 |
askLoginOrRegister();
|
269 |
};
|