lokesh341 commited on
Commit
93827eb
·
verified ·
1 Parent(s): ae736a0

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +145 -238
templates/index.html CHANGED
@@ -4,7 +4,7 @@
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
  <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
10
  </head>
@@ -63,16 +63,20 @@
63
  color: gray;
64
  margin-top: 20px;
65
  }
66
- .image-logo {
67
- width: 80px;
68
- margin-bottom: 20px;
69
- }
70
  </style>
71
 
72
  <body>
73
  <div class="container">
74
  <h1>Welcome to Biryani Hub 🍽 🍗</h1>
75
 
 
 
 
 
 
 
 
 
76
  <label for="name">Your Name</label>
77
  <input type="text" id="name" placeholder="Your name will appear here..." readonly>
78
 
@@ -85,12 +89,18 @@
85
  <p class="info" id="infoMessage">Listening 🗣🎙️...</p>
86
  <p class="status" id="status">🔊...</p>
87
  </div>
88
-
89
- <div id="confirmation" style="display: none;">
90
- <h2>Confirm Your Details:</h2>
91
- <p><strong>Name:</strong> <span id="confirmName"></span></p>
92
- <p><strong>Email:</strong> <span id="confirmEmail"></span></p>
93
- <p><strong>Phone:</strong> <span id="confirmPhone"></span></p>
 
 
 
 
 
 
94
  </div>
95
 
96
  <script>
@@ -114,300 +124,197 @@
114
  window.speechSynthesis.speak(speech);
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  function startListeningForName() {
118
  recognition.start();
119
  recognition.onresult = function(event) {
120
  nameCaptured = event.results[0][0].transcript.trim();
121
  document.getElementById('name').value = nameCaptured;
122
  recognition.stop();
123
- setTimeout(confirmName, 500);
124
  };
125
  }
126
 
127
  function confirmName() {
128
- speak("You said " + nameCaptured + ". Is it okay, or do you want to change it?", function() {
129
- recognition.start();
130
- recognition.onresult = function(event) {
131
- let confirmation = event.results[0][0].transcript.trim().toLowerCase();
132
- recognition.stop();
133
- if (confirmation.includes("ok") || confirmation.includes("next")) {
134
- setTimeout(() => speak("Great! Now, tell me your email.", startListeningForEmail), 500);
135
- } else {
136
- setTimeout(() => speak("Let's try again. Tell me your name.", startListeningForName), 500);
137
- }
138
- };
139
- });
140
  }
141
 
 
142
  function startListeningForEmail() {
143
  recognition.start();
144
  recognition.onresult = function(event) {
145
  emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
146
  document.getElementById('email').value = emailCaptured;
147
  recognition.stop();
148
- speak("You said " + emailCaptured + ". Is it correct?", function() {
149
- recognition.start();
150
- recognition.onresult = function(event) {
151
- let confirmation = event.results[0][0].transcript.trim().toLowerCase();
152
- recognition.stop();
153
- if (confirmation.includes("ok") || confirmation.includes("next")) {
154
- setTimeout(() => speak("Great! Now, tell me your mobile number.", startListeningForMobile), 500);
155
- } else {
156
- speak("Let's try again. Tell me your email.", startListeningForEmail);
157
- }
158
- };
159
- });
160
  };
161
  }
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  function startListeningForMobile() {
164
  recognition.start();
165
  recognition.onresult = function(event) {
166
  mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
167
  document.getElementById('mobile').value = mobileCaptured;
168
  recognition.stop();
169
- speak("You said " + mobileCaptured + ". Is it correct?", function() {
170
- recognition.start();
171
- recognition.onresult = function(event) {
172
- let confirmation = event.results[0][0].transcript.trim().toLowerCase();
173
- recognition.stop();
174
- if (confirmation.includes("ok") || confirmation.includes("next")) {
175
- speak("All details are captured. Confirming your registration.", function() {
176
- autoConfirm();
177
- });
178
- } else {
179
- speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
180
- }
181
- };
182
- });
183
  };
184
  }
185
 
