lokesh341 commited on
Commit
cc4f4bc
·
verified ·
1 Parent(s): 72a81f7

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +281 -122
templates/index.html CHANGED
@@ -4,93 +4,152 @@
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>
11
-
12
- <style>
13
- body {
14
- font-family: 'Roboto', sans-serif;
15
- background: linear-gradient(135deg, #f4c542, #ff8f6a);
16
- margin: 0;
17
- display: flex;
18
- justify-content: center;
19
- align-items: center;
20
- height: 100vh;
21
- text-align: center;
22
- }
23
- .container {
24
- background-color: #87ceeb; /* Light blue */
25
- padding: 40px 50px;
26
- border-radius: 10px;
27
- width: 400px;
28
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
29
- }
30
- h1 {
31
- font-size: 30px;
32
- font-weight: bold;
33
- color: #ff6a00;
34
- }
35
- label {
36
- font-size: 16px;
37
- margin-top: 20px;
38
- display: block;
39
- text-align: left;
40
- font-weight: bold;
41
- }
42
- input[type="text"] {
43
- width: 100%;
44
- padding: 12px;
45
- font-size: 16px;
46
- border: 2px solid #ccc;
47
- border-radius: 8px;
48
- margin-top: 8px;
49
- box-sizing: border-box;
50
- }
51
- input[type="text"]:focus {
52
- border-color: #ff6a00;
53
- outline: none;
54
- }
55
- .info {
56
- margin-top: 20px;
57
- font-size: 16px;
58
- color: #ff6a00;
59
- font-weight: bold;
60
- }
61
- .status {
62
- font-size: 14px;
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
-
79
- <label for="email">Your Email</label>
80
- <input type="text" id="email" placeholder="Your email will appear here..." readonly>
81
-
82
- <label for="mobile">Your Mobile Number</label>
83
- <input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
84
-
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,75 +173,109 @@
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;
@@ -191,6 +284,7 @@
191
  setTimeout(autoSubmit, 3000);
192
  }
193
 
 
194
  function autoSubmit() {
195
  var name = document.getElementById('name').value;
196
  var email = document.getElementById('email').value;
@@ -214,9 +308,74 @@
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>
 
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Biryani Hub - Register & Login</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: 500px;
25
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
26
+ display: flex;
27
+ justify-content: space-between;
28
+ }
29
+ .form-container {
30
+ width: 48%;
31
+ }
32
+ h1 {
33
+ font-size: 30px;
34
+ font-weight: bold;
35
+ color: #ff6a00;
36
+ }
37
+ label {
38
+ font-size: 16px;
39
+ margin-top: 20px;
40
+ display: block;
41
+ text-align: left;
42
+ font-weight: bold;
43
+ color: #333;
44
+ }
45
+ input[type="text"] {
46
+ width: 100%;
47
+ padding: 12px;
48
+ font-size: 16px;
49
+ border: 2px solid #ccc;
50
+ border-radius: 8px;
51
+ margin-top: 8px;
52
+ box-sizing: border-box;
53
+ background-color: #f9f9f9;
54
+ }
55
+ input[type="text"]:focus {
56
+ border-color: #ff6a00;
57
+ outline: none;
58
+ }
59
+ .info {
60
+ margin-top: 20px;
61
+ font-size: 16px;
62
+ color: #ff6a00;
63
+ font-weight: bold;
64
+ }
65
+ .status {
66
+ font-size: 14px;
67
+ color: gray;
68
+ margin-top: 20px;
69
+ }
70
+ .header {
71
+ font-size: 24px;
72
+ font-weight: bold;
73
+ color: #ff6a00;
74
+ margin-bottom: 20px;
75
+ }
76
+ .form-section {
77
+ padding: 20px;
78
+ background-color: #f9f9f9;
79
+ border-radius: 10px;
80
+ }
81
+ #confirmation {
82
+ display: none;
83
+ margin-top: 20px;
84
+ background-color: #f9f9f9;
85
+ padding: 20px;
86
+ border-radius: 10px;
87
+ }
88
+ #confirmation h2 {
89
+ font-size: 20px;
90
+ font-weight: bold;
91
+ }
92
+ .confirm-details {
93
+ margin: 10px 0;
94
+ }
95
+ .confirm-button {
96
+ padding: 10px 20px;
97
+ background-color: #ff6a00;
98
+ color: white;
99
+ border: none;
100
+ border-radius: 5px;
101
+ cursor: pointer;
102
+ }
103
+ .confirm-button:hover {
104
+ background-color: #e65e00;
105
+ }
106
+ </style>
107
  </head>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  <body>
