Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +144 -6
templates/index.html
CHANGED
@@ -4,11 +4,83 @@
|
|
4 |
<head>
|
5 |
<meta charset="UTF-8">
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
-
<title>Biryani Hub
|
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 |
<style>
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
</style>
|
13 |
</head>
|
14 |
<body>
|
@@ -18,7 +90,7 @@
|
|
18 |
<!-- Form Section -->
|
19 |
<div class="form-container">
|
20 |
<!-- Registration Form -->
|
21 |
-
<div class="form-section" id="registrationForm" style="display:
|
22 |
<h2 class="header">Register</h2>
|
23 |
<label for="name">Your Name</label>
|
24 |
<input type="text" id="name" placeholder="Your name will appear here..." readonly>
|
@@ -69,7 +141,7 @@
|
|
69 |
window.speechSynthesis.speak(speech);
|
70 |
}
|
71 |
|
72 |
-
//
|
73 |
function askLoginOrRegister() {
|
74 |
speak("Are you a new customer or an existing customer? Say 'new' for registration or 'existing' for login.", function() {
|
75 |
recognition.start();
|
@@ -180,7 +252,7 @@
|
|
180 |
setTimeout(autoSubmit, 3000);
|
181 |
}
|
182 |
|
183 |
-
// Submit details to
|
184 |
function autoSubmit() {
|
185 |
var name = document.getElementById('name').value;
|
186 |
var email = document.getElementById('email').value;
|
@@ -204,6 +276,72 @@
|
|
204 |
});
|
205 |
}
|
206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
window.onload = function () {
|
208 |
askLoginOrRegister();
|
209 |
};
|
|
|
4 |
<head>
|
5 |
<meta charset="UTF-8">
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>Biryani Hub - Registration & 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; /* White background for contrast */
|
22 |
+
padding: 40px 50px;
|
23 |
+
border-radius: 10px;
|
24 |
+
width: 450px;
|
25 |
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
26 |
+
margin-right: 20px;
|
27 |
+
}
|
28 |
+
h1 {
|
29 |
+
font-size: 30px;
|
30 |
+
font-weight: bold;
|
31 |
+
color: #ff6a00;
|
32 |
+
}
|
33 |
+
label {
|
34 |
+
font-size: 16px;
|
35 |
+
margin-top: 20px;
|
36 |
+
display: block;
|
37 |
+
text-align: left;
|
38 |
+
font-weight: bold;
|
39 |
+
color: #333;
|
40 |
+
}
|
41 |
+
input[type="text"] {
|
42 |
+
width: 100%;
|
43 |
+
padding: 12px;
|
44 |
+
font-size: 16px;
|
45 |
+
border: 2px solid #ccc;
|
46 |
+
border-radius: 8px;
|
47 |
+
margin-top: 8px;
|
48 |
+
box-sizing: border-box;
|
49 |
+
background-color: #f9f9f9;
|
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 |
+
.form-container {
|
67 |
+
display: flex;
|
68 |
+
justify-content: space-between;
|
69 |
+
gap: 30px;
|
70 |
+
}
|
71 |
+
.form-container > div {
|
72 |
+
width: 48%;
|
73 |
+
}
|
74 |
+
.form-section {
|
75 |
+
padding: 20px;
|
76 |
+
background-color: #f9f9f9;
|
77 |
+
border-radius: 10px;
|
78 |
+
}
|
79 |
+
.header {
|
80 |
+
font-size: 24px;
|
81 |
+
font-weight: bold;
|
82 |
+
color: #ff6a00;
|
83 |
+
}
|
84 |
</style>
|
85 |
</head>
|
86 |
<body>
|
|
|
90 |
<!-- Form Section -->
|
91 |
<div class="form-container">
|
92 |
<!-- Registration Form -->
|
93 |
+
<div class="form-section" id="registrationForm" style="display: none;">
|
94 |
<h2 class="header">Register</h2>
|
95 |
<label for="name">Your Name</label>
|
96 |
<input type="text" id="name" placeholder="Your name will appear here..." readonly>
|
|
|
141 |
window.speechSynthesis.speak(speech);
|
142 |
}
|
143 |
|
144 |
+
// Function to ask user if they want to register or login
|
145 |
function askLoginOrRegister() {
|
146 |
speak("Are you a new customer or an existing customer? Say 'new' for registration or 'existing' for login.", function() {
|
147 |
recognition.start();
|
|
|
252 |
setTimeout(autoSubmit, 3000);
|
253 |
}
|
254 |
|
255 |
+
// Submit details to backend
|
256 |
function autoSubmit() {
|
257 |
var name = document.getElementById('name').value;
|
258 |
var email = document.getElementById('email').value;
|
|
|
276 |
});
|
277 |
}
|
278 |
|
279 |
+
// Start login process
|
280 |
+
function startListeningForLoginEmail() {
|
281 |
+
recognition.start();
|
282 |
+
recognition.onresult = function(event) {
|
283 |
+
emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
284 |
+
document.getElementById('loginEmail').value = emailCaptured;
|
285 |
+
recognition.stop();
|
286 |
+
speak("You said " + emailCaptured + ". Is it correct?", confirmLoginEmail);
|
287 |
+
};
|
288 |
+
}
|
289 |
+
|
290 |
+
function confirmLoginEmail() {
|
291 |
+
recognition.start();
|
292 |
+
recognition.onresult = function(event) {
|
293 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
294 |
+
recognition.stop();
|
295 |
+
if (confirmation.includes("ok")) {
|
296 |
+
speak("Great! Now, tell me your mobile number.", startListeningForLoginMobile);
|
297 |
+
} else {
|
298 |
+
speak("Let's try again. Tell me your email.", startListeningForLoginEmail);
|
299 |
+
}
|
300 |
+
};
|
301 |
+
}
|
302 |
+
|
303 |
+
function startListeningForLoginMobile() {
|
304 |
+
recognition.start();
|
305 |
+
recognition.onresult = function(event) {
|
306 |
+
mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
307 |
+
document.getElementById('loginMobile').value = mobileCaptured;
|
308 |
+
recognition.stop();
|
309 |
+
speak("You said " + mobileCaptured + ". Is it correct?", confirmLoginMobile);
|
310 |
+
};
|
311 |
+
}
|
312 |
+
|
313 |
+
function confirmLoginMobile() {
|
314 |
+
recognition.start();
|
315 |
+
recognition.onresult = function(event) {
|
316 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
317 |
+
recognition.stop();
|
318 |
+
if (confirmation.includes("ok")) {
|
319 |
+
submitLogin();
|
320 |
+
} else {
|
321 |
+
speak("Let's try again. Tell me your mobile number.", startListeningForLoginMobile);
|
322 |
+
}
|
323 |
+
};
|
324 |
+
}
|
325 |
+
|
326 |
+
// Submit login details to backend
|
327 |
+
function submitLogin() {
|
328 |
+
let email = document.getElementById('loginEmail').value;
|
329 |
+
let mobile = document.getElementById('loginMobile').value;
|
330 |
+
fetch('/submit_login', {
|
331 |
+
method: 'POST',
|
332 |
+
headers: { 'Content-Type': 'application/json' },
|
333 |
+
body: JSON.stringify({ email: email, mobile: mobile })
|
334 |
+
})
|
335 |
+
.then(response => response.json())
|
336 |
+
.then(data => {
|
337 |
+
speak("Login successful. Welcome back!");
|
338 |
+
// Redirect or perform other actions
|
339 |
+
})
|
340 |
+
.catch(error => {
|
341 |
+
speak("There was an error with your login. Please try again.");
|
342 |
+
});
|
343 |
+
}
|
344 |
+
|
345 |
window.onload = function () {
|
346 |
askLoginOrRegister();
|
347 |
};
|