lokesh341 commited on
Commit
45cd82b
Β·
verified Β·
1 Parent(s): b8143e8

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +43 -14
templates/index.html CHANGED
@@ -31,7 +31,7 @@
31
  border-radius: 10px;
32
  width: 500px;
33
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
34
- display: none; /* Initially hidden, will show based on selection */
35
  }
36
  .form-container {
37
  width: 100%;
@@ -93,7 +93,6 @@
93
  <input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
94
 
95
  <p class="info" id="infoMessage">Listening πŸ—£πŸŽ™οΈ...</p>
96
- <p class="status" id="status">πŸ”Š...</p>
97
  </div>
98
  </div>
99
 
@@ -107,7 +106,6 @@
107
  <input type="text" id="loginMobile" placeholder="Your mobile number will appear here..." readonly>
108
 
109
  <p class="info" id="infoMessageLogin">Listening πŸ—£πŸŽ™οΈ...</p>
110
- <p class="status" id="statusLogin">πŸ”Š...</p>
111
  </div>
112
  </div>
113
 
@@ -129,7 +127,7 @@
129
  }
130
 
131
  function askLoginOrRegister() {
132
- speak("Welcome to Biryani Hub. Are you a new customer or an existing customer? Say 'Register' for registration or 'Login' to log in.", function() {
133
  recognition.start();
134
  recognition.onresult = function(event) {
135
  let response = event.results[0][0].transcript.trim().toLowerCase();
@@ -139,7 +137,7 @@
139
  } else if (response.includes("login")) {
140
  showLoginForm();
141
  } else {
142
- speak("Sorry, I didn't understand. Please say 'Register' for registration or 'Login' to log in.", askLoginOrRegister);
143
  }
144
  };
145
  });
@@ -148,13 +146,13 @@
148
  function showRegistrationForm() {
149
  document.getElementById('registrationForm').style.display = 'block';
150
  document.getElementById('loginForm').style.display = 'none';
151
- speak("Please tell me your name to begin the registration.", startListeningForName);
152
  }
153
 
154
  function showLoginForm() {
155
  document.getElementById('loginForm').style.display = 'block';
156
  document.getElementById('registrationForm').style.display = 'none';
157
- speak("Please tell me your email to begin the login process.", startListeningForLoginEmail);
158
  }
159
 
160
  function startListeningForName() {
@@ -162,7 +160,7 @@
162
  recognition.onresult = function(event) {
163
  document.getElementById('name').value = event.results[0][0].transcript.trim();
164
  recognition.stop();
165
- speak("Your name is " + document.getElementById('name').value + ". Is it correct?", confirmName);
166
  };
167
  }
168
 
@@ -172,9 +170,9 @@
172
  let confirmation = event.results[0][0].transcript.trim().toLowerCase();
173
  recognition.stop();
174
  if (confirmation.includes("ok")) {
175
- speak("Great! Now, tell me your email.", startListeningForEmail);
176
  } else {
177
- speak("Let's try again. Tell me your name.", startListeningForName);
178
  }
179
  };
180
  }
@@ -184,7 +182,7 @@
184
  recognition.onresult = function(event) {
185
  document.getElementById('email').value = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
186
  recognition.stop();
187
- speak("You said " + document.getElementById('email').value + ". Is it correct?", confirmEmail);
188
  };
189
  }
190
 
@@ -194,9 +192,31 @@
194
  let confirmation = event.results[0][0].transcript.trim().toLowerCase();
195
  recognition.stop();
196
  if (confirmation.includes("ok")) {
197
- speak("Great! Now, tell me your mobile number.", startListeningForMobile);
198
  } else {
199
- speak("Let's try again. Tell me your email.", startListeningForEmail);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  }
201
  };
202
  }
@@ -206,7 +226,16 @@
206
  recognition.onresult = function(event) {
207
  document.getElementById('loginEmail').value = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
208
  recognition.stop();
209
- speak("You said " + document.getElementById('loginEmail').value + ". Is it correct?", confirmLoginEmail);
 
 
 
 
 
 
 
 
 
210
  };
211
  }
212
 
 
31
  border-radius: 10px;
32
  width: 500px;
33
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
34
+ display: none;
35
  }
