Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +211 -209
templates/index.html
CHANGED
@@ -1,210 +1,212 @@
|
|
1 |
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
|
|
|
|
|
1 |
|
2 |
+
<!DOCTYPE html>
|
3 |
+
<html lang="en">
|
4 |
+
<head>
|
5 |
+
<meta charset="UTF-8">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>Biryani Hub Login & Registration</title>
|
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 |
+
/* Styling remains unchanged */
|
12 |
+
</style>
|
13 |
+
</head>
|
14 |
+
<body>
|
15 |
+
<div class="container">
|
16 |
+
<h1>Welcome to Biryani Hub 🍽 🍗</h1>
|
17 |
+
|
18 |
+
<!-- Form Section -->
|
19 |
+
<div class="form-container">
|
20 |
+
<!-- Registration Form -->
|
21 |
+
<div class="form-section" id="registrationForm" style="display: block;">
|
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>
|
25 |
+
|
26 |
+
<label for="email">Your Email</label>
|
27 |
+
<input type="text" id="email" placeholder="Your email will appear here..." readonly>
|
28 |
+
|
29 |
+
<label for="mobile">Your Mobile Number</label>
|
30 |
+
<input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
|
31 |
+
|
32 |
+
<p class="info" id="infoMessage">Listening 🗣🎙️...</p>
|
33 |
+
<p class="status" id="status">🔊...</p>
|
34 |
+
</div>
|
35 |
+
|
36 |
+
<!-- Login Form -->
|
37 |
+
<div class="form-section" id="loginForm" style="display: none;">
|
38 |
+
<h2 class="header">Login</h2>
|
39 |
+
<label for="loginEmail">Your Email</label>
|
40 |
+
<input type="text" id="loginEmail" placeholder="Your email will appear here..." readonly>
|
41 |
+
|
42 |
+
<label for="loginMobile">Your Mobile Number</label>
|
43 |
+
<input type="text" id="loginMobile" placeholder="Your mobile number will appear here..." readonly>
|
44 |
+
|
45 |
+
<p class="info" id="infoMessageLogin">Listening 🗣🎙️...</p>
|
46 |
+
<p class="status" id="statusLogin">🔊...</p>
|
47 |
+
</div>
|
48 |
+
</div>
|
49 |
+
</div>
|
50 |
+
|
51 |
+
<script>
|
52 |
+
let recognition;
|
53 |
+
let nameCaptured = "";
|
54 |
+
let emailCaptured = "";
|
55 |
+
let mobileCaptured = "";
|
56 |
+
|
57 |
+
if ('webkitSpeechRecognition' in window) {
|
58 |
+
recognition = new webkitSpeechRecognition();
|
59 |
+
recognition.continuous = false;
|
60 |
+
recognition.interimResults = false;
|
61 |
+
recognition.lang = 'en-US';
|
62 |
+
} else {
|
63 |
+
alert("Speech Recognition API is not supported in this browser.");
|
64 |
+
}
|
65 |
+
|
66 |
+
function speak(text, callback) {
|
67 |
+
const speech = new SpeechSynthesisUtterance(text);
|
68 |
+
speech.onend = callback;
|
69 |
+
window.speechSynthesis.speak(speech);
|
70 |
+
}
|
71 |
+
|
72 |
+
// Start by asking if the user is a new or existing customer
|
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();
|
76 |
+
recognition.onresult = function(event) {
|
77 |
+
let response = event.results[0][0].transcript.trim().toLowerCase();
|
78 |
+
recognition.stop();
|
79 |
+
if (response.includes("new")) {
|
80 |
+
showRegistrationForm();
|
81 |
+
} else if (response.includes("existing")) {
|
82 |
+
showLoginForm();
|
83 |
+
} else {
|
84 |
+
speak("Sorry, I didn't understand. Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
|
85 |
+
}
|
86 |
+
};
|
87 |
+
});
|
88 |
+
}
|
89 |
+
|
90 |
+
function showRegistrationForm() {
|
91 |
+
document.getElementById('registrationForm').style.display = 'block';
|
92 |
+
document.getElementById('loginForm').style.display = 'none';
|
93 |
+
speak("Please tell me your name to begin the registration.", startListeningForName);
|
94 |
+
}
|
95 |
+
|
96 |
+
function showLoginForm() {
|
97 |
+
document.getElementById('loginForm').style.display = 'block';
|
98 |
+
document.getElementById('registrationForm').style.display = 'none';
|
99 |
+
speak("Please tell me your email to begin the login process.", startListeningForLoginEmail);
|
100 |
+
}
|
101 |
+
|
102 |
+
// Capture the name for registration
|
103 |
+
function startListeningForName() {
|
104 |
+
recognition.start();
|
105 |
+
recognition.onresult = function(event) {
|
106 |
+
nameCaptured = event.results[0][0].transcript.trim();
|
107 |
+
document.getElementById('name').value = nameCaptured;
|
108 |
+
recognition.stop();
|
109 |
+
speak("You said " + nameCaptured + ". Is it correct?", confirmName);
|
110 |
+
};
|
111 |
+
}
|
112 |
+
|
113 |
+
function confirmName() {
|
114 |
+
recognition.start();
|
115 |
+
recognition.onresult = function(event) {
|
116 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
117 |
+
recognition.stop();
|
118 |
+
if (confirmation.includes("ok")) {
|
119 |
+
speak("Great! Now, tell me your email.", startListeningForEmail);
|
120 |
+
} else {
|
121 |
+
speak("Let's try again. Tell me your name.", startListeningForName);
|
122 |
+
}
|
123 |
+
};
|
124 |
+
}
|
125 |
+
|
126 |
+
// Capture email for registration
|
127 |
+
function startListeningForEmail() {
|
128 |
+
recognition.start();
|
129 |
+
recognition.onresult = function(event) {
|
130 |
+
emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
131 |
+
document.getElementById('email').value = emailCaptured;
|
132 |
+
recognition.stop();
|
133 |
+
speak("You said " + emailCaptured + ". Is it correct?", confirmEmail);
|
134 |
+
};
|
135 |
+
}
|
136 |
+
|
137 |
+
function confirmEmail() {
|
138 |
+
recognition.start();
|
139 |
+
recognition.onresult = function(event) {
|
140 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
141 |
+
recognition.stop();
|
142 |
+
if (confirmation.includes("ok")) {
|
143 |
+
speak("Great! Now, tell me your mobile number.", startListeningForMobile);
|
144 |
+
} else {
|
145 |
+
speak("Let's try again. Tell me your email.", startListeningForEmail);
|
146 |
+
}
|
147 |
+
};
|
148 |
+
}
|
149 |
+
|
150 |
+
// Capture mobile number for registration
|
151 |
+
function startListeningForMobile() {
|
152 |
+
recognition.start();
|
153 |
+
recognition.onresult = function(event) {
|
154 |
+
mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
155 |
+
document.getElementById('mobile').value = mobileCaptured;
|
156 |
+
recognition.stop();
|
157 |
+
speak("You said " + mobileCaptured + ". Is it correct?", confirmMobile);
|
158 |
+
};
|
159 |
+
}
|
160 |
+
|
161 |
+
function confirmMobile() {
|
162 |
+
recognition.start();
|
163 |
+
recognition.onresult = function(event) {
|
164 |
+
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
165 |
+
recognition.stop();
|
166 |
+
if (confirmation.includes("ok")) {
|
167 |
+
autoConfirm();
|
168 |
+
} else {
|
169 |
+
speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
|
170 |
+
}
|
171 |
+
};
|
172 |
+
}
|
173 |
+
|
174 |
+
// Confirm details and submit automatically
|
175 |
+
function autoConfirm() {
|
176 |
+
document.getElementById('confirmName').textContent = document.getElementById('name').value;
|
177 |
+
document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
|
178 |
+
document.getElementById('confirmPhone').textContent = document.getElementById('mobile').value;
|
179 |
+
document.getElementById('confirmation').style.display = 'block';
|
180 |
+
setTimeout(autoSubmit, 3000);
|
181 |
+
}
|
182 |
+
|
183 |
+
// Submit details to Salesforce
|
184 |
+
function autoSubmit() {
|
185 |
+
var name = document.getElementById('name').value;
|
186 |
+
var email = document.getElementById('email').value;
|
187 |
+
var phone = document.getElementById('mobile').value;
|
188 |
+
fetch('/submit', {
|
189 |
+
method: 'POST',
|
190 |
+
headers: { 'Content-Type': 'application/json' },
|
191 |
+
body: JSON.stringify({ name: name, email: email, phone: phone })
|
192 |
+
})
|
193 |
+
.then(response => response.json())
|
194 |
+
.then(data => {
|
195 |
+
if (data.success) {
|
196 |
+
document.getElementById('status').textContent = 'Your details were submitted successfully!';
|
197 |
+
document.getElementById('confirmation').style.display = 'none';
|
198 |
+
speak("Your registration is complete. Thank you for registering.");
|
199 |
+
setTimeout(() => location.reload(), 5000);
|
200 |
+
} else {
|
201 |
+
document.getElementById('status').textContent = 'There was an error submitting your details.';
|
202 |
+
speak("There was an error submitting your details. Please try again.");
|
203 |
+
}
|
204 |
+
});
|
205 |
+
}
|
206 |
+
|
207 |
+
window.onload = function () {
|
208 |
+
askLoginOrRegister();
|
209 |
+
};
|
210 |
+
</script>
|
211 |
+
</body>
|
212 |
+
</html>
|