Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +254 -43
templates/index.html
CHANGED
@@ -49,7 +49,18 @@
|
|
49 |
border-color: #ff6a00;
|
50 |
outline: none;
|
51 |
}
|
52 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
padding: 10px 20px;
|
54 |
background-color: #ff6a00;
|
55 |
color: white;
|
@@ -58,12 +69,23 @@
|
|
58 |
cursor: pointer;
|
59 |
margin-top: 10px;
|
60 |
}
|
61 |
-
.confirm-button:hover {
|
62 |
background-color: #e65e00;
|
63 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
</style>
|
65 |
</head>
|
66 |
<body>
|
|
|
67 |
<div class="container" id="welcomePage">
|
68 |
<h1>Welcome to Biriyani Hub 🍽</h1>
|
69 |
<h2 class="info" id="infoMessage">Welcome! Are you a new customer or an existing one?</h2>
|
@@ -74,86 +96,275 @@
|
|
74 |
<div class="container" id="registrationForm" style="display: none;">
|
75 |
<h2>Register</h2>
|
76 |
<label for="name">Your Name</label>
|
77 |
-
<input type="text" id="name" placeholder="Listening for name..."
|
78 |
|
79 |
<label for="email">Your Email</label>
|
80 |
-
<input type="text" id="email" placeholder="Listening for email..."
|
81 |
|
82 |
<label for="mobile">Your Mobile Number</label>
|
83 |
-
<input type="text" id="mobile" placeholder="Listening for mobile number..."
|
84 |
-
|
85 |
-
<label for="password">Your Password</label>
|
86 |
-
<input type="password" id="password" placeholder="Enter your password" required>
|
87 |
|
88 |
<p class="status" id="registrationStatus">Listening... 🗣</p>
|
89 |
-
<button class="confirm-button" onclick="submitRegistration()">Register</button>
|
90 |
</div>
|
91 |
|
92 |
<!-- Login Form -->
|
93 |
<div class="container" id="loginForm" style="display: none;">
|
94 |
<h2>Login</h2>
|
95 |
<label for="loginEmail">Your Email</label>
|
96 |
-
<input type="text" id="loginEmail" placeholder="Listening for email..."
|
97 |
|
98 |
<label for="loginMobile">Your Mobile Number</label>
|
99 |
-
<input type="text" id="loginMobile" placeholder="Listening for mobile number..."
|
100 |
-
|
101 |
-
<label for="loginPassword">Your Password</label>
|
102 |
-
<input type="password" id="loginPassword" placeholder="Enter your password" required>
|
103 |
|
104 |
<p class="status" id="loginStatus">Listening... 🗣</p>
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
</div>
|
107 |
|
108 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
function submitRegistration() {
|
110 |
const name = document.getElementById('name').value;
|
111 |
const email = document.getElementById('email').value;
|
112 |
const phone = document.getElementById('mobile').value;
|
113 |
-
|
114 |
-
|
115 |
-
fetch('/register', {
|
116 |
method: 'POST',
|
117 |
headers: { 'Content-Type': 'application/json' },
|
118 |
-
body: JSON.stringify({ name, email, phone
|
119 |
})
|
120 |
.then(response => response.json())
|
121 |
.then(data => {
|
122 |
if (data.success) {
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
} else {
|
126 |
-
|
|
|
127 |
}
|
128 |
})
|
129 |
.catch(error => {
|
130 |
-
|
|
|
131 |
});
|
132 |
}
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
|
|
|
|
|
|
149 |
} else {
|
150 |
-
|
151 |
}
|
152 |
-
}
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
});
|
156 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
</script>
|
158 |
</body>
|
159 |
</html>
|
|
|
49 |
border-color: #ff6a00;
|
50 |
outline: none;
|
51 |
}
|
52 |
+
.info {
|
53 |
+
font-size: 16px;
|
54 |
+
color: #ff6a00;
|
55 |
+
font-weight: bold;
|
56 |
+
margin-top: 10px;
|
57 |
+
}
|
58 |
+
.status {
|
59 |
+
font-size: 14px;
|
60 |
+
color: gray;
|
61 |
+
margin-top: 10px;
|
62 |
+
}
|
63 |
+
.confirm-button, .switch-button {
|
64 |
padding: 10px 20px;
|
65 |
background-color: #ff6a00;
|
66 |
color: white;
|
|
|
69 |
cursor: pointer;
|
70 |
margin-top: 10px;
|
71 |
}
|
72 |
+
.confirm-button:hover, .switch-button:hover {
|
73 |
background-color: #e65e00;
|
74 |
}
|
75 |
+
.confirm-details {
|
76 |
+
margin-top: 20px;
|
77 |
+
font-size: 18px;
|
78 |
+
font-weight: bold;
|
79 |
+
color: #333;
|
80 |
+
}
|
81 |
+
.details {
|
82 |
+
font-size: 16px;
|
83 |
+
margin: 5px 0;
|
84 |
+
}
|
85 |
</style>
|
86 |
</head>
|
87 |
<body>
|
88 |
+
<!-- Welcome Page -->
|
89 |
<div class="container" id="welcomePage">
|
90 |
<h1>Welcome to Biriyani Hub 🍽</h1>
|
91 |
<h2 class="info" id="infoMessage">Welcome! Are you a new customer or an existing one?</h2>
|
|
|
96 |
<div class="container" id="registrationForm" style="display: none;">
|
97 |
<h2>Register</h2>
|
98 |
<label for="name">Your Name</label>
|
99 |
+
<input type="text" id="name" placeholder="Listening for name..." readonly>
|
100 |
|
101 |
<label for="email">Your Email</label>
|
102 |
+
<input type="text" id="email" placeholder="Listening for email..." readonly>
|
103 |
|
104 |
<label for="mobile">Your Mobile Number</label>
|
105 |
+
<input type="text" id="mobile" placeholder="Listening for mobile number..." readonly>
|
|
|
|
|
|
|
106 |
|
107 |
<p class="status" id="registrationStatus">Listening... 🗣</p>
|
|
|
108 |
</div>
|
109 |
|
110 |
<!-- Login Form -->
|
111 |
<div class="container" id="loginForm" style="display: none;">
|
112 |
<h2>Login</h2>
|
113 |
<label for="loginEmail">Your Email</label>
|
114 |
+
<input type="text" id="loginEmail" placeholder="Listening for email..." readonly>
|
115 |
|
116 |
<label for="loginMobile">Your Mobile Number</label>
|
117 |
+
<input type="text" id="loginMobile" placeholder="Listening for mobile number..." readonly>
|
|
|
|
|
|
|
118 |
|
119 |
<p class="status" id="loginStatus">Listening... 🗣</p>
|
120 |
+
</div>
|
121 |
+
|
122 |
+
<!-- Confirmation Page -->
|
123 |
+
<div class="container" id="confirmationPage" style="display: none;">
|
124 |
+
<h2>Confirm Your Details</h2>
|
125 |
+
<div class="confirm-details">
|
126 |
+
<p class="details"><strong>Name:</strong> <span id="confirmName"></span></p>
|
127 |
+
<p class="details"><strong>Email:</strong> <span id="confirmEmail"></span></p>
|
128 |
+
<p class="details"><strong>Phone:</strong> <span id="confirmPhone"></span></p>
|
129 |
+
</div>
|
130 |
+
</div>
|
131 |
+
|
132 |
+
<div id="statusMessage" style="display: none;">
|
133 |
+
<h2 id="statusText"></h2>
|
134 |
</div>
|
135 |
|
136 |
<script>
|
137 |
+
let recognition;
|
138 |
+
if ('webkitSpeechRecognition' in window) {
|
139 |
+
recognition = new webkitSpeechRecognition();
|
140 |
+
recognition.continuous = false;
|
141 |
+
recognition.interimResults = false;
|
142 |
+
recognition.lang = 'en-US';
|
143 |
+
} else {
|
144 |
+
alert("Speech Recognition API is not supported in this browser.");
|
145 |
+
}
|
146 |
+
function speak(text, callback) {
|
147 |
+
const speech = new SpeechSynthesisUtterance(text);
|
148 |
+
speech.onend = callback;
|
149 |
+
window.speechSynthesis.speak(speech);
|
150 |
+
}
|
151 |
+
function askLoginOrRegister() {
|
152 |
+
speak("Are you a new customer or an existing customer? Say 'new' to register or 'existing' to login.", function () {
|
153 |
+
recognition.start();
|
154 |
+
recognition.onresult = function (event) {
|
155 |
+
let response = event.results[0][0].transcript.trim().toLowerCase();
|
156 |
+
recognition.stop();
|
157 |
+
if (response.includes("new")) {
|
158 |
+
showRegistrationForm();
|
159 |
+
captureName();
|
160 |
+
} else if (response.includes("existing")) {
|
161 |
+
showLoginForm();
|
162 |
+
captureLoginDetails();
|
163 |
+
} else {
|
164 |
+
speak("I didn't understand. Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
|
165 |
+
}
|
166 |
+
};
|
167 |
+
});
|
168 |
+
}
|
169 |
+
function showRegistrationForm() {
|
170 |
+
document.getElementById('welcomePage').style.display = 'none';
|
171 |
+
document.getElementById('registrationForm').style.display = 'block';
|
172 |
+
document.getElementById('loginForm').style.display = 'none';
|
173 |
+
document.getElementById('confirmationPage').style.display = 'none';
|
174 |
+
document.getElementById('statusMessage').style.display = 'none';
|
175 |
+
}
|
176 |
+
function showLoginForm() {
|
177 |
+
document.getElementById('welcomePage').style.display = 'none';
|
178 |
+
document.getElementById('registrationForm').style.display = 'none';
|
179 |
+
document.getElementById('loginForm').style.display = 'block';
|
180 |
+
document.getElementById('confirmationPage').style.display = 'none';
|
181 |
+
document.getElementById('statusMessage').style.display = 'none';
|
182 |
+
}
|
183 |
+
function captureName() {
|
184 |
+
speak("Please say your name.", function () {
|
185 |
+
recognition.start();
|
186 |
+
recognition.onresult = function (event) {
|
187 |
+
let nameCaptured = event.results[0][0].transcript.trim();
|
188 |
+
document.getElementById('name').value = nameCaptured;
|
189 |
+
recognition.stop();
|
190 |
+
speak("You said " + nameCaptured + ". Is it correct?", function () {
|
191 |
+
confirmName(nameCaptured);
|
192 |
+
});
|
193 |
+
};
|
194 |
+
});
|
195 |
+
}
|
196 |
+
function confirmName(nameCaptured) {
|
197 |
+
recognition.start();
|
198 |
+
recognition.onresult = function (event) {
|
199 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
200 |
+
recognition.stop();
|
201 |
+
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
202 |
+
captureEmail();
|
203 |
+
} else {
|
204 |
+
captureName();
|
205 |
+
}
|
206 |
+
};
|
207 |
+
}
|
208 |
+
function captureEmail() {
|
209 |
+
speak("Now, say your email.", function () {
|
210 |
+
recognition.start();
|
211 |
+
recognition.onresult = function (event) {
|
212 |
+
let emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
213 |
+
document.getElementById('email').value = emailCaptured;
|
214 |
+
recognition.stop();
|
215 |
+
speak("You said " + emailCaptured + ". Is it correct?", function () {
|
216 |
+
confirmEmail(emailCaptured);
|
217 |
+
});
|
218 |
+
};
|
219 |
+
});
|
220 |
+
}
|
221 |
+
function confirmEmail(emailCaptured) {
|
222 |
+
recognition.start();
|
223 |
+
recognition.onresult = function (event) {
|
224 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
225 |
+
recognition.stop();
|
226 |
+
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
227 |
+
captureMobile();
|
228 |
+
} else {
|
229 |
+
captureEmail();
|
230 |
+
}
|
231 |
+
};
|
232 |
+
}
|
233 |
+
function captureMobile() {
|
234 |
+
speak("Now, say your mobile number.", function () {
|
235 |
+
recognition.start();
|
236 |
+
recognition.onresult = function (event) {
|
237 |
+
let mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
238 |
+
document.getElementById('mobile').value = mobileCaptured;
|
239 |
+
recognition.stop();
|
240 |
+
speak("You said " + mobileCaptured + ". Is it correct?", function () {
|
241 |
+
confirmMobile(mobileCaptured);
|
242 |
+
});
|
243 |
+
};
|
244 |
+
});
|
245 |
+
}
|
246 |
+
function confirmMobile(mobileCaptured) {
|
247 |
+
recognition.start();
|
248 |
+
recognition.onresult = function (event) {
|
249 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
250 |
+
recognition.stop();
|
251 |
+
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
252 |
+
// Show confirmation page with details
|
253 |
+
showConfirmationPage();
|
254 |
+
} else {
|
255 |
+
captureMobile();
|
256 |
+
}
|
257 |
+
};
|
258 |
+
}
|
259 |
+
function showConfirmationPage() {
|
260 |
+
const name = document.getElementById('name').value;
|
261 |
+
const email = document.getElementById('email').value;
|
262 |
+
const phone = document.getElementById('mobile').value;
|
263 |
+
document.getElementById('confirmName').textContent = name;
|
264 |
+
document.getElementById('confirmEmail').textContent = email;
|
265 |
+
document.getElementById('confirmPhone').textContent = phone;
|
266 |
+
// Automatically submit the details after a delay
|
267 |
+
setTimeout(submitRegistration, 6000); // 6 seconds delay
|
268 |
+
}
|
269 |
function submitRegistration() {
|
270 |
const name = document.getElementById('name').value;
|
271 |
const email = document.getElementById('email').value;
|
272 |
const phone = document.getElementById('mobile').value;
|
273 |
+
// Simulate submission to Salesforce
|
274 |
+
fetch('/submit', {
|
|
|
275 |
method: 'POST',
|
276 |
headers: { 'Content-Type': 'application/json' },
|
277 |
+
body: JSON.stringify({ name, email, phone })
|
278 |
})
|
279 |
.then(response => response.json())
|
280 |
.then(data => {
|
281 |
if (data.success) {
|
282 |
+
document.getElementById('statusText').textContent = `Thank you for registering, ${name}!`;
|
283 |
+
document.getElementById('statusMessage').style.display = 'block';
|
284 |
+
// Show 'Submitted Successfully' after 6 seconds, then refresh the page after 5 seconds
|
285 |
+
setTimeout(() => {
|
286 |
+
document.getElementById('statusText').textContent = 'Submitted Successfully!';
|
287 |
+
setTimeout(() => {
|
288 |
+
window.location.reload(); // Refresh after 5 seconds
|
289 |
+
}, 5000);
|
290 |
+
}, 6000);
|
291 |
} else {
|
292 |
+
document.getElementById('statusText').textContent = 'There was an error submitting your details. Please try again.';
|
293 |
+
document.getElementById('statusMessage').style.display = 'block';
|
294 |
}
|
295 |
})
|
296 |
.catch(error => {
|
297 |
+
document.getElementById('statusText').textContent = 'An error occurred. Please try again.';
|
298 |
+
document.getElementById('statusMessage').style.display = 'block';
|
299 |
});
|
300 |
}
|
301 |
+
function captureLoginDetails() {
|
302 |
+
speak("Please say your email for login.", function () {
|
303 |
+
recognition.start();
|
304 |
+
recognition.onresult = function (event) {
|
305 |
+
let emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
306 |
+
document.getElementById('loginEmail').value = emailCaptured;
|
307 |
+
recognition.stop();
|
308 |
+
speak("You said " + emailCaptured + ". Is it correct?", function () {
|
309 |
+
confirmLoginEmail(emailCaptured);
|
310 |
+
});
|
311 |
+
};
|
312 |
+
});
|
313 |
+
}
|
314 |
+
function confirmLoginEmail(emailCaptured) {
|
315 |
+
recognition.start();
|
316 |
+
recognition.onresult = function (event) {
|
317 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
318 |
+
recognition.stop();
|
319 |
+
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
320 |
+
captureLoginMobile();
|
321 |
} else {
|
322 |
+
captureLoginDetails();
|
323 |
}
|
324 |
+
};
|
325 |
+
}
|
326 |
+
function captureLoginMobile() {
|
327 |
+
speak("Now, say your mobile number.", function () {
|
328 |
+
recognition.start();
|
329 |
+
recognition.onresult = function (event) {
|
330 |
+
let mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
331 |
+
document.getElementById('loginMobile').value = mobileCaptured;
|
332 |
+
recognition.stop();
|
333 |
+
speak("You said " + mobileCaptured + ". Is it correct?", function () {
|
334 |
+
confirmLoginMobile(mobileCaptured);
|
335 |
+
});
|
336 |
+
};
|
337 |
});
|
338 |
}
|
339 |
+
function confirmLoginMobile(mobileCaptured) {
|
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("yes") || confirmation.includes("ok")) {
|
345 |
+
submitLogin();
|
346 |
+
} else {
|
347 |
+
captureLoginMobile();
|
348 |
+
}
|
349 |
+
};
|
350 |
+
}
|
351 |
+
function submitLogin() {
|
352 |
+
const loginEmail = document.getElementById('loginEmail').value;
|
353 |
+
const loginMobile = document.getElementById('loginMobile').value;
|
354 |
+
// Simulate login check
|
355 |
+
if (loginEmail && loginMobile) {
|
356 |
+
document.getElementById('statusText').textContent = 'Login successful! Redirecting...';
|
357 |
+
document.getElementById('statusMessage').style.display = 'block';
|
358 |
+
setTimeout(() => {
|
359 |
+
window.location.href = '/dashboard'; // Redirect to dashboard
|
360 |
+
}, 3000);
|
361 |
+
} else {
|
362 |
+
speak("Please enter valid login details.");
|
363 |
+
}
|
364 |
+
}
|
365 |
+
window.onload = function () {
|
366 |
+
askLoginOrRegister();
|
367 |
+
};
|
368 |
</script>
|
369 |
</body>
|
370 |
</html>
|