Update templates/index.html
Browse files- templates/index.html +4 -110
templates/index.html
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
<!DOCTYPE html>
|
| 3 |
<html lang="en">
|
| 4 |
<head>
|
|
@@ -72,16 +71,6 @@
|
|
| 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>
|
|
@@ -119,20 +108,6 @@
|
|
| 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) {
|
|
@@ -173,16 +148,12 @@
|
|
| 173 |
document.getElementById('welcomePage').style.display = 'none';
|
| 174 |
document.getElementById('registrationForm').style.display = 'block';
|
| 175 |
document.getElementById('loginForm').style.display = 'none';
|
| 176 |
-
document.getElementById('confirmationPage').style.display = 'none';
|
| 177 |
-
document.getElementById('statusMessage').style.display = 'none';
|
| 178 |
}
|
| 179 |
|
| 180 |
function showLoginForm() {
|
| 181 |
document.getElementById('welcomePage').style.display = 'none';
|
| 182 |
document.getElementById('registrationForm').style.display = 'none';
|
| 183 |
document.getElementById('loginForm').style.display = 'block';
|
| 184 |
-
document.getElementById('confirmationPage').style.display = 'none';
|
| 185 |
-
document.getElementById('statusMessage').style.display = 'none';
|
| 186 |
}
|
| 187 |
|
| 188 |
function captureName() {
|
|
@@ -259,33 +230,18 @@
|
|
| 259 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
| 260 |
recognition.stop();
|
| 261 |
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
| 262 |
-
|
| 263 |
-
showConfirmationPage();
|
| 264 |
} else {
|
| 265 |
captureMobile();
|
| 266 |
}
|
| 267 |
};
|
| 268 |
}
|
| 269 |
|
| 270 |
-
function showConfirmationPage() {
|
| 271 |
-
const name = document.getElementById('name').value;
|
| 272 |
-
const email = document.getElementById('email').value;
|
| 273 |
-
const phone = document.getElementById('mobile').value;
|
| 274 |
-
|
| 275 |
-
document.getElementById('confirmName').textContent = name;
|
| 276 |
-
document.getElementById('confirmEmail').textContent = email;
|
| 277 |
-
document.getElementById('confirmPhone').textContent = phone;
|
| 278 |
-
|
| 279 |
-
// Automatically submit the details after a delay
|
| 280 |
-
setTimeout(submitRegistration, 6000); // 6 seconds delay
|
| 281 |
-
}
|
| 282 |
-
|
| 283 |
function submitRegistration() {
|
| 284 |
const name = document.getElementById('name').value;
|
| 285 |
const email = document.getElementById('email').value;
|
| 286 |
const phone = document.getElementById('mobile').value;
|
| 287 |
|
| 288 |
-
// Simulate submission to Salesforce
|
| 289 |
fetch('/submit', {
|
| 290 |
method: 'POST',
|
| 291 |
headers: { 'Content-Type': 'application/json' },
|
|
@@ -294,24 +250,10 @@
|
|
| 294 |
.then(response => response.json())
|
| 295 |
.then(data => {
|
| 296 |
if (data.success) {
|
| 297 |
-
|
| 298 |
-
document.getElementById('statusMessage').style.display = 'block';
|
| 299 |
-
|
| 300 |
-
// Show 'Submitted Successfully' after 6 seconds, then refresh the page after 5 seconds
|
| 301 |
-
setTimeout(() => {
|
| 302 |
-
document.getElementById('statusText').textContent = 'Submitted Successfully!';
|
| 303 |
-
setTimeout(() => {
|
| 304 |
-
window.location.reload(); // Refresh after 5 seconds
|
| 305 |
-
}, 5000);
|
| 306 |
-
}, 6000);
|
| 307 |
} else {
|
| 308 |
-
|
| 309 |
-
document.getElementById('statusMessage').style.display = 'block';
|
| 310 |
}
|
| 311 |
-
})
|
| 312 |
-
.catch(error => {
|
| 313 |
-
document.getElementById('statusText').textContent = 'An error occurred. Please try again.';
|
| 314 |
-
document.getElementById('statusMessage').style.display = 'block';
|
| 315 |
});
|
| 316 |
}
|
| 317 |
|
|
@@ -342,52 +284,4 @@
|
|
| 342 |
};
|
| 343 |
}
|
| 344 |
|
| 345 |
-
function
|
| 346 |
-
speak("Now, say your mobile number.", function () {
|
| 347 |
-
recognition.start();
|
| 348 |
-
recognition.onresult = function (event) {
|
| 349 |
-
let mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
| 350 |
-
document.getElementById('loginMobile').value = mobileCaptured;
|
| 351 |
-
recognition.stop();
|
| 352 |
-
speak("You said " + mobileCaptured + ". Is it correct?", function () {
|
| 353 |
-
confirmLoginMobile(mobileCaptured);
|
| 354 |
-
});
|
| 355 |
-
};
|
| 356 |
-
});
|
| 357 |
-
}
|
| 358 |
-
|
| 359 |
-
function confirmLoginMobile(mobileCaptured) {
|
| 360 |
-
recognition.start();
|
| 361 |
-
recognition.onresult = function (event) {
|
| 362 |
-
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
| 363 |
-
recognition.stop();
|
| 364 |
-
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
| 365 |
-
submitLogin();
|
| 366 |
-
} else {
|
| 367 |
-
captureLoginMobile();
|
| 368 |
-
}
|
| 369 |
-
};
|
| 370 |
-
}
|
| 371 |
-
|
| 372 |
-
function submitLogin() {
|
| 373 |
-
const loginEmail = document.getElementById('loginEmail').value;
|
| 374 |
-
const loginMobile = document.getElementById('loginMobile').value;
|
| 375 |
-
|
| 376 |
-
// Simulate login check
|
| 377 |
-
if (loginEmail && loginMobile) {
|
| 378 |
-
document.getElementById('statusText').textContent = 'Login successful! Redirecting...';
|
| 379 |
-
document.getElementById('statusMessage').style.display = 'block';
|
| 380 |
-
setTimeout(() => {
|
| 381 |
-
window.location.href = '/dashboard'; // Redirect to dashboard
|
| 382 |
-
}, 3000);
|
| 383 |
-
} else {
|
| 384 |
-
speak("Please enter valid login details.");
|
| 385 |
-
}
|
| 386 |
-
}
|
| 387 |
-
|
| 388 |
-
window.onload = function () {
|
| 389 |
-
askLoginOrRegister();
|
| 390 |
-
};
|
| 391 |
-
</script>
|
| 392 |
-
</body>
|
| 393 |
-
</html>
|
|
|
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
|
|
|
| 71 |
.confirm-button:hover, .switch-button:hover {
|
| 72 |
background-color: #e65e00;
|
| 73 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
</style>
|
| 75 |
</head>
|
| 76 |
<body>
|
|
|
|
| 108 |
<p class="status" id="loginStatus">Listening... 🗣</p>
|
| 109 |
</div>
|
| 110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
<script>
|
| 112 |
let recognition;
|
| 113 |
if ('webkitSpeechRecognition' in window) {
|
|
|
|
| 148 |
document.getElementById('welcomePage').style.display = 'none';
|
| 149 |
document.getElementById('registrationForm').style.display = 'block';
|
| 150 |
document.getElementById('loginForm').style.display = 'none';
|
|
|
|
|
|
|
| 151 |
}
|
| 152 |
|
| 153 |
function showLoginForm() {
|
| 154 |
document.getElementById('welcomePage').style.display = 'none';
|
| 155 |
document.getElementById('registrationForm').style.display = 'none';
|
| 156 |
document.getElementById('loginForm').style.display = 'block';
|
|
|
|
|
|
|
| 157 |
}
|
| 158 |
|
| 159 |
function captureName() {
|
|
|
|
| 230 |
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
| 231 |
recognition.stop();
|
| 232 |
if (confirmation.includes("yes") || confirmation.includes("ok")) {
|
| 233 |
+
submitRegistration();
|
|
|
|
| 234 |
} else {
|
| 235 |
captureMobile();
|
| 236 |
}
|
| 237 |
};
|
| 238 |
}
|
| 239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
function submitRegistration() {
|
| 241 |
const name = document.getElementById('name').value;
|
| 242 |
const email = document.getElementById('email').value;
|
| 243 |
const phone = document.getElementById('mobile').value;
|
| 244 |
|
|
|
|
| 245 |
fetch('/submit', {
|
| 246 |
method: 'POST',
|
| 247 |
headers: { 'Content-Type': 'application/json' },
|
|
|
|
| 250 |
.then(response => response.json())
|
| 251 |
.then(data => {
|
| 252 |
if (data.success) {
|
| 253 |
+
window.location.href = '/menu'; // Redirect to menu after successful registration
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
} else {
|
| 255 |
+
alert('There was an error. Please try again.');
|
|
|
|
| 256 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
});
|
| 258 |
}
|
| 259 |
|
|
|
|
| 284 |
};
|
| 285 |
}
|
| 286 |
|
| 287 |
+
function capture
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|