Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +45 -15
templates/index.html
CHANGED
@@ -134,6 +134,8 @@
|
|
134 |
|
135 |
<script>
|
136 |
let recognition;
|
|
|
|
|
137 |
if ('webkitSpeechRecognition' in window) {
|
138 |
recognition = new webkitSpeechRecognition();
|
139 |
recognition.continuous = false;
|
@@ -156,9 +158,11 @@
|
|
156 |
let response = event.results[0][0].transcript.trim().toLowerCase();
|
157 |
recognition.stop();
|
158 |
if (response.includes("new")) {
|
|
|
159 |
showRegistrationForm();
|
160 |
captureName();
|
161 |
} else if (response.includes("existing")) {
|
|
|
162 |
showLoginForm();
|
163 |
captureLoginEmail();
|
164 |
} else {
|
@@ -178,58 +182,84 @@
|
|
178 |
document.getElementById('registrationForm').style.display = 'none';
|
179 |
}
|
180 |
|
181 |
-
// Capture
|
182 |
-
function
|
183 |
-
speak("Please say your
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
recognition.start();
|
185 |
recognition.onresult = function (event) {
|
186 |
let emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
187 |
-
document.getElementById('
|
188 |
recognition.stop();
|
189 |
speak("You said " + emailCaptured + ". Is it correct?", function () {
|
190 |
-
|
191 |
});
|
192 |
};
|
193 |
});
|
194 |
}
|
195 |
|
196 |
-
function
|
197 |
recognition.start();
|
198 |
recognition.onresult = function (event) {
|
199 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
200 |
recognition.stop();
|
201 |
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
202 |
-
|
203 |
} else {
|
204 |
-
|
205 |
}
|
206 |
};
|
207 |
}
|
208 |
|
209 |
-
function
|
210 |
speak("Now, say your mobile number.", function () {
|
211 |
recognition.start();
|
212 |
recognition.onresult = function (event) {
|
213 |
let mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
214 |
-
document.getElementById('
|
215 |
recognition.stop();
|
216 |
speak("You said " + mobileCaptured + ". Is it correct?", function () {
|
217 |
-
|
218 |
});
|
219 |
};
|
220 |
});
|
221 |
}
|
222 |
|
223 |
-
function
|
224 |
recognition.start();
|
225 |
recognition.onresult = function (event) {
|
226 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
227 |
recognition.stop();
|
228 |
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
229 |
-
|
230 |
-
showSuccessMessage();
|
231 |
} else {
|
232 |
-
|
233 |
}
|
234 |
};
|
235 |
}
|
|
|
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 |
let response = event.results[0][0].transcript.trim().toLowerCase();
|
159 |
recognition.stop();
|
160 |
if (response.includes("new")) {
|
161 |
+
registrationMode = true;
|
162 |
showRegistrationForm();
|
163 |
captureName();
|
164 |
} else if (response.includes("existing")) {
|
165 |
+
registrationMode = false;
|
166 |
showLoginForm();
|
167 |
captureLoginEmail();
|
168 |
} else {
|
|
|
182 |
document.getElementById('registrationForm').style.display = 'none';
|
183 |
}
|
184 |
|
185 |
+
// Capture name and confirm for registration
|
186 |
+
function captureName() {
|
187 |
+
speak("Please say your name.", function () {
|
188 |
+
recognition.start();
|
189 |
+
recognition.onresult = function (event) {
|
190 |
+
let nameCaptured = event.results[0][0].transcript.trim();
|
191 |
+
document.getElementById('name').value = nameCaptured;
|
192 |
+
recognition.stop();
|
193 |
+
speak("You said " + nameCaptured + ". Is it correct?", function () {
|
194 |
+
confirmName(nameCaptured);
|
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 |
+
function captureEmail() {
|
214 |
+
speak("Now, say your email.", function () {
|
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 |
recognition.stop();
|
247 |
speak("You said " + mobileCaptured + ". Is it correct?", function () {
|
248 |
+
confirmMobile(mobileCaptured);
|
249 |
});
|
250 |
};
|
251 |
});
|
252 |
}
|
253 |
|
254 |
+
function confirmMobile(mobileCaptured) {
|
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 |
+
captureMobile();
|
263 |
}
|
264 |
};
|
265 |
}
|