lokesh341 commited on
Commit
ae736a0
·
verified ·
1 Parent(s): 57e1375

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +190 -0
templates/index.html CHANGED
@@ -221,3 +221,193 @@
221
  </script>
222
  </body>
223
  </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+