186
- function autoConfirm() {
187
- document.getElementById('confirmName').textContent = document.getElementById('name').value;
188
- document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
189
- document.getElementById('confirmPhone').textContent = document.getElementById('mobile').value;
190
- document.getElementById('confirmation').style.display = 'block';
191
- setTimeout(autoSubmit, 3000);
 
 
 
 
 
192
  }
193
 
194
- function autoSubmit() {
195
- var name = document.getElementById('name').value;
196
- var email = document.getElementById('email').value;
197
- var phone = document.getElementById('mobile').value;
198
- fetch('/submit', {
 
199
  method: 'POST',
200
  headers: { 'Content-Type': 'application/json' },
201
- body: JSON.stringify({ name: name, email: email, phone: phone })
202
  })
203
  .then(response => response.json())
204
  .then(data => {
205
- if (data.success) {
206
- document.getElementById('status').textContent = 'Your details were submitted successfully!';
207
- document.getElementById('confirmation').style.display = 'none';
208
- speak("Your registration is complete. Thank you for registering.");
209
- setTimeout(() => location.reload(), 5000);
210
- } else {
211
- document.getElementById('status').textContent = 'There was an error submitting your details.';
212
- speak("There was an error submitting your details. Please try again.");
213
- }
214
  });
215
  }
216
 
217
- window.onload = function () {
218
- speak("Welcome to Biryani Hub. Please tell me your name to start the registration.");
219
- setTimeout(startListeningForName, 5000);
220
- };
221
- </script>
222
- </body>
223
- </html>
224
-
225
-
226
-
227
- <!DOCTYPE html>
228
- <html lang="en">
229
- <head>
230
- <meta charset="UTF-8">
231
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
232
- <title>Biryani Hub Login</title>
233
- <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
234
- <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
235
- </head>
236
-
237
- <style>
238
- body {
239
- font-family: 'Roboto', sans-serif;
240
- background: linear-gradient(135deg, #f4c542, #ff8f6a);
241
- margin: 0;
242
- display: flex;
243
- justify-content: center;
244
- align-items: center;
245
- height: 100vh;
246
- text-align: center;
247
- }
248
- .container {
249
- background-color: #87ceeb; /* Light blue */
250
- padding: 40px 50px;
251
- border-radius: 10px;
252
- width: 400px;
253
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
254
- }
255
- h1 {
256
- font-size: 30px;
257
- font-weight: bold;
258
- color: #ff6a00;
259
- }
260
- label {
261
- font-size: 16px;
262
- margin-top: 20px;
263
- display: block;
264
- text-align: left;
265
- font-weight: bold;
266
- }
267
- input[type="text"] {
268
- width: 100%;
269
- padding: 12px;
270
- font-size: 16px;
271
- border: 2px solid #ccc;
272
- border-radius: 8px;
273
- margin-top: 8px;
274
- box-sizing: border-box;
275
- }
276
- input[type="text"]:focus {
277
- border-color: #ff6a00;
278
- outline: none;
279
- }
280
- .info {
281
- margin-top: 20px;
282
- font-size: 16px;
283
- color: #ff6a00;
284
- font-weight: bold;
285
- }
286
- .status {
287
- font-size: 14px;
288
- color: gray;
289
- margin-top: 20px;
290
- }
291
- </style>
292
-
293
- <body>
294
- <div class="container">
295
- <h1>Welcome Back to Biryani Hub 🍽 🍗</h1>
296
-
297
- <label for="email">Your Email</label>
298
- <input type="text" id="email" placeholder="Your email will appear here..." readonly>
299
-
300
- <label for="mobile">Your Mobile Number</label>
301
- <input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
302
-
303
- <p class="info" id="infoMessage">Listening 🗣🎙️...</p>
304
- <p class="status" id="status">🔊...</p>
305
- </div>
306
-
307
- <div id="confirmation" style="display: none;">
308
- <h2>Confirm Your Details:</h2>
309
- <p><strong>Email:</strong> <span id="confirmEmail"></span></p>
310
- <p><strong>Phone:</strong> <span id="confirmPhone"></span></p>
311
- </div>
312
-
313
- <script>
314
- let recognition;
315
- let emailCaptured = "";
316
- let mobileCaptured = "";
317
-
318
- if ('webkitSpeechRecognition' in window) {
319
- recognition = new webkitSpeechRecognition();
320
- recognition.continuous = false;
321
- recognition.interimResults = false;
322
- recognition.lang = 'en-US';
323
- } else {
324
- alert("Speech Recognition API is not supported in this browser.");
325
- }
326
-
327
- function speak(text, callback) {
328
- const speech = new SpeechSynthesisUtterance(text);
329
- speech.onend = callback;
330
- window.speechSynthesis.speak(speech);
331
  }
332
 
333
- function startListeningForEmail() {
334
  recognition.start();
335
  recognition.onresult = function(event) {
336
- emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
337
- document.getElementById('email').value = emailCaptured;
338
  recognition.stop();
339
- speak("You said " + emailCaptured + ". Is it correct?", function() {
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("ok") || confirmation.includes("next")) {
345
- setTimeout(() => speak("Great! Now, tell me your mobile number.", startListeningForMobile), 500);
346
- } else {
347
- speak("Let's try again. Tell me your email.", startListeningForEmail);
348
- }
349
- };
350
- });
351
  };
