Update templates/index.html
Browse files- templates/index.html +241 -221
templates/index.html
CHANGED
@@ -4,34 +4,119 @@
|
|
4 |
<head>
|
5 |
<meta charset="UTF-8">
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
-
<title>Biryani Hub Registration</title>
|
8 |
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
|
9 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
</head>
|
11 |
-
|
12 |
<body>
|
13 |
<div class="container">
|
14 |
-
|
15 |
<h1>Welcome to Biryani Hub 🍽 🍗</h1>
|
16 |
-
|
17 |
-
<label for="name">Your Name</label>
|
18 |
-
<input type="text" id="name" placeholder="Your name will appear here..." readonly>
|
19 |
-
|
20 |
-
<label for="email">Your Email</label>
|
21 |
-
<input type="text" id="email" placeholder="Your email will appear here..." readonly>
|
22 |
-
|
23 |
-
<label for="mobile">Your Mobile Number</label>
|
24 |
-
<input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
|
25 |
|
26 |
-
|
27 |
-
<
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
</div>
|
36 |
|
37 |
<script>
|
@@ -39,6 +124,7 @@
|
|
39 |
let nameCaptured = "";
|
40 |
let emailCaptured = "";
|
41 |
let mobileCaptured = "";
|
|
|
42 |
if ('webkitSpeechRecognition' in window) {
|
43 |
recognition = new webkitSpeechRecognition();
|
44 |
recognition.continuous = false;
|
@@ -47,76 +133,116 @@
|
|
47 |
} else {
|
48 |
alert("Speech Recognition API is not supported in this browser.");
|
49 |
}
|
|
|
50 |
function speak(text, callback) {
|
51 |
const speech = new SpeechSynthesisUtterance(text);
|
52 |
speech.onend = callback;
|
53 |
window.speechSynthesis.speak(speech);
|
54 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
function startListeningForName() {
|
56 |
recognition.start();
|
57 |
recognition.onresult = function(event) {
|
58 |
nameCaptured = event.results[0][0].transcript.trim();
|
59 |
document.getElementById('name').value = nameCaptured;
|
60 |
recognition.stop();
|
61 |
-
|
62 |
};
|
63 |
}
|
|
|
64 |
function confirmName() {
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
};
|
76 |
-
});
|
77 |
}
|
|
|
|
|
78 |
function startListeningForEmail() {
|
79 |
recognition.start();
|
80 |
recognition.onresult = function(event) {
|
81 |
emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
82 |
document.getElementById('email').value = emailCaptured;
|
83 |
recognition.stop();
|
84 |
-
speak("You said " + emailCaptured + ". Is it correct?",
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
}
|
|
|
|
|
96 |
};
|
97 |
}
|
|
|
|
|
98 |
function startListeningForMobile() {
|
99 |
recognition.start();
|
100 |
recognition.onresult = function(event) {
|
101 |
mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
102 |
document.getElementById('mobile').value = mobileCaptured;
|
103 |
recognition.stop();
|
104 |
-
speak("You said " + mobileCaptured + ". Is it correct?",
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
}
|
118 |
};
|
119 |
}
|
|
|
|
|
120 |
function autoConfirm() {
|
121 |
document.getElementById('confirmName').textContent = document.getElementById('name').value;
|
122 |
document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
|
@@ -124,6 +250,8 @@
|
|
124 |
document.getElementById('confirmation').style.display = 'block';
|
125 |
setTimeout(autoSubmit, 3000);
|
126 |
}
|
|
|
|
|
127 |
function autoSubmit() {
|
128 |
var name = document.getElementById('name').value;
|
129 |
var email = document.getElementById('email').value;
|
@@ -146,183 +274,75 @@
|
|
146 |
}
|
147 |
});
|
148 |
}
|
149 |
-
window.onload = function () {
|
150 |
-
setTimeout(startListeningForName, 4000);
|
151 |
-
};
|
152 |
-
</script>
|
153 |
-
</body>
|
154 |
-
</html>
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
font-family: 'Roboto', sans-serif;
|
166 |
-
background: linear-gradient(135deg, #f4c542, #ff8f6a);
|
167 |
-
margin: 0;
|
168 |
-
display: flex;
|
169 |
-
justify-content: center;
|
170 |
-
align-items: center;
|
171 |
-
height: 100vh;
|
172 |
-
text-align: center;
|
173 |
-
}
|
174 |
-
.container {
|
175 |
-
background-color: #87ceeb;
|
176 |
-
padding: 40px 50px;
|
177 |
-
border-radius: 10px;
|
178 |
-
width: 400px;
|
179 |
-
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
180 |
-
}
|
181 |
-
h1 {
|
182 |
-
font-size: 30px;
|
183 |
-
font-weight: bold;
|
184 |
-
color: #ff6a00;
|
185 |
-
}
|
186 |
-
label {
|
187 |
-
font-size: 16px;
|
188 |
-
margin-top: 20px;
|
189 |
-
display: block;
|
190 |
-
text-align: left;
|
191 |
-
font-weight: bold;
|
192 |
-
}
|
193 |
-
input[type="text"], input[type="tel"] {
|
194 |
-
width: 100%;
|
195 |
-
padding: 12px;
|
196 |
-
font-size: 16px;
|
197 |
-
border: 2px solid #ccc;
|
198 |
-
border-radius: 8px;
|
199 |
-
margin-top: 8px;
|
200 |
-
box-sizing: border-box;
|
201 |
-
}
|
202 |
-
input:focus {
|
203 |
-
border-color: #ff6a00;
|
204 |
-
outline: none;
|
205 |
-
}
|
206 |
-
.info {
|
207 |
-
margin-top: 20px;
|
208 |
-
font-size: 16px;
|
209 |
-
color: #ff6a00;
|
210 |
-
font-weight: bold;
|
211 |
-
}
|
212 |
-
.status {
|
213 |
-
font-size: 14px;
|
214 |
-
color: gray;
|
215 |
-
margin-top: 20px;
|
216 |
}
|
217 |
-
</style>
|
218 |
-
</head>
|
219 |
-
<body>
|
220 |
-
<div class="container">
|
221 |
-
<h1>Welcome to Biryani Hub 🍽 🍗</h1>
|
222 |
-
<h2>login 🍗</h2>
|
223 |
-
<label for="email">Your Email</label>
|
224 |
-
<input type="text" id="email" placeholder="Your email will appear here..." readonly>
|
225 |
-
|
226 |
-
<label for="mobile">Mobile Number</label>
|
227 |
-
<input type="tel" id="mobile" placeholder="Your mobile number will appear here..." readonly>
|
228 |
-
|
229 |
-
<p class="info" id="infoMessage">Listening 🗣🎙️...</p>
|
230 |
-
<p class="status" id="status">🔊...</p>
|
231 |
-
</div>
|
232 |
|
233 |
-
|
234 |
-
let recognition;
|
235 |
-
let emailCaptured = "";
|
236 |
-
let mobileCaptured = "";
|
237 |
-
|
238 |
-
if ('webkitSpeechRecognition' in window) {
|
239 |
-
recognition = new webkitSpeechRecognition();
|
240 |
-
recognition.continuous = false;
|
241 |
-
recognition.interimResults = false;
|
242 |
-
recognition.lang = 'en-US';
|
243 |
-
} else {
|
244 |
-
alert("Speech Recognition API is not supported in this browser.");
|
245 |
-
}
|
246 |
-
|
247 |
-
function speak(text, callback) {
|
248 |
-
const speech = new SpeechSynthesisUtterance(text);
|
249 |
-
speech.onend = callback;
|
250 |
-
window.speechSynthesis.speak(speech);
|
251 |
-
}
|
252 |
-
|
253 |
-
function startListeningForEmail() {
|
254 |
recognition.start();
|
255 |
recognition.onresult = function(event) {
|
256 |
-
|
257 |
-
document.getElementById('email').value = emailCaptured;
|
258 |
recognition.stop();
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
if (confirmation.includes("ok") || confirmation.includes("Next")) {
|
265 |
-
setTimeout(() => speak("Great! Now, tell me your mobile number.", startListeningForMobile), 500);
|
266 |
-
} else {
|
267 |
-
speak("Let's try again. Tell me your email.", startListeningForEmail);
|
268 |
-
}
|
269 |
-
};
|
270 |
-
});
|
271 |
};
|
272 |
}
|
273 |
-
|
274 |
-
function
|
275 |
recognition.start();
|
276 |
recognition.onresult = function(event) {
|
277 |
mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
278 |
-
document.getElementById('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
recognition.stop();
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
if (confirmation.includes("ok") || confirmation.includes("Next")) {
|
286 |
-
speak("Checking your details...", function() {
|
287 |
-
// Send captured email and mobile to backend for validation
|
288 |
-
fetch('/validate_login', {
|
289 |
-
method: 'POST',
|
290 |
-
headers: {
|
291 |
-
'Content-Type': 'application/json',
|
292 |
-
},
|
293 |
-
body: JSON.stringify({
|
294 |
-
email: emailCaptured,
|
295 |
-
mobile: mobileCaptured
|
296 |
-
})
|
297 |
-
}).then(response => response.json())
|
298 |
-
.then(data => {
|
299 |
-
if (data.success) {
|
300 |
-
speak("Login successful. Welcome!", function() {
|
301 |
-
window.location.href = "https://huggingface.co/spaces/Subbu1304/AIVoice4s"; // Redirects to menu page
|
302 |
-
});
|
303 |
-
} else {
|
304 |
-
speak(data.error || "Invalid credentials. Please try again.", function() {});
|
305 |
-
}
|
306 |
-
});
|
307 |
-
});
|
308 |
-
} else {
|
309 |
-
speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
|
310 |
-
}
|
311 |
-
};
|
312 |
-
});
|
313 |
};
|
314 |
}
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
});
|
322 |
}
|
323 |
-
|
324 |
window.onload = function () {
|
325 |
-
|
326 |
};
|
327 |
</script>
|
328 |
</body>
|
|
|
4 |
<head>
|
5 |
<meta charset="UTF-8">
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>Biryani Hub - Login or Registration</title>
|
8 |
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
|
9 |
+
<style>
|
10 |
+
body {
|
11 |
+
font-family: 'Roboto', sans-serif;
|
12 |
+
background: linear-gradient(135deg, #f4c542, #ff8f6a);
|
13 |
+
margin: 0;
|
14 |
+
display: flex;
|
15 |
+
justify-content: center;
|
16 |
+
align-items: center;
|
17 |
+
height: 100vh;
|
18 |
+
text-align: center;
|
19 |
+
}
|
20 |
+
.container {
|
21 |
+
background-color: #fff;
|
22 |
+
padding: 40px 50px;
|
23 |
+
border-radius: 10px;
|
24 |
+
width: 450px;
|
25 |
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
26 |
+
}
|
27 |
+
h1 {
|
28 |
+
font-size: 30px;
|
29 |
+
font-weight: bold;
|
30 |
+
color: #ff6a00;
|
31 |
+
}
|
32 |
+
label {
|
33 |
+
font-size: 16px;
|
34 |
+
margin-top: 20px;
|
35 |
+
display: block;
|
36 |
+
text-align: left;
|
37 |
+
font-weight: bold;
|
38 |
+
color: #333;
|
39 |
+
}
|
40 |
+
input[type="text"] {
|
41 |
+
width: 100%;
|
42 |
+
padding: 12px;
|
43 |
+
font-size: 16px;
|
44 |
+
border: 2px solid #ccc;
|
45 |
+
border-radius: 8px;
|
46 |
+
margin-top: 8px;
|
47 |
+
box-sizing: border-box;
|
48 |
+
background-color: #f9f9f9;
|
49 |
+
}
|
50 |
+
input[type="text"]:focus {
|
51 |
+
border-color: #ff6a00;
|
52 |
+
outline: none;
|
53 |
+
}
|
54 |
+
.info {
|
55 |
+
margin-top: 20px;
|
56 |
+
font-size: 16px;
|
57 |
+
color: #ff6a00;
|
58 |
+
font-weight: bold;
|
59 |
+
}
|
60 |
+
.status {
|
61 |
+
font-size: 14px;
|
62 |
+
color: gray;
|
63 |
+
margin-top: 20px;
|
64 |
+
}
|
65 |
+
.form-container {
|
66 |
+
display: flex;
|
67 |
+
justify-content: space-between;
|
68 |
+
gap: 30px;
|
69 |
+
}
|
70 |
+
.form-container > div {
|
71 |
+
width: 48%;
|
72 |
+
}
|
73 |
+
.form-section {
|
74 |
+
padding: 20px;
|
75 |
+
background-color: #f9f9f9;
|
76 |
+
border-radius: 10px;
|
77 |
+
}
|
78 |
+
.header {
|
79 |
+
font-size: 24px;
|
80 |
+
font-weight: bold;
|
81 |
+
color: #ff6a00;
|
82 |
+
}
|
83 |
+
</style>
|
84 |
</head>
|
|
|
85 |
<body>
|
86 |
<div class="container">
|
|
|
87 |
<h1>Welcome to Biryani Hub 🍽 🍗</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
+
<!-- Form Section -->
|
90 |
+
<div class="form-container">
|
91 |
+
<!-- Registration Form -->
|
92 |
+
<div class="form-section" id="registrationForm" style="display: none;">
|
93 |
+
<h2 class="header">Register</h2>
|
94 |
+
<label for="name">Your Name</label>
|
95 |
+
<input type="text" id="name" placeholder="Your name will appear here..." readonly>
|
96 |
+
|
97 |
+
<label for="email">Your Email</label>
|
98 |
+
<input type="text" id="email" placeholder="Your email will appear here..." readonly>
|
99 |
+
|
100 |
+
<label for="mobile">Your Mobile Number</label>
|
101 |
+
<input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
|
102 |
+
|
103 |
+
<p class="info" id="infoMessage">Listening 🗣🎙️...</p>
|
104 |
+
<p class="status" id="status">🔊...</p>
|
105 |
+
</div>
|
106 |
+
|
107 |
+
<!-- Login Form -->
|
108 |
+
<div class="form-section" id="loginForm" style="display: none;">
|
109 |
+
<h2 class="header">Login</h2>
|
110 |
+
<label for="loginEmail">Your Email</label>
|
111 |
+
<input type="text" id="loginEmail" placeholder="Your email will appear here..." readonly>
|
112 |
+
|
113 |
+
<label for="loginMobile">Your Mobile Number</label>
|
114 |
+
<input type="text" id="loginMobile" placeholder="Your mobile number will appear here..." readonly>
|
115 |
+
|
116 |
+
<p class="info" id="infoMessageLogin">Listening 🗣🎙️...</p>
|
117 |
+
<p class="status" id="statusLogin">🔊...</p>
|
118 |
+
</div>
|
119 |
+
</div>
|
120 |
</div>
|
121 |
|
122 |
<script>
|
|
|
124 |
let nameCaptured = "";
|
125 |
let emailCaptured = "";
|
126 |
let mobileCaptured = "";
|
127 |
+
|
128 |
if ('webkitSpeechRecognition' in window) {
|
129 |
recognition = new webkitSpeechRecognition();
|
130 |
recognition.continuous = false;
|
|
|
133 |
} else {
|
134 |
alert("Speech Recognition API is not supported in this browser.");
|
135 |
}
|
136 |
+
|
137 |
function speak(text, callback) {
|
138 |
const speech = new SpeechSynthesisUtterance(text);
|
139 |
speech.onend = callback;
|
140 |
window.speechSynthesis.speak(speech);
|
141 |
}
|
142 |
+
|
143 |
+
// Function to ask user if they want to register or login
|
144 |
+
function askLoginOrRegister() {
|
145 |
+
speak("Are you a new customer or an existing customer? Say 'new' for registration or 'existing' for login.", function() {
|
146 |
+
recognition.start();
|
147 |
+
recognition.onresult = function(event) {
|
148 |
+
let response = event.results[0][0].transcript.trim().toLowerCase();
|
149 |
+
recognition.stop();
|
150 |
+
if (response.includes("new")) {
|
151 |
+
showRegistrationForm();
|
152 |
+
} else if (response.includes("existing")) {
|
153 |
+
showLoginForm();
|
154 |
+
} else {
|
155 |
+
speak("Sorry, I didn't understand. Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
|
156 |
+
}
|
157 |
+
};
|
158 |
+
});
|
159 |
+
}
|
160 |
+
|
161 |
+
function showRegistrationForm() {
|
162 |
+
document.getElementById('registrationForm').style.display = 'block';
|
163 |
+
document.getElementById('loginForm').style.display = 'none';
|
164 |
+
speak("Please tell me your name to begin the registration.", startListeningForName);
|
165 |
+
}
|
166 |
+
|
167 |
+
function showLoginForm() {
|
168 |
+
document.getElementById('loginForm').style.display = 'block';
|
169 |
+
document.getElementById('registrationForm').style.display = 'none';
|
170 |
+
speak("Please tell me your email to begin the login process.", startListeningForLoginEmail);
|
171 |
+
}
|
172 |
+
|
173 |
+
// Capture the name for registration
|
174 |
function startListeningForName() {
|
175 |
recognition.start();
|
176 |
recognition.onresult = function(event) {
|
177 |
nameCaptured = event.results[0][0].transcript.trim();
|
178 |
document.getElementById('name').value = nameCaptured;
|
179 |
recognition.stop();
|
180 |
+
speak("You said " + nameCaptured + ". Is it correct?", confirmName);
|
181 |
};
|
182 |
}
|
183 |
+
|
184 |
function confirmName() {
|
185 |
+
recognition.start();
|
186 |
+
recognition.onresult = function(event) {
|
187 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
188 |
+
recognition.stop();
|
189 |
+
if (confirmation.includes("ok")) {
|
190 |
+
speak("Great! Now, tell me your email.", startListeningForEmail);
|
191 |
+
} else {
|
192 |
+
speak("Let's try again. Tell me your name.", startListeningForName);
|
193 |
+
}
|
194 |
+
};
|
|
|
|
|
195 |
}
|
196 |
+
|
197 |
+
// Capture email for registration
|
198 |
function startListeningForEmail() {
|
199 |
recognition.start();
|
200 |
recognition.onresult = function(event) {
|
201 |
emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
202 |
document.getElementById('email').value = emailCaptured;
|
203 |
recognition.stop();
|
204 |
+
speak("You said " + emailCaptured + ". Is it correct?", confirmEmail);
|
205 |
+
};
|
206 |
+
}
|
207 |
+
|
208 |
+
function confirmEmail() {
|
209 |
+
recognition.start();
|
210 |
+
recognition.onresult = function(event) {
|
211 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
212 |
+
recognition.stop();
|
213 |
+
if (confirmation.includes("ok")) {
|
214 |
+
speak("Great! Now, tell me your mobile number.", startListeningForMobile);
|
215 |
+
} else {
|
216 |
+
speak("Let's try again. Tell me your email.", startListeningForEmail);
|
217 |
+
}
|
218 |
};
|
219 |
}
|
220 |
+
|
221 |
+
// Capture mobile number for registration
|
222 |
function startListeningForMobile() {
|
223 |
recognition.start();
|
224 |
recognition.onresult = function(event) {
|
225 |
mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
226 |
document.getElementById('mobile').value = mobileCaptured;
|
227 |
recognition.stop();
|
228 |
+
speak("You said " + mobileCaptured + ". Is it correct?", confirmMobile);
|
229 |
+
};
|
230 |
+
}
|
231 |
+
|
232 |
+
function confirmMobile() {
|
233 |
+
recognition.start();
|
234 |
+
recognition.onresult = function(event) {
|
235 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
236 |
+
recognition.stop();
|
237 |
+
if (confirmation.includes("ok")) {
|
238 |
+
autoConfirm();
|
239 |
+
} else {
|
240 |
+
speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
|
241 |
+
}
|
242 |
};
|
243 |
}
|
244 |
+
|
245 |
+
// Confirm details and submit automatically
|
246 |
function autoConfirm() {
|
247 |
document.getElementById('confirmName').textContent = document.getElementById('name').value;
|
248 |
document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
|
|
|
250 |
document.getElementById('confirmation').style.display = 'block';
|
251 |
setTimeout(autoSubmit, 3000);
|
252 |
}
|
253 |
+
|
254 |
+
// Submit details to backend
|
255 |
function autoSubmit() {
|
256 |
var name = document.getElementById('name').value;
|
257 |
var email = document.getElementById('email').value;
|
|
|
274 |
}
|
275 |
});
|
276 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
|
278 |
+
// Start login process
|
279 |
+
function startListeningForLoginEmail() {
|
280 |
+
recognition.start();
|
281 |
+
recognition.onresult = function(event) {
|
282 |
+
emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
283 |
+
document.getElementById('loginEmail').value = emailCaptured;
|
284 |
+
recognition.stop();
|
285 |
+
speak("You said " + emailCaptured + ". Is it correct?", confirmLoginEmail);
|
286 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
|
289 |
+
function confirmLoginEmail() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
recognition.start();
|
291 |
recognition.onresult = function(event) {
|
292 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
|
|
293 |
recognition.stop();
|
294 |
+
if (confirmation.includes("ok")) {
|
295 |
+
speak("Great! Now, tell me your mobile number.", startListeningForLoginMobile);
|
296 |
+
} else {
|
297 |
+
speak("Let's try again. Tell me your email.", startListeningForLoginEmail);
|
298 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
};
|
300 |
}
|
301 |
+
|
302 |
+
function startListeningForLoginMobile() {
|
303 |
recognition.start();
|
304 |
recognition.onresult = function(event) {
|
305 |
mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
306 |
+
document.getElementById('loginMobile').value = mobileCaptured;
|
307 |
+
recognition.stop();
|
308 |
+
speak("You said " + mobileCaptured + ". Is it correct?", confirmLoginMobile);
|
309 |
+
};
|
310 |
+
}
|
311 |
+
|
312 |
+
function confirmLoginMobile() {
|
313 |
+
recognition.start();
|
314 |
+
recognition.onresult = function(event) {
|
315 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
316 |
recognition.stop();
|
317 |
+
if (confirmation.includes("ok")) {
|
318 |
+
submitLogin();
|
319 |
+
} else {
|
320 |
+
speak("Let's try again. Tell me your mobile number.", startListeningForLoginMobile);
|
321 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
};
|
323 |
}
|
324 |
+
|
325 |
+
// Submit login details to backend
|
326 |
+
function submitLogin() {
|
327 |
+
let email = document.getElementById('loginEmail').value;
|
328 |
+
let mobile = document.getElementById('loginMobile').value;
|
329 |
+
fetch('/submit_login', {
|
330 |
+
method: 'POST',
|
331 |
+
headers: { 'Content-Type': 'application/json' },
|
332 |
+
body: JSON.stringify({ email: email, mobile: mobile })
|
333 |
+
})
|
334 |
+
.then(response => response.json())
|
335 |
+
.then(data => {
|
336 |
+
speak("Login successful. Welcome back!");
|
337 |
+
// Redirect or perform other actions
|
338 |
+
})
|
339 |
+
.catch(error => {
|
340 |
+
speak("There was an error with your login. Please try again.");
|
341 |
});
|
342 |
}
|
343 |
+
|
344 |
window.onload = function () {
|
345 |
+
askLoginOrRegister();
|
346 |
};
|
347 |
</script>
|
348 |
</body>
|