109
  <div class="container">
110
+ <!-- Register Section -->
111
+ <div class="form-container" id="registrationForm" style="display: none;">
112
+ <h1>Welcome to Biryani Hub 🍽 🍗</h1>
113
+ <div class="form-section">
114
+ <h2 class="header">Register</h2>
115
+ <label for="name">Your Name</label>
116
+ <input type="text" id="name" placeholder="Your name will appear here..." readonly>
117
+
118
+ <label for="email">Your Email</label>
119
+ <input type="text" id="email" placeholder="Your email will appear here..." readonly>
120
+
121
+ <label for="mobile">Your Mobile Number</label>
122
+ <input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
123
+
124
+ <p class="info" id="infoMessage">Listening 🗣🎙️...</p>
125
+ <p class="status" id="status">🔊...</p>
126
+ </div>
127
+ </div>
128
+
129
+ <!-- Login Section -->
130
+ <div class="form-container" id="loginForm" style="display: none;">
131
+ <h1>Welcome to Biryani Hub 🍽 🍗</h1>
132
+ <div class="form-section">
133
+ <h2 class="header">Login</h2>
134
+ <label for="loginEmail">Your Email</label>
135
+ <input type="text" id="loginEmail" placeholder="Your email will appear here..." readonly>
136
+
137
+ <label for="loginMobile">Your Mobile Number</label>
138
+ <input type="text" id="loginMobile" placeholder="Your mobile number will appear here..." readonly>
139
+
140
+ <p class="info" id="infoMessageLogin">Listening 🗣🎙️...</p>
141
+ <p class="status" id="statusLogin">🔊...</p>
142
+ </div>
143
+ </div>
144
  </div>
145
+
146
+ <!-- Confirmation Section -->
147
+ <div id="confirmation">
148
  <h2>Confirm Your Details:</h2>
149
+ <p class="confirm-details"><strong>Name:</strong> <span id="confirmName"></span></p>
150
+ <p class="confirm-details"><strong>Email:</strong> <span id="confirmEmail"></span></p>
151
+ <p class="confirm-details"><strong>Phone:</strong> <span id="confirmPhone"></span></p>
152
+ <button class="confirm-button" onclick="autoSubmit()">Confirm</button>
153
  </div>
154
 
155
  <script>
 
173
  window.speechSynthesis.speak(speech);
174
  }
175
 
176
+ // Ask the user if they want to register or login
177
+ function askLoginOrRegister() {
178
+ speak("Are you a new customer or an existing customer? Say 'new' for registration or 'existing' for login.", function() {
179
+ recognition.start();
180
+ recognition.onresult = function(event) {
181
+ let response = event.results[0][0].transcript.trim().toLowerCase();
182
+ recognition.stop();
183
+ if (response.includes("new")) {
184
+ showRegistrationForm();
185
+ } else if (response.includes("existing")) {
186
+ showLoginForm();
187
+ } else {
188
+ speak("Sorry, I didn't understand. Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
189
+ }
190
+ };
191
+ });
192
+ }
193
+
194
+ function showRegistrationForm() {
195
+ document.getElementById('registrationForm').style.display = 'block';
196
+ document.getElementById('loginForm').style.display = 'none';
197
+ speak("Please tell me your name to begin the registration.", startListeningForName);
198
+ }
199
+
200
+ function showLoginForm() {
201
+ document.getElementById('loginForm').style.display = 'block';
202
+ document.getElementById('registrationForm').style.display = 'none';
203
+ speak("Please tell me your email to begin the login process.", startListeningForLoginEmail);
204
+ }
205
+
206
+ // Capture the name for registration
207
  function startListeningForName() {
208
  recognition.start();
209
  recognition.onresult = function(event) {
210
  nameCaptured = event.results[0][0].transcript.trim();
211
  document.getElementById('name').value = nameCaptured;
212
  recognition.stop();
213
+ speak("You said " + nameCaptured + ". Is it correct?", confirmName);
214
  };
215
  }
216
 
217
  function confirmName() {
218
+ recognition.start();
219
+ recognition.onresult = function(event) {
220
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
221
+ recognition.stop();
222
+ if (confirmation.includes("ok")) {
223
+ speak("Great! Now, tell me your email.", startListeningForEmail);
224
+ } else {
225
+ speak("Let's try again. Tell me your name.", startListeningForName);
226
+ }
227
+ };
 
 
228
  }
229
 
230
+ // Capture email for registration
231
  function startListeningForEmail() {
232
  recognition.start();
233
  recognition.onresult = function(event) {
234
  emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
235
  document.getElementById('email').value = emailCaptured;
236
  recognition.stop();
237
+ speak("You said " + emailCaptured + ". Is it correct?", confirmEmail);
 
 
 
 
 
 
 
 
 
 
 
238
  };
239
  }
240
 
241
+ function confirmEmail() {
242
+ recognition.start();
243
+ recognition.onresult = function(event) {
244
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
245
+ recognition.stop();
246
+ if (confirmation.includes("ok")) {
247
+ speak("Great! Now, tell me your mobile number.", startListeningForMobile);
248
+ } else {
249
+ speak("Let's try again. Tell me your email.", startListeningForEmail);
250
+ }
251
+ };
252
+ }
253
+
254
+ // Capture mobile number for registration
255
  function startListeningForMobile() {
256
  recognition.start();
257
  recognition.onresult = function(event) {
258
  mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
259
  document.getElementById('mobile').value = mobileCaptured;
260
  recognition.stop();
261
+ speak("You said " + mobileCaptured + ". Is it correct?", confirmMobile);
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  };
263
  }
264
 
265
+ function confirmMobile() {
266
+ recognition.start();
267
+ recognition.onresult = function(event) {
268
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
269
+ recognition.stop();
270
+ if (confirmation.includes("ok")) {
271
+ autoConfirm();
272
+ } else {
273
+ speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
274
+ }
275
+ };
276
+ }
277
+
278
+ // Confirm details and submit automatically
279
  function autoConfirm() {
280
  document.getElementById('confirmName').textContent = document.getElementById('name').value;
281
  document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
 
284
  setTimeout(autoSubmit, 3000);
285
  }
286
 
287
+ // Submit details to backend
288
  function autoSubmit() {
289
  var name = document.getElementById('name').value;
290
  var email = document.getElementById('email').value;
 
308
  });