352
  }
353
 
354
- function startListeningForMobile() {
355
  recognition.start();
356
  recognition.onresult = function(event) {
357
  mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
358
- document.getElementById('mobile').value = mobileCaptured;
359
  recognition.stop();
360
- speak("You said " + mobileCaptured + ". Is it correct?", function() {
361
- recognition.start();
362
- recognition.onresult = function(event) {
363
- let confirmation = event.results[0][0].transcript.trim().toLowerCase();
364
- recognition.stop();
365
- if (confirmation.includes("ok") || confirmation.includes("next")) {
366
- speak("All details are captured. Confirming your login.", function() {
367
- autoConfirm();
368
- });
369
- } else {
370
- speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
371
- }
372
- };
373
- });
374
  };
375
  }
376
 
377
- function autoConfirm() {
378
- document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
379
- document.getElementById('confirmPhone').textContent = document.getElementById('mobile').value;
380
- document.getElementById('confirmation').style.display = 'block';
381
- setTimeout(autoSubmit, 3000);
 
 
 
 
 
 
382
  }
383
 
384
- function autoSubmit() {
385
- var email = document.getElementById('email').value;
386
- var phone = document.getElementById('mobile').value;
387
- fetch('/login', {
 
388
  method: 'POST',
389
  headers: { 'Content-Type': 'application/json' },
390
- body: JSON.stringify({ email: email, phone: phone })
391
  })
392
  .then(response => response.json())
393
  .then(data => {
394
- if (data.success) {
395
- document.getElementById('status').textContent = 'Login successful!';
396
- document.getElementById('confirmation').style.display = 'none';
397
- speak("Your login is successful. Welcome back!");
398
- setTimeout(() => location.reload(), 5000);
399
- } else {
400
- document.getElementById('status').textContent = 'There was an error with your login.';
401
- speak("There was an error with your login. Please try again.");
402
- }
403
  });
404
  }
405
 
406
  window.onload = function () {
407
- speak("Welcome to Biryani Hub. Please tell me your email to start the login process.");
408
- setTimeout(startListeningForEmail, 5000);
409
  };
410
  </script>
411
  </body>
412
  </html>
413
-
 
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Biryani Hub</title>
8
  <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
9
  <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
10
  </head>
 
63
  color: gray;
64
  margin-top: 20px;
65
  }
 
 
 
 
66
  </style>
67
 
68
  <body>
69
  <div class="container">
70
  <h1>Welcome to Biryani Hub 🍽 🍗</h1>
71
 
72
+ <!-- Prompt for choosing between login and registration -->
73
+ <p class="info" id="infoMessage">Listening 🗣🎙️...</p>
74
+ <p class="status" id="status">🔊...</p>
75
+ </div>
76
+
77
+ <div id="registrationForm" style="display: none;">
78
+ <!-- Registration Form -->
79
+ <h2>Register</h2>
80
  <label for="name">Your Name</label>
