Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +153 -15
templates/index.html
CHANGED
@@ -84,28 +84,26 @@
|
|
84 |
<div class="container" id="registrationForm" style="display: none;">
|
85 |
<h2>Register</h2>
|
86 |
<label for="name">Your Name</label>
|
87 |
-
<input type="text" id="name" placeholder="
|
88 |
|
89 |
<label for="email">Your Email</label>
|
90 |
-
<input type="text" id="email" placeholder="
|
91 |
|
92 |
<label for="mobile">Your Mobile Number</label>
|
93 |
-
<input type="text" id="mobile" placeholder="
|
94 |
|
95 |
-
<
|
96 |
-
<button class="switch-button" onclick="showLoginForm()">Switch to Login</button>
|
97 |
</div>
|
98 |
|
99 |
<div class="container" id="loginForm" style="display: none;">
|
100 |
<h2>Login</h2>
|
101 |
<label for="loginEmail">Your Email</label>
|
102 |
-
<input type="text" id="loginEmail" placeholder="
|
103 |
|
104 |
<label for="loginMobile">Your Mobile Number</label>
|
105 |
-
<input type="text" id="loginMobile" placeholder="
|
106 |
|
107 |
-
<
|
108 |
-
<button class="switch-button" onclick="showRegistrationForm()">Switch to Register</button>
|
109 |
</div>
|
110 |
|
111 |
<div id="statusMessage" style="display: none;">
|
@@ -137,8 +135,10 @@
|
|
137 |
recognition.stop();
|
138 |
if (response.includes("new")) {
|
139 |
showRegistrationForm();
|
|
|
140 |
} else if (response.includes("existing")) {
|
141 |
showLoginForm();
|
|
|
142 |
} else {
|
143 |
speak("I didn't understand. Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
|
144 |
}
|
@@ -150,20 +150,104 @@
|
|
150 |
document.getElementById('welcomePage').style.display = 'none';
|
151 |
document.getElementById('registrationForm').style.display = 'block';
|
152 |
document.getElementById('loginForm').style.display = 'none';
|
|
|
153 |
}
|
154 |
|
155 |
function showLoginForm() {
|
156 |
document.getElementById('welcomePage').style.display = 'none';
|
157 |
document.getElementById('registrationForm').style.display = 'none';
|
158 |
document.getElementById('loginForm').style.display = 'block';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
}
|
160 |
|
161 |
function submitRegistration() {
|
162 |
const name = document.getElementById('name').value;
|
163 |
const email = document.getElementById('email').value;
|
164 |
-
const
|
165 |
|
166 |
-
// Simulate submission
|
167 |
document.getElementById('statusText').textContent = `Thank you for registering, ${name}!`;
|
168 |
document.getElementById('statusMessage').style.display = 'block';
|
169 |
setTimeout(() => {
|
@@ -171,12 +255,66 @@
|
|
171 |
}, 3000);
|
172 |
}
|
173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
function submitLogin() {
|
175 |
-
const
|
176 |
-
const
|
177 |
|
178 |
-
// Simulate login check
|
179 |
-
if (
|
180 |
document.getElementById('statusText').textContent = 'Login successful! Redirecting...';
|
181 |
document.getElementById('statusMessage').style.display = 'block';
|
182 |
setTimeout(() => {
|
|
|
84 |
<div class="container" id="registrationForm" style="display: none;">
|
85 |
<h2>Register</h2>
|
86 |
<label for="name">Your Name</label>
|
87 |
+
<input type="text" id="name" placeholder="Listening for name..." readonly>
|
88 |
|
89 |
<label for="email">Your Email</label>
|
90 |
+
<input type="text" id="email" placeholder="Listening for email..." readonly>
|
91 |
|
92 |
<label for="mobile">Your Mobile Number</label>
|
93 |
+
<input type="text" id="mobile" placeholder="Listening for mobile number..." readonly>
|
94 |
|
95 |
+
<p class="status" id="registrationStatus">Listening... 🗣</p>
|
|
|
96 |
</div>
|
97 |
|
98 |
<div class="container" id="loginForm" style="display: none;">
|
99 |
<h2>Login</h2>
|
100 |
<label for="loginEmail">Your Email</label>
|
101 |
+
<input type="text" id="loginEmail" placeholder="Listening for email..." readonly>
|
102 |
|
103 |
<label for="loginMobile">Your Mobile Number</label>
|
104 |
+
<input type="text" id="loginMobile" placeholder="Listening for mobile number..." readonly>
|
105 |
|
106 |
+
<p class="status" id="loginStatus">Listening... 🗣</p>
|
|
|
107 |
</div>
|
108 |
|
109 |
<div id="statusMessage" style="display: none;">
|
|
|
135 |
recognition.stop();
|
136 |
if (response.includes("new")) {
|
137 |
showRegistrationForm();
|
138 |
+
captureName();
|
139 |
} else if (response.includes("existing")) {
|
140 |
showLoginForm();
|
141 |
+
captureLoginDetails();
|
142 |
} else {
|
143 |
speak("I didn't understand. Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
|
144 |
}
|
|
|
150 |
document.getElementById('welcomePage').style.display = 'none';
|
151 |
document.getElementById('registrationForm').style.display = 'block';
|
152 |
document.getElementById('loginForm').style.display = 'none';
|
153 |
+
document.getElementById('statusMessage').style.display = 'none';
|
154 |
}
|
155 |
|
156 |
function showLoginForm() {
|
157 |
document.getElementById('welcomePage').style.display = 'none';
|
158 |
document.getElementById('registrationForm').style.display = 'none';
|
159 |
document.getElementById('loginForm').style.display = 'block';
|
160 |
+
document.getElementById('statusMessage').style.display = 'none';
|
161 |
+
}
|
162 |
+
|
163 |
+
function captureName() {
|
164 |
+
speak("Please say your name.", function () {
|
165 |
+
recognition.start();
|
166 |
+
recognition.onresult = function (event) {
|
167 |
+
let nameCaptured = event.results[0][0].transcript.trim();
|
168 |
+
document.getElementById('name').value = nameCaptured;
|
169 |
+
recognition.stop();
|
170 |
+
speak("You said " + nameCaptured + ". Is it correct?", function () {
|
171 |
+
confirmName(nameCaptured);
|
172 |
+
});
|
173 |
+
};
|
174 |
+
});
|
175 |
+
}
|
176 |
+
|
177 |
+
function confirmName(nameCaptured) {
|
178 |
+
recognition.start();
|
179 |
+
recognition.onresult = function (event) {
|
180 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
181 |
+
recognition.stop();
|
182 |
+
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
183 |
+
captureEmail();
|
184 |
+
} else {
|
185 |
+
captureName();
|
186 |
+
}
|
187 |
+
};
|
188 |
+
}
|
189 |
+
|
190 |
+
function captureEmail() {
|
191 |
+
speak("Now, say your email.", function () {
|
192 |
+
recognition.start();
|
193 |
+
recognition.onresult = function (event) {
|
194 |
+
let emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
195 |
+
document.getElementById('email').value = emailCaptured;
|
196 |
+
recognition.stop();
|
197 |
+
speak("You said " + emailCaptured + ". Is it correct?", function () {
|
198 |
+
confirmEmail(emailCaptured);
|
199 |
+
});
|
200 |
+
};
|
201 |
+
});
|
202 |
+
}
|
203 |
+
|
204 |
+
function confirmEmail(emailCaptured) {
|
205 |
+
recognition.start();
|
206 |
+
recognition.onresult = function (event) {
|
207 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
208 |
+
recognition.stop();
|
209 |
+
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
210 |
+
captureMobile();
|
211 |
+
} else {
|
212 |
+
captureEmail();
|
213 |
+
}
|
214 |
+
};
|
215 |
+
}
|
216 |
+
|
217 |
+
function captureMobile() {
|
218 |
+
speak("Now, say your mobile number.", function () {
|
219 |
+
recognition.start();
|
220 |
+
recognition.onresult = function (event) {
|
221 |
+
let mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
222 |
+
document.getElementById('mobile').value = mobileCaptured;
|
223 |
+
recognition.stop();
|
224 |
+
speak("You said " + mobileCaptured + ". Is it correct?", function () {
|
225 |
+
confirmMobile(mobileCaptured);
|
226 |
+
});
|
227 |
+
};
|
228 |
+
});
|
229 |
+
}
|
230 |
+
|
231 |
+
function confirmMobile(mobileCaptured) {
|
232 |
+
recognition.start();
|
233 |
+
recognition.onresult = function (event) {
|
234 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
235 |
+
recognition.stop();
|
236 |
+
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
237 |
+
// Show confirmation page with details
|
238 |
+
submitRegistration();
|
239 |
+
} else {
|
240 |
+
captureMobile();
|
241 |
+
}
|
242 |
+
};
|
243 |
}
|
244 |
|
245 |
function submitRegistration() {
|
246 |
const name = document.getElementById('name').value;
|
247 |
const email = document.getElementById('email').value;
|
248 |
+
const phone = document.getElementById('mobile').value;
|
249 |
|
250 |
+
// Simulate submission
|
251 |
document.getElementById('statusText').textContent = `Thank you for registering, ${name}!`;
|
252 |
document.getElementById('statusMessage').style.display = 'block';
|
253 |
setTimeout(() => {
|
|
|
255 |
}, 3000);
|
256 |
}
|
257 |
|
258 |
+
function captureLoginDetails() {
|
259 |
+
speak("Please say your email for login.", function () {
|
260 |
+
recognition.start();
|
261 |
+
recognition.onresult = function (event) {
|
262 |
+
let emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
263 |
+
document.getElementById('loginEmail').value = emailCaptured;
|
264 |
+
recognition.stop();
|
265 |
+
speak("You said " + emailCaptured + ". Is it correct?", function () {
|
266 |
+
confirmLoginEmail(emailCaptured);
|
267 |
+
});
|
268 |
+
};
|
269 |
+
});
|
270 |
+
}
|
271 |
+
|
272 |
+
function confirmLoginEmail(emailCaptured) {
|
273 |
+
recognition.start();
|
274 |
+
recognition.onresult = function (event) {
|
275 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
276 |
+
recognition.stop();
|
277 |
+
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
278 |
+
captureLoginMobile();
|
279 |
+
} else {
|
280 |
+
captureLoginDetails();
|
281 |
+
}
|
282 |
+
};
|
283 |
+
}
|
284 |
+
|
285 |
+
function captureLoginMobile() {
|
286 |
+
speak("Now, say your mobile number.", function () {
|
287 |
+
recognition.start();
|
288 |
+
recognition.onresult = function (event) {
|
289 |
+
let mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
290 |
+
document.getElementById('loginMobile').value = mobileCaptured;
|
291 |
+
recognition.stop();
|
292 |
+
speak("You said " + mobileCaptured + ". Is it correct?", function () {
|
293 |
+
confirmLoginMobile(mobileCaptured);
|
294 |
+
});
|
295 |
+
};
|
296 |
+
});
|
297 |
+
}
|
298 |
+
|
299 |
+
function confirmLoginMobile(mobileCaptured) {
|
300 |
+
recognition.start();
|
301 |
+
recognition.onresult = function (event) {
|
302 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
303 |
+
recognition.stop();
|
304 |
+
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
305 |
+
submitLogin();
|
306 |
+
} else {
|
307 |
+
captureLoginMobile();
|
308 |
+
}
|
309 |
+
};
|
310 |
+
}
|
311 |
+
|
312 |
function submitLogin() {
|
313 |
+
const loginEmail = document.getElementById('loginEmail').value;
|
314 |
+
const loginMobile = document.getElementById('loginMobile').value;
|
315 |
|
316 |
+
// Simulate login check
|
317 |
+
if (loginEmail && loginMobile) {
|
318 |
document.getElementById('statusText').textContent = 'Login successful! Redirecting...';
|
319 |
document.getElementById('statusMessage').style.display = 'block';
|
320 |
setTimeout(() => {
|