Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +50 -309
templates/index.html
CHANGED
@@ -4,346 +4,87 @@
|
|
4 |
<head>
|
5 |
<meta charset="UTF-8">
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
-
<title>
|
8 |
-
<link
|
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: 450px;
|
25 |
-
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
26 |
-
}
|
27 |
-
h1 {
|
28 |
-
font-size: 30px;
|
29 |
-
font-weight: bold;
|
30 |
-
color: #ff6a00;
|
31 |
-
}
|
32 |
-
label {
|
33 |
-
font-size: 16px;
|
34 |
-
margin-top: 20px;
|
35 |
-
display: block;
|
36 |
-
text-align: left;
|
37 |
-
font-weight: bold;
|
38 |
-
color: #333;
|
39 |
-
}
|
40 |
-
input[type="text"] {
|
41 |
-
width: 100%;
|
42 |
-
padding: 12px;
|
43 |
-
font-size: 16px;
|
44 |
-
border: 2px solid #ccc;
|
45 |
-
border-radius: 8px;
|
46 |
-
margin-top: 8px;
|
47 |
-
box-sizing: border-box;
|
48 |
-
background-color: #f9f9f9;
|
49 |
-
}
|
50 |
-
input[type="text"]:focus {
|
51 |
-
border-color: #ff6a00;
|
52 |
-
outline: none;
|
53 |
-
}
|
54 |
-
.info {
|
55 |
-
margin-top: 20px;
|
56 |
-
font-size: 16px;
|
57 |
-
color: #ff6a00;
|
58 |
-
font-weight: bold;
|
59 |
-
}
|
60 |
-
.status {
|
61 |
-
font-size: 14px;
|
62 |
-
color: gray;
|
63 |
-
margin-top: 20px;
|
64 |
-
}
|
65 |
-
.form-container {
|
66 |
-
display: flex;
|
67 |
-
justify-content: space-between;
|
68 |
-
gap: 30px;
|
69 |
-
}
|
70 |
-
.form-container > div {
|
71 |
-
width: 48%;
|
72 |
-
}
|
73 |
-
.form-section {
|
74 |
-
padding: 20px;
|
75 |
-
background-color: #f9f9f9;
|
76 |
-
border-radius: 10px;
|
77 |
-
}
|
78 |
-
.header {
|
79 |
-
font-size: 24px;
|
80 |
-
font-weight: bold;
|
81 |
-
color: #ff6a00;
|
82 |
-
}
|
83 |
-
</style>
|
84 |
</head>
|
85 |
<body>
|
|
|
86 |
<div class="container">
|
87 |
-
<
|
88 |
|
89 |
-
<!--
|
90 |
-
<div class="
|
91 |
-
|
92 |
-
<
|
93 |
-
<h2 class="header">Register</h2>
|
94 |
-
<label for="name">Your Name</label>
|
95 |
-
<input type="text" id="name" placeholder="Your name will appear here..." readonly>
|
96 |
-
|
97 |
-
<label for="email">Your Email</label>
|
98 |
-
<input type="text" id="email" placeholder="Your email will appear here..." readonly>
|
99 |
-
|
100 |
-
<label for="mobile">Your Mobile Number</label>
|
101 |
-
<input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
</div>
|
106 |
|
107 |
-
|
108 |
-
<
|
109 |
-
<h2 class="header">Login</h2>
|
110 |
-
<label for="loginEmail">Your Email</label>
|
111 |
-
<input type="text" id="loginEmail" placeholder="Your email will appear here..." readonly>
|
112 |
-
|
113 |
-
<label for="loginMobile">Your Mobile Number</label>
|
114 |
-
<input type="text" id="loginMobile" placeholder="Your mobile number will appear here..." readonly>
|
115 |
|
116 |
-
|
117 |
-
|
118 |
-
</div>
|
119 |
</div>
|
120 |
-
</div>
|
121 |
-
|
122 |
-
<script>
|
123 |
-
let recognition;
|
124 |
-
let nameCaptured = "";
|
125 |
-
let emailCaptured = "";
|
126 |
-
let mobileCaptured = "";
|
127 |
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
} else {
|
134 |
-
alert("Speech Recognition API is not supported in this browser.");
|
135 |
-
}
|
136 |
-
|
137 |
-
function speak(text, callback) {
|
138 |
-
const speech = new SpeechSynthesisUtterance(text);
|
139 |
-
speech.onend = callback;
|
140 |
-
window.speechSynthesis.speak(speech);
|
141 |
-
}
|
142 |
|
143 |
-
|
144 |
-
|
145 |
-
speak("Are you a new customer or an existing customer? Say 'new' for registration or 'existing' for login.", function() {
|
146 |
-
recognition.start();
|
147 |
-
recognition.onresult = function(event) {
|
148 |
-
let response = event.results[0][0].transcript.trim().toLowerCase();
|
149 |
-
recognition.stop();
|
150 |
-
if (response.includes("new")) {
|
151 |
-
showRegistrationForm();
|
152 |
-
} else if (response.includes("existing")) {
|
153 |
-
showLoginForm();
|
154 |
-
} else {
|
155 |
-
speak("Sorry, I didn't understand. Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
|
156 |
-
}
|
157 |
-
};
|
158 |
-
});
|
159 |
-
}
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
speak("Please tell me your name to begin the registration.", startListeningForName);
|
165 |
-
}
|
166 |
-
|
167 |
-
function showLoginForm() {
|
168 |
-
document.getElementById('loginForm').style.display = 'block';
|
169 |
-
document.getElementById('registrationForm').style.display = 'none';
|
170 |
-
speak("Please tell me your email to begin the login process.", startListeningForLoginEmail);
|
171 |
-
}
|
172 |
-
|
173 |
-
// Capture the name for registration
|
174 |
-
function startListeningForName() {
|
175 |
-
recognition.start();
|
176 |
-
recognition.onresult = function(event) {
|
177 |
-
nameCaptured = event.results[0][0].transcript.trim();
|
178 |
-
document.getElementById('name').value = nameCaptured;
|
179 |
-
recognition.stop();
|
180 |
-
speak("You said " + nameCaptured + ". Is it correct?", confirmName);
|
181 |
-
};
|
182 |
-
}
|
183 |
-
|
184 |
-
function confirmName() {
|
185 |
-
recognition.start();
|
186 |
-
recognition.onresult = function(event) {
|
187 |
-
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
188 |
-
recognition.stop();
|
189 |
-
if (confirmation.includes("ok")) {
|
190 |
-
speak("Great! Now, tell me your email.", startListeningForEmail);
|
191 |
-
} else {
|
192 |
-
speak("Let's try again. Tell me your name.", startListeningForName);
|
193 |
-
}
|
194 |
-
};
|
195 |
-
}
|
196 |
-
|
197 |
-
// Capture email for registration
|
198 |
-
function startListeningForEmail() {
|
199 |
-
recognition.start();
|
200 |
-
recognition.onresult = function(event) {
|
201 |
-
emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
202 |
-
document.getElementById('email').value = emailCaptured;
|
203 |
-
recognition.stop();
|
204 |
-
speak("You said " + emailCaptured + ". Is it correct?", confirmEmail);
|
205 |
-
};
|
206 |
-
}
|
207 |
-
|
208 |
-
function confirmEmail() {
|
209 |
-
recognition.start();
|
210 |
-
recognition.onresult = function(event) {
|
211 |
-
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
212 |
-
recognition.stop();
|
213 |
-
if (confirmation.includes("ok")) {
|
214 |
-
speak("Great! Now, tell me your mobile number.", startListeningForMobile);
|
215 |
-
} else {
|
216 |
-
speak("Let's try again. Tell me your email.", startListeningForEmail);
|
217 |
-
}
|
218 |
-
};
|
219 |
-
}
|
220 |
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
recognition.onresult = function(event) {
|
225 |
-
mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
226 |
-
document.getElementById('mobile').value = mobileCaptured;
|
227 |
-
recognition.stop();
|
228 |
-
speak("You said " + mobileCaptured + ". Is it correct?", confirmMobile);
|
229 |
-
};
|
230 |
-
}
|
231 |
|
232 |
-
|
|
|
233 |
recognition.start();
|
234 |
recognition.onresult = function(event) {
|
235 |
-
let
|
236 |
-
|
237 |
-
if (
|
238 |
-
|
239 |
-
} else {
|
240 |
-
|
|
|
|
|
241 |
}
|
242 |
-
}
|
243 |
}
|
244 |
|
245 |
-
//
|
246 |
-
function
|
247 |
-
|
248 |
-
|
249 |
-
document.getElementById('confirmPhone').textContent = document.getElementById('mobile').value;
|
250 |
-
document.getElementById('confirmation').style.display = 'block';
|
251 |
-
setTimeout(autoSubmit, 3000);
|
252 |
-
}
|
253 |
|
254 |
-
|
255 |
-
function autoSubmit() {
|
256 |
-
var name = document.getElementById('name').value;
|
257 |
-
var email = document.getElementById('email').value;
|
258 |
-
var phone = document.getElementById('mobile').value;
|
259 |
-
fetch('/submit', {
|
260 |
method: 'POST',
|
261 |
headers: { 'Content-Type': 'application/json' },
|
262 |
-
body: JSON.stringify({
|
263 |
})
|
264 |
.then(response => response.json())
|
265 |
.then(data => {
|
266 |
if (data.success) {
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
} else {
|
272 |
-
document.getElementById('status').textContent = 'There was an error submitting your details.';
|
273 |
-
speak("There was an error submitting your details. Please try again.");
|
274 |
-
}
|
275 |
-
});
|
276 |
-
}
|
277 |
-
|
278 |
-
// Start login process
|
279 |
-
function startListeningForLoginEmail() {
|
280 |
-
recognition.start();
|
281 |
-
recognition.onresult = function(event) {
|
282 |
-
emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
283 |
-
document.getElementById('loginEmail').value = emailCaptured;
|
284 |
-
recognition.stop();
|
285 |
-
speak("You said " + emailCaptured + ". Is it correct?", confirmLoginEmail);
|
286 |
-
};
|
287 |
-
}
|
288 |
-
|
289 |
-
function confirmLoginEmail() {
|
290 |
-
recognition.start();
|
291 |
-
recognition.onresult = function(event) {
|
292 |
-
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
293 |
-
recognition.stop();
|
294 |
-
if (confirmation.includes("ok")) {
|
295 |
-
speak("Great! Now, tell me your mobile number.", startListeningForLoginMobile);
|
296 |
-
} else {
|
297 |
-
speak("Let's try again. Tell me your email.", startListeningForLoginEmail);
|
298 |
-
}
|
299 |
-
};
|
300 |
-
}
|
301 |
-
|
302 |
-
function startListeningForLoginMobile() {
|
303 |
-
recognition.start();
|
304 |
-
recognition.onresult = function(event) {
|
305 |
-
mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
306 |
-
document.getElementById('loginMobile').value = mobileCaptured;
|
307 |
-
recognition.stop();
|
308 |
-
speak("You said " + mobileCaptured + ". Is it correct?", confirmLoginMobile);
|
309 |
-
};
|
310 |
-
}
|
311 |
-
|
312 |
-
function confirmLoginMobile() {
|
313 |
-
recognition.start();
|
314 |
-
recognition.onresult = function(event) {
|
315 |
-
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
316 |
-
recognition.stop();
|
317 |
-
if (confirmation.includes("ok")) {
|
318 |
-
submitLogin();
|
319 |
} else {
|
320 |
-
|
321 |
}
|
322 |
-
};
|
323 |
-
}
|
324 |
-
|
325 |
-
// Submit login details to backend
|
326 |
-
function submitLogin() {
|
327 |
-
let email = document.getElementById('loginEmail').value;
|
328 |
-
let mobile = document.getElementById('loginMobile').value;
|
329 |
-
fetch('/submit_login', {
|
330 |
-
method: 'POST',
|
331 |
-
headers: { 'Content-Type': 'application/json' },
|
332 |
-
body: JSON.stringify({ email: email, mobile: mobile })
|
333 |
-
})
|
334 |
-
.then(response => response.json())
|
335 |
-
.then(data => {
|
336 |
-
speak("Login successful. Welcome back!");
|
337 |
-
// Redirect or perform other actions
|
338 |
})
|
339 |
.catch(error => {
|
340 |
-
|
341 |
});
|
342 |
}
|
343 |
-
|
344 |
-
window.onload = function () {
|
345 |
-
askLoginOrRegister();
|
346 |
-
};
|
347 |
</script>
|
348 |
</body>
|
349 |
</html>
|
|
|
4 |
<head>
|
5 |
<meta charset="UTF-8">
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>Login - Biryani Hub</title>
|
8 |
+
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
</head>
|
10 |
<body>
|
11 |
+
|
12 |
<div class="container">
|
13 |
+
<h2>Welcome to Biryani Hub 🍽️ 🍗</h2>
|
14 |
|
15 |
+
<!-- Voice Input Section -->
|
16 |
+
<div class="voice-section">
|
17 |
+
<label for="name">Your Name</label>
|
18 |
+
<input type="text" id="name" placeholder="Your name will appear here..." disabled>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
<label for="email">Your Email</label>
|
21 |
+
<input type="email" id="voice-email" placeholder="Your email will appear here..." disabled>
|
|
|
22 |
|
23 |
+
<label for="phone">Your Mobile Number</label>
|
24 |
+
<input type="text" id="voice-phone" placeholder="Your mobile number will appear here..." disabled>
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
<p><span class="listening">Listening 🎙️...</span></p>
|
27 |
+
<button onclick="startVoiceRecognition()">Start Voice Recognition</button>
|
|
|
28 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
+
<!-- Login Section -->
|
31 |
+
<div class="login-section">
|
32 |
+
<h2>Login to Biryani Hub</h2>
|
33 |
+
<label for="login-email">Email</label>
|
34 |
+
<input type="email" id="login-email" placeholder="Enter your email">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
+
<label for="login-phone">Phone Number</label>
|
37 |
+
<input type="text" id="login-phone" placeholder="Enter your phone number">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
<button onclick="login()">Login</button>
|
40 |
+
</div>
|
41 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
<script>
|
44 |
+
// Initialize Speech Recognition (for voice assistance)
|
45 |
+
var recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
+
// Start Voice Recognition when button is clicked
|
48 |
+
function startVoiceRecognition() {
|
49 |
recognition.start();
|
50 |
recognition.onresult = function(event) {
|
51 |
+
let transcript = event.results[0][0].transcript;
|
52 |
+
|
53 |
+
if (document.activeElement.id === "name") {
|
54 |
+
document.getElementById("name").value = transcript;
|
55 |
+
} else if (document.activeElement.id === "voice-email") {
|
56 |
+
document.getElementById("voice-email").value = transcript;
|
57 |
+
} else if (document.activeElement.id === "voice-phone") {
|
58 |
+
document.getElementById("voice-phone").value = transcript;
|
59 |
}
|
60 |
+
}
|
61 |
}
|
62 |
|
63 |
+
// Login function (manual)
|
64 |
+
function login() {
|
65 |
+
let email = document.getElementById('login-email').value;
|
66 |
+
let phone = document.getElementById('login-phone').value;
|
|
|
|
|
|
|
|
|
67 |
|
68 |
+
fetch('/login', {
|
|
|
|
|
|
|
|
|
|
|
69 |
method: 'POST',
|
70 |
headers: { 'Content-Type': 'application/json' },
|
71 |
+
body: JSON.stringify({ email: email, phone_number: phone })
|
72 |
})
|
73 |
.then(response => response.json())
|
74 |
.then(data => {
|
75 |
if (data.success) {
|
76 |
+
localStorage.setItem('userName', data.user.Name);
|
77 |
+
localStorage.setItem('userEmail', email);
|
78 |
+
localStorage.setItem('userPhone', phone);
|
79 |
+
window.location.href = "/dashboard";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
} else {
|
81 |
+
alert('Invalid credentials! Please contact admin to register in Salesforce.');
|
82 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
})
|
84 |
.catch(error => {
|
85 |
+
alert('Error logging in!');
|
86 |
});
|
87 |
}
|
|
|
|
|
|
|
|
|
88 |
</script>
|
89 |
</body>
|
90 |
</html>
|