Update templates/index.html
Browse files- templates/index.html +34 -187
templates/index.html
CHANGED
@@ -4,154 +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 -
|
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">
|
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>
|
156 |
let recognition;
|
157 |
let nameCaptured = "";
|
@@ -164,7 +17,7 @@
|
|
164 |
recognition.interimResults = false;
|
165 |
recognition.lang = 'en-US';
|
166 |
} else {
|
167 |
-
alert("Speech Recognition API
|
168 |
}
|
169 |
|
170 |
function speak(text, callback) {
|
@@ -173,37 +26,48 @@
|
|
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?
|
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 |
-
|
185 |
} else if (response.includes("existing")) {
|
186 |
showLoginForm();
|
187 |
} else {
|
188 |
-
speak("
|
189 |
}
|
190 |
};
|
191 |
});
|
192 |
}
|
193 |
|
194 |
-
function
|
195 |
-
document.getElementById('
|
196 |
-
document.getElementById('
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
}
|
199 |
|
200 |
-
function
|
201 |
-
|
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) {
|
@@ -220,14 +84,13 @@
|
|
220 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
221 |
recognition.stop();
|
222 |
if (confirmation.includes("ok")) {
|
223 |
-
speak("
|
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) {
|
@@ -244,14 +107,13 @@
|
|
244 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
245 |
recognition.stop();
|
246 |
if (confirmation.includes("ok")) {
|
247 |
-
speak("
|
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) {
|
@@ -268,42 +130,25 @@
|
|
268 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
269 |
recognition.stop();
|
270 |
if (confirmation.includes("ok")) {
|
271 |
-
|
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;
|
282 |
-
document.getElementById('confirmPhone').textContent = document.getElementById('mobile').value;
|
283 |
-
document.getElementById('confirmation').style.display = 'block';
|
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;
|
291 |
-
var phone = document.getElementById('mobile').value;
|
292 |
fetch('/submit', {
|
293 |
method: 'POST',
|
294 |
headers: { 'Content-Type': 'application/json' },
|
295 |
-
body: JSON.stringify({ name:
|
296 |
})
|
297 |
.then(response => response.json())
|
298 |
.then(data => {
|
299 |
if (data.success) {
|
300 |
-
|
301 |
-
document.getElementById('confirmation').style.display = 'none';
|
302 |
-
speak("Your registration is complete. Thank you for registering.");
|
303 |
-
setTimeout(() => location.reload(), 5000);
|
304 |
} else {
|
305 |
-
|
306 |
-
speak("There was an error submitting your details. Please try again.");
|
307 |
}
|
308 |
});
|
309 |
}
|
@@ -312,5 +157,7 @@
|
|
312 |
askLoginOrRegister();
|
313 |
};
|
314 |
</script>
|
|
|
|
|
315 |
</body>
|
316 |
</html>
|
|
|
4 |
<head>
|
5 |
<meta charset="UTF-8">
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>Biryani Hub - Voice Login & Register</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
<script>
|
9 |
let recognition;
|
10 |
let nameCaptured = "";
|
|
|
17 |
recognition.interimResults = false;
|
18 |
recognition.lang = 'en-US';
|
19 |
} else {
|
20 |
+
alert("Speech Recognition API not supported in this browser.");
|
21 |
}
|
22 |
|
23 |
function speak(text, callback) {
|
|
|
26 |
window.speechSynthesis.speak(speech);
|
27 |
}
|
28 |
|
|
|
29 |
function askLoginOrRegister() {
|
30 |
+
speak("Are you a new customer or an existing customer?", function() {
|
31 |
recognition.start();
|
32 |
recognition.onresult = function(event) {
|
33 |
let response = event.results[0][0].transcript.trim().toLowerCase();
|
34 |
recognition.stop();
|
35 |
if (response.includes("new")) {
|
36 |
+
checkIfUserExists();
|
37 |
} else if (response.includes("existing")) {
|
38 |
showLoginForm();
|
39 |
} else {
|
40 |
+
speak("Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
|
41 |
}
|
42 |
};
|
43 |
});
|
44 |
}
|
45 |
|
46 |
+
function checkIfUserExists() {
|
47 |
+
var email = document.getElementById('email').value;
|
48 |
+
var phone = document.getElementById('mobile').value;
|
49 |
+
|
50 |
+
fetch('/login', {
|
51 |
+
method: 'POST',
|
52 |
+
headers: { 'Content-Type': 'application/json' },
|
53 |
+
body: JSON.stringify({ email: email, phone_number: phone })
|
54 |
+
})
|
55 |
+
.then(response => response.json())
|
56 |
+
.then(data => {
|
57 |
+
if (data.success) {
|
58 |
+
speak("You are already registered. Logging you in now.");
|
59 |
+
autoLoginSubmit();
|
60 |
+
} else {
|
61 |
+
speak("Please provide your details for registration.");
|
62 |
+
showRegistrationForm();
|
63 |
+
}
|
64 |
+
});
|
65 |
}
|
66 |
|
67 |
+
function showRegistrationForm() {
|
68 |
+
speak("Please tell me your name.", startListeningForName);
|
|
|
|
|
69 |
}
|
70 |
|
|
|
71 |
function startListeningForName() {
|
72 |
recognition.start();
|
73 |
recognition.onresult = function(event) {
|
|
|
84 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
85 |
recognition.stop();
|
86 |
if (confirmation.includes("ok")) {
|
87 |
+
speak("Now, tell me your email.", startListeningForEmail);
|
88 |
} else {
|
89 |
speak("Let's try again. Tell me your name.", startListeningForName);
|
90 |
}
|
91 |
};
|
92 |
}
|
93 |
|
|
|
94 |
function startListeningForEmail() {
|
95 |
recognition.start();
|
96 |
recognition.onresult = function(event) {
|
|
|
107 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
108 |
recognition.stop();
|
109 |
if (confirmation.includes("ok")) {
|
110 |
+
speak("Now, tell me your mobile number.", startListeningForMobile);
|
111 |
} else {
|
112 |
speak("Let's try again. Tell me your email.", startListeningForEmail);
|
113 |
}
|
114 |
};
|
115 |
}
|
116 |
|
|
|
117 |
function startListeningForMobile() {
|
118 |
recognition.start();
|
119 |
recognition.onresult = function(event) {
|
|
|
130 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
131 |
recognition.stop();
|
132 |
if (confirmation.includes("ok")) {
|
133 |
+
autoSubmit();
|
134 |
} else {
|
135 |
speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
|
136 |
}
|
137 |
};
|
138 |
}
|
139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
function autoSubmit() {
|
|
|
|
|
|
|
141 |
fetch('/submit', {
|
142 |
method: 'POST',
|
143 |
headers: { 'Content-Type': 'application/json' },
|
144 |
+
body: JSON.stringify({ name: nameCaptured, email: emailCaptured, phone: mobileCaptured })
|
145 |
})
|
146 |
.then(response => response.json())
|
147 |
.then(data => {
|
148 |
if (data.success) {
|
149 |
+
speak("Registration complete. Thank you!");
|
|
|
|
|
|
|
150 |
} else {
|
151 |
+
speak(data.message);
|
|
|
152 |
}
|
153 |
});
|
154 |
}
|
|
|
157 |
askLoginOrRegister();
|
158 |
};
|
159 |
</script>
|
160 |
+
</head>
|
161 |
+
<body>
|
162 |
</body>
|
163 |
</html>
|