36
  .form-container {
37
  width: 100%;
 
93
  <input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
94
 
95
  <p class="info" id="infoMessage">Listening πŸ—£πŸŽ™οΈ...</p>
 
96
  </div>
97
  </div>
98
 
 
106
  <input type="text" id="loginMobile" placeholder="Your mobile number will appear here..." readonly>
107
 
108
  <p class="info" id="infoMessageLogin">Listening πŸ—£πŸŽ™οΈ...</p>
 
109
  </div>
110
  </div>
111
 
 
127
  }
128
 
129
  function askLoginOrRegister() {
130
+ speak("Welcome to Biryani Hub. Say 'Register' to create an account or 'Login' to sign in.", function() {
131
  recognition.start();
132
  recognition.onresult = function(event) {
133
  let response = event.results[0][0].transcript.trim().toLowerCase();
 
137
  } else if (response.includes("login")) {
138
  showLoginForm();
139
  } else {
140
+ speak("I didn't understand. Please say 'Register' to sign up or 'Login' to sign in.", askLoginOrRegister);
141
  }
142
  };
143
  });
 
146
  function showRegistrationForm() {
147
  document.getElementById('registrationForm').style.display = 'block';
148
  document.getElementById('loginForm').style.display = 'none';
149
+ speak("Please say your name to begin registration.", startListeningForName);
150
  }
151
 
152
  function showLoginForm() {
153
  document.getElementById('loginForm').style.display = 'block';
154
  document.getElementById('registrationForm').style.display = 'none';
155
+ speak("Please say your email for login.", startListeningForLoginEmail);
156
  }
157
 
158
  function startListeningForName() {
 
160
  recognition.onresult = function(event) {
161
  document.getElementById('name').value = event.results[0][0].transcript.trim();
162
  recognition.stop();
163
+ speak("Your name is " + document.getElementById('name').value + ". Is this correct?", confirmName);
164
  };
165
  }
166
 
 
170
  let confirmation = event.results[0][0].transcript.trim().toLowerCase();
171
  recognition.stop();
172
  if (confirmation.includes("ok")) {
173
+ speak("Now, say your email.", startListeningForEmail);
174
  } else {
175
+ speak("Let's try again. Say your name.", startListeningForName);
176
  }
177
  };
178
  }
 
182
  recognition.onresult = function(event) {
183
  document.getElementById('email').value = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
184
  recognition.stop();
185
+ speak("You said " + document.getElementById('email').value + ". Is this correct?", confirmEmail);
186
  };
187
  }
188
 
 
192
  let confirmation = event.results[0][0].transcript.trim().toLowerCase();
193
  recognition.stop();
194
  if (confirmation.includes("ok")) {
195
+ speak("Now, say your mobile number.", startListeningForMobile);
196
  } else {
197
+ speak("Let's try again. Say your email.", startListeningForEmail);
198
+ }
199
+ };
200
+ }
201
+
202
+ function startListeningForMobile() {
203
+ recognition.start();
204
+ recognition.onresult = function(event) {
205
+ document.getElementById('mobile').value = event.results[0][0].transcript.trim().replace(/\s+/g, '');
206
+ recognition.stop();
207
+ speak("You said " + document.getElementById('mobile').value + ". Is this correct?", confirmMobile);
208
+ };
209
+ }
210
+
211
+ function confirmMobile() {
212
+ recognition.start();
213
+ recognition.onresult = function(event) {
214
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
215
+ recognition.stop();
216
+ if (confirmation.includes("ok")) {
217
+ speak("Registration complete.");
218
+ } else {
219
+ speak("Let's try again. Say your mobile number.", startListeningForMobile);
220
  }
221
  };
222
  }
 
226
  recognition.onresult = function(event) {
227
  document.getElementById('loginEmail').value = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
228
  recognition.stop();
229
+ speak("Now, say your mobile number.", startListeningForLoginMobile);
230
+ };
231
+ }
232
+
233
+ function startListeningForLoginMobile() {
234
+ recognition.start();
235
+ recognition.onresult = function(event) {
236
+ document.getElementById('loginMobile').value = event.results[0][0].transcript.trim().replace(/\s+/g, '');
237
+ recognition.stop();
238
+ speak("Login successful.");
239
  };
240
  }
241