309
  }
310
 
311
+ // Start login process
312
+ function startListeningForLoginEmail() {
313
+ recognition.start();
314
+ recognition.onresult = function(event) {
315
+ emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
316
+ document.getElementById('loginEmail').value = emailCaptured;
317
+ recognition.stop();
318
+ speak("You said " + emailCaptured + ". Is it correct?", confirmLoginEmail);
319
+ };
320
+ }
321
+
322
+ function confirmLoginEmail() {
323
+ recognition.start();
324
+ recognition.onresult = function(event) {
325
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
326
+ recognition.stop();
327
+ if (confirmation.includes("ok")) {
328
+ speak("Great! Now, tell me your mobile number.", startListeningForLoginMobile);
329
+ } else {
330
+ speak("Let's try again. Tell me your email.", startListeningForLoginEmail);
331
+ }
332
+ };
333
+ }
334
+
335
+ function startListeningForLoginMobile() {
336
+ recognition.start();
337
+ recognition.onresult = function(event) {
338
+ mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
339
+ document.getElementById('loginMobile').value = mobileCaptured;
340
+ recognition.stop();
341
+ speak("You said " + mobileCaptured + ". Is it correct?", confirmLoginMobile);
342
+ };
343
+ }
344
+
345
+ function confirmLoginMobile() {
346
+ recognition.start();
347
+ recognition.onresult = function(event) {
348
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
349
+ recognition.stop();
350
+ if (confirmation.includes("ok")) {
351
+ submitLogin();
352
+ } else {
353
+ speak("Let's try again. Tell me your mobile number.", startListeningForLoginMobile);
354
+ }
355
+ };
356
+ }
357
+
358
+ // Submit login details to backend
359
+ function submitLogin() {
360
+ let email = document.getElementById('loginEmail').value;
361
+ let mobile = document.getElementById('loginMobile').value;
362
+ fetch('/submit_login', {
363
+ method: 'POST',
364
+ headers: { 'Content-Type': 'application/json' },
365
+ body: JSON.stringify({ email: email, mobile: mobile })
366
+ })
367
+ .then(response => response.json())
368
+ .then(data => {
369
+ speak("Login successful. Welcome back!");
370
+ // Redirect or perform other actions
371
+ })
372
+ .catch(error => {
373
+ speak("There was an error with your login. Please try again.");
374
+ });
375
+ }
376
+
377
  window.onload = function () {
378
+ askLoginOrRegister();
 
379
  };
380
  </script>
381
  </body>