Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +56 -185
templates/index.html
CHANGED
@@ -23,11 +23,6 @@
|
|
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;
|
@@ -36,25 +31,19 @@
|
|
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
|
46 |
width: 100%;
|
47 |
-
padding:
|
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;
|
@@ -67,31 +56,6 @@
|
|
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;
|
@@ -107,49 +71,20 @@
|
|
107 |
</head>
|
108 |
<body>
|
109 |
<div class="container">
|
110 |
-
|
111 |
-
<
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
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>
|
@@ -158,6 +93,7 @@
|
|
158 |
let emailCaptured = "";
|
159 |
let mobileCaptured = "";
|
160 |
|
|
|
161 |
if ('webkitSpeechRecognition' in window) {
|
162 |
recognition = new webkitSpeechRecognition();
|
163 |
recognition.continuous = false;
|
@@ -173,143 +109,78 @@
|
|
173 |
window.speechSynthesis.speak(speech);
|
174 |
}
|
175 |
|
176 |
-
|
177 |
-
function askLoginOrRegister() {
|
178 |
-
speak("Are you a new customer or an existing customer? Say 'new' for registration or 'existing' for login.", function() {
|
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 |
-
showRegistrationForm();
|
185 |
-
} else if (response.includes("existing")) {
|
186 |
-
showLoginForm();
|
187 |
-
} else {
|
188 |
-
speak("Sorry, I didn't understand. Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
|
189 |
-
}
|
190 |
-
};
|
191 |
-
});
|
192 |
-
}
|
193 |
-
|
194 |
-
function showRegistrationForm() {
|
195 |
-
document.getElementById('registrationForm').style.display = 'block';
|
196 |
-
document.getElementById('loginForm').style.display = 'none';
|
197 |
-
speak("Please tell me your name to begin the registration.", startListeningForName);
|
198 |
-
}
|
199 |
-
|
200 |
-
function showLoginForm() {
|
201 |
-
document.getElementById('loginForm').style.display = 'block';
|
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) {
|
210 |
-
|
211 |
-
document.getElementById('name').value = nameCaptured;
|
212 |
recognition.stop();
|
213 |
-
|
214 |
};
|
215 |
}
|
216 |
|
217 |
-
function
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
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) {
|
234 |
-
emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
235 |
document.getElementById('email').value = emailCaptured;
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
}
|
240 |
-
|
241 |
-
function confirmEmail() {
|
242 |
-
recognition.start();
|
243 |
-
recognition.onresult = function(event) {
|
244 |
-
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
|
245 |
-
recognition.stop();
|
246 |
-
if (confirmation.includes("ok")) {
|
247 |
-
speak("Great! Now, tell me your mobile number.", startListeningForMobile);
|
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) {
|
258 |
-
mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
|
259 |
document.getElementById('mobile').value = mobileCaptured;
|
260 |
-
|
261 |
-
|
262 |
-
};
|
263 |
}
|
264 |
|
265 |
-
function
|
266 |
recognition.start();
|
267 |
recognition.onresult = function(event) {
|
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.
|
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 |
-
|
|
|
|
|
293 |
method: 'POST',
|
294 |
headers: { 'Content-Type': 'application/json' },
|
295 |
body: JSON.stringify({ name: name, email: email, phone: phone })
|
296 |
})
|
297 |
.then(response => response.json())
|
298 |
.then(data => {
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
speak("There was an error submitting your details. Please try again.");
|
307 |
-
}
|
308 |
});
|
309 |
}
|
310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
window.onload = function () {
|
312 |
-
|
313 |
};
|
314 |
</script>
|
315 |
</body>
|
|
|
23 |
border-radius: 10px;
|
24 |
width: 500px;
|
25 |
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
h1 {
|
28 |
font-size: 30px;
|
|
|
31 |
}
|
32 |
label {
|
33 |
font-size: 16px;
|
|
|
34 |
display: block;
|
35 |
text-align: left;
|
36 |
font-weight: bold;
|
37 |
color: #333;
|
38 |
}
|
39 |
+
input {
|
40 |
width: 100%;
|
41 |
+
padding: 10px;
|
|
|
42 |
border: 2px solid #ccc;
|
43 |
border-radius: 8px;
|
44 |
margin-top: 8px;
|
|
|
45 |
background-color: #f9f9f9;
|
46 |
+
font-size: 16px;
|
|
|
|
|
|
|
47 |
}
|
48 |
.info {
|
49 |
margin-top: 20px;
|
|
|
56 |
color: gray;
|
57 |
margin-top: 20px;
|
58 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
.confirm-button {
|
60 |
padding: 10px 20px;
|
61 |
background-color: #ff6a00;
|
|
|
71 |
</head>
|
72 |
<body>
|
73 |
<div class="container">
|
74 |
+
<h1>Welcome to Biryani Hub 🍽 🍗</h1>
|
75 |
+
<label>Your Name</label>
|
76 |
+
<input type="text" id="name" placeholder="Listening..." readonly>
|
77 |
+
|
78 |
+
<label>Your Email</label>
|
79 |
+
<input type="text" id="email" placeholder="Listening..." readonly>
|
80 |
+
|
81 |
+
<label>Your Mobile Number</label>
|
82 |
+
<input type="text" id="mobile" placeholder="Listening..." readonly>
|
83 |
+
|
84 |
+
<p class="info" id="infoMessage">Listening 🗣🎙️...</p>
|
85 |
+
<p class="status" id="status">🔊...</p>
|
86 |
+
|
87 |
+
<button class="confirm-button" onclick="autoSubmit()">Submit</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
</div>
|
89 |
|
90 |
<script>
|
|
|
93 |
let emailCaptured = "";
|
94 |
let mobileCaptured = "";
|
95 |
|
96 |
+
// Check browser support
|
97 |
if ('webkitSpeechRecognition' in window) {
|
98 |
recognition = new webkitSpeechRecognition();
|
99 |
recognition.continuous = false;
|
|
|
109 |
window.speechSynthesis.speak(speech);
|
110 |
}
|
111 |
|
112 |
+
function startListening() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
recognition.start();
|
114 |
recognition.onresult = function(event) {
|
115 |
+
let result = event.results[0][0].transcript.trim();
|
|
|
116 |
recognition.stop();
|
117 |
+
handleInput(result);
|
118 |
};
|
119 |
}
|
120 |
|
121 |
+
function handleInput(input) {
|
122 |
+
if (!nameCaptured) {
|
123 |
+
nameCaptured = input;
|
124 |
+
document.getElementById('name').value = nameCaptured;
|
125 |
+
speak("You said " + nameCaptured + ". Now, say your email.", startListening);
|
126 |
+
} else if (!emailCaptured) {
|
127 |
+
emailCaptured = input.replace(/\bat\b/g, '@').replace(/\s+/g, '');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
document.getElementById('email').value = emailCaptured;
|
129 |
+
speak("You said " + emailCaptured + ". Now, say your mobile number.", startListening);
|
130 |
+
} else if (!mobileCaptured) {
|
131 |
+
mobileCaptured = input.replace(/\s+/g, '');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
document.getElementById('mobile').value = mobileCaptured;
|
133 |
+
speak("You said " + mobileCaptured + ". Confirm by saying 'OK'.", confirmSubmission);
|
134 |
+
}
|
|
|
135 |
}
|
136 |
|
137 |
+
function confirmSubmission() {
|
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 |
+
autoSubmit();
|
144 |
} else {
|
145 |
+
speak("Let's try again.", startListening);
|
146 |
}
|
147 |
};
|
148 |
}
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
function autoSubmit() {
|
151 |
var name = document.getElementById('name').value;
|
152 |
var email = document.getElementById('email').value;
|
153 |
var phone = document.getElementById('mobile').value;
|
154 |
+
|
155 |
+
// Simulated API request
|
156 |
+
fetch('https://jsonplaceholder.typicode.com/posts', {
|
157 |
method: 'POST',
|
158 |
headers: { 'Content-Type': 'application/json' },
|
159 |
body: JSON.stringify({ name: name, email: email, phone: phone })
|
160 |
})
|
161 |
.then(response => response.json())
|
162 |
.then(data => {
|
163 |
+
document.getElementById('status').textContent = '✅ Submitted successfully!';
|
164 |
+
speak("Your details were submitted successfully!");
|
165 |
+
validateWorldRecords(name, email, phone);
|
166 |
+
})
|
167 |
+
.catch(error => {
|
168 |
+
document.getElementById('status').textContent = '❌ Error submitting!';
|
169 |
+
speak("There was an error submitting your details.");
|
|
|
|
|
170 |
});
|
171 |
}
|
172 |
|
173 |
+
function validateWorldRecords(name, email, phone) {
|
174 |
+
let worldRecordNames = ["Usain Bolt", "Michael Phelps", "Serena Williams"];
|
175 |
+
if (worldRecordNames.includes(name)) {
|
176 |
+
speak("Wow! You are a world record holder!");
|
177 |
+
} else {
|
178 |
+
speak("Thank you for registering.");
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
window.onload = function () {
|
183 |
+
speak("Please say your name.", startListening);
|
184 |
};
|
185 |
</script>
|
186 |
</body>
|