81
  <input type="text" id="name" placeholder="Your name will appear here..." readonly>
82
 
 
89
  <p class="info" id="infoMessage">Listening 🗣🎙️...</p>
90
  <p class="status" id="status">🔊...</p>
91
  </div>
92
+
93
+ <div id="loginForm" style="display: none;">
94
+ <!-- Login Form -->
95
+ <h2>Login</h2>
96
+ <label for="loginEmail">Your Email</label>
97
+ <input type="text" id="loginEmail" placeholder="Your email will appear here..." readonly>
98
+
99
+ <label for="loginMobile">Your Mobile Number</label>
100
+ <input type="text" id="loginMobile" placeholder="Your mobile number will appear here..." readonly>
101
+
102
+ <p class="info" id="infoMessageLogin">Listening 🗣🎙️...</p>
103
+ <p class="status" id="statusLogin">🔊...</p>
104
  </div>
105
 
106
  <script>
 
124
  window.speechSynthesis.speak(speech);
125
  }
126
 
127
+ // Start by asking if the user is a new or existing customer
128
+ function askLoginOrRegister() {
129
+ speak("Are you a new customer or an existing customer? Say 'new' for registration or 'existing' for login.", function() {
130
+ recognition.start();
131
+ recognition.onresult = function(event) {
132
+ let response = event.results[0][0].transcript.trim().toLowerCase();
133
+ recognition.stop();
134
+ if (response.includes("new")) {
135
+ showRegistrationForm();
136
+ } else if (response.includes("existing")) {
137
+ showLoginForm();
138
+ } else {
139
+ speak("Sorry, I didn't understand. Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
140
+ }
141
+ };
142
+ });
143
+ }
144
+
145
+ function showRegistrationForm() {
146
+ document.getElementById('registrationForm').style.display = 'block';
147
+ document.getElementById('loginForm').style.display = 'none';
148
+ speak("Please tell me your name to begin the registration.", startListeningForName);
149
+ }
150
+
151
+ function showLoginForm() {
152
+ document.getElementById('loginForm').style.display = 'block';
153
+ document.getElementById('registrationForm').style.display = 'none';
154
+ speak("Please tell me your email to begin the login process.", startListeningForLoginEmail);
155
+ }
156
+
157
+ // Capture the name for registration
158
  function startListeningForName() {
159
  recognition.start();
160
  recognition.onresult = function(event) {
161
  nameCaptured = event.results[0][0].transcript.trim();
162
  document.getElementById('name').value = nameCaptured;
163
  recognition.stop();
164
+ speak("You said " + nameCaptured + ". Is it correct?", confirmName);
165
  };
166
  }
167
 
168
  function confirmName() {
169
+ recognition.start();
170
+ recognition.onresult = function(event) {
171
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
172
+ recognition.stop();
173
+ if (confirmation.includes("ok")) {
174
+ speak("Great! Now, tell me your email.", startListeningForEmail);
175
+ } else {
176
+ speak("Let's try again. Tell me your name.", startListeningForName);
177
+ }
178
+ };
 
 
179
  }
180
 
181
+ // Capture email for registration
182
  function startListeningForEmail() {
183
  recognition.start();
184
  recognition.onresult = function(event) {
185
  emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
186
  document.getElementById('email').value = emailCaptured;
187
  recognition.stop();
188
+ speak("You said " + emailCaptured + ". Is it correct?", confirmEmail);
 
 
 
 
 
 
 
 
 
 
 
189
  };
190
  }
191
 
192
+ function confirmEmail() {
193
+ recognition.start();
194
+ recognition.onresult = function(event) {
195
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
196
+ recognition.stop();
197
+ if (confirmation.includes("ok")) {
198
+ speak("Great! Now, tell me your mobile number.", startListeningForMobile);
199
+ } else {
200
+ speak("Let's try again. Tell me your email.", startListeningForEmail);
201
+ }
202
+ };
203
+ }
204
+
205
+ // Capture mobile number for registration
206
  function startListeningForMobile() {
207
  recognition.start();
208
  recognition.onresult = function(event) {
209
  mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
210
  document.getElementById('mobile').value = mobileCaptured;
211
  recognition.stop();
212
+ speak("You said " + mobileCaptured + ". Is it correct?", confirmMobile);
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  };
214
  }
215
 
216
+ function confirmMobile() {
217
+ recognition.start();
218
+ recognition.onresult = function(event) {
219
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
220
+ recognition.stop();
221
+ if (confirmation.includes("ok")) {
222
+ submitRegistration();
223
+ } else {
224
+ speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
225
+ }
226
+ };
227
  }
228
 
229
+ // Submit registration to backend
230
+ function submitRegistration() {
231
+ let name = document.getElementById('name').value;
232
+ let email = document.getElementById('email').value;
233
+ let mobile = document.getElementById('mobile').value;
234
+ fetch('/submit_registration', {
235
  method: 'POST',
236
  headers: { 'Content-Type': 'application/json' },
237
+ body: JSON.stringify({ name: name, email: email, mobile: mobile })
238
  })
239
  .then(response => response.json())
240
  .then(data => {
241
+ speak("Registration successful. Thank you!");
242
+ // Redirect or do further actions
243
+ })
244
+ .catch(error => {
245
+ speak("There was an error with your registration. Please try again.");
 
 
 
 
246
  });
247
  }
248
 
249
+ // Start login process (similar to registration process but only email and phone)
250
+ function startListeningForLoginEmail() {
251
+ recognition.start();
252
+ recognition.onresult = function(event) {
253
+ emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
254
+ document.getElementById('loginEmail').value = emailCaptured;
255
+ recognition.stop();
256
+ speak("You said " + emailCaptured + ". Is it correct?", confirmLoginEmail);
257
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  }
259
 
260
+ function confirmLoginEmail() {
261
  recognition.start();
262
  recognition.onresult = function(event) {
263
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
 
264
  recognition.stop();
265
+ if (confirmation.includes("ok")) {
266
+ speak("Great! Now, tell me your mobile number.", startListeningForLoginMobile);
267
+ } else {
268
+ speak("Let's try again. Tell me your email.", startListeningForLoginEmail);
269
+ }
 
 
 
 
 
 
 
270
  };
271
  }
272
 
273
+ function startListeningForLoginMobile() {
274
  recognition.start();
275
  recognition.onresult = function(event) {
276
  mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
277
+ document.getElementById('loginMobile').value = mobileCaptured;
278
  recognition.stop();
279
+ speak("You said " + mobileCaptured + ". Is it correct?", confirmLoginMobile);
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  };
281
  }
282
 
283
+ function confirmLoginMobile() {
284
+ recognition.start();
285
+ recognition.onresult = function(event) {
286
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
287
+ recognition.stop();
288
+ if (confirmation.includes("ok")) {
289
+ submitLogin();
290
+ } else {
291
+ speak("Let's try again. Tell me your mobile number.", startListeningForLoginMobile);
292
+ }
293
+ };
294
  }
295
 
296
+ // Submit login details to backend
297
+ function submitLogin() {
298
+ let email = document.getElementById('loginEmail').value;
299
+ let mobile = document.getElementById('loginMobile').value;
300
+ fetch('/submit_login', {
301
  method: 'POST',
302
  headers: { 'Content-Type': 'application/json' },
303
+ body: JSON.stringify({ email: email, mobile: mobile })
304
  })
305
  .then(response => response.json())
306
  .then(data => {
307
+ speak("Login successful. Welcome back!");
308
+ // Redirect or perform other actions
309
+ })
310
+ .catch(error => {
311
+ speak("There was an error with your login. Please try again.");
 
 
 
 
312
  });
313
  }
314
 
315
  window.onload = function () {
316
+ askLoginOrRegister();
 
317
  };
318
  </script>
319
  </body>
320
  </html>