lokesh341 commited on
Commit
36abe92
·
verified ·
1 Parent(s): 5979d1d

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +48 -177
templates/index.html CHANGED
@@ -75,52 +75,41 @@
75
  </style>
76
  </head>
77
  <body>
78
- <div class="container">
79
- <h1>Welcome to Biryani Hub 🍽</h1>
80
- <h2 class="info" id="infoMessage">Listening... 🗣🎙</h2>
81
- <p class="status" id="status">🔊 Speak Now...</p>
82
-
83
- <!-- Registration Form -->
84
- <div id="registrationForm">
85
- <h2>Register</h2>
86
- <label for="name">Your Name</label>
87
- <input type="text" id="name" placeholder="Listening for name..." readonly>
88
 
89
- <label for="email">Your Email</label>
90
- <input type="text" id="email" placeholder="Listening for email..." readonly>
 
 
91
 
92
- <label for="mobile">Your Mobile Number</label>
93
- <input type="text" id="mobile" placeholder="Listening for mobile number..." readonly>
94
 
95
- <button class="confirm-button" onclick="startVoiceRecognition()">Restart Voice Input</button>
96
- <button class="switch-button" onclick="showLoginForm()">Switch to Login</button>
97
- </div>
98
 
99
- <!-- Login Form -->
100
- <div id="loginForm" style="display: none;">
101
- <h2>Login</h2>
102
- <label for="loginEmail">Your Email</label>
103
- <input type="text" id="loginEmail" placeholder="Enter your email" required>
104
 
105
- <label for="loginMobile">Your Mobile Number</label>
106
- <input type="text" id="loginMobile" placeholder="Enter your mobile number" required>
 
 
107
 
108
- <button class="confirm-button" onclick="submitLogin()">Login</button>
109
- <button class="switch-button" onclick="showRegistrationForm()">Switch to Register</button>
110
- </div>
111
 
112
- <!-- Confirmation Details -->
113
- <div id="confirmationForm" style="display: none;">
114
- <h2>Confirm Your Details</h2>
115
- <p><strong>Name:</strong> <span id="confirmName"></span></p>
116
- <p><strong>Email:</strong> <span id="confirmEmail"></span></p>
117
- <p><strong>Phone:</strong> <span id="confirmPhone"></span></p>
118
- <button class="confirm-button" onclick="submitDetails()">Confirm and Submit</button>
119
- </div>
120
 
121
- <div id="statusMessage" style="display: none;">
122
- <h2 id="statusText"></h2>
123
- </div>
124
  </div>
125
 
126
  <script>
@@ -148,7 +137,6 @@
148
  recognition.stop();
149
  if (response.includes("new")) {
150
  showRegistrationForm();
151
- captureName();
152
  } else if (response.includes("existing")) {
153
  showLoginForm();
154
  } else {
@@ -159,160 +147,43 @@
159
  }
160
 
161
  function showRegistrationForm() {
 
162
  document.getElementById('registrationForm').style.display = 'block';
163
  document.getElementById('loginForm').style.display = 'none';
164
- document.getElementById('confirmationForm').style.display = 'none';
165
- document.getElementById('statusMessage').style.display = 'none';
166
  }
167
 
168
  function showLoginForm() {
169
- document.getElementById('loginForm').style.display = 'block';
170
  document.getElementById('registrationForm').style.display = 'none';
171
- document.getElementById('confirmationForm').style.display = 'none';
172
- document.getElementById('statusMessage').style.display = 'none';
173
- speak("Please provide your email and mobile number to login.");
174
- }
175
-
176
- function captureName() {
177
- speak("Please say your name.", function () {
178
- recognition.start();
179
- recognition.onresult = function (event) {
180
- let nameCaptured = event.results[0][0].transcript.trim();
181
- document.getElementById('name').value = nameCaptured;
182
- recognition.stop();
183
- speak("You said " + nameCaptured + ". Is it correct?", function () {
184
- confirmName(nameCaptured);
185
- });
186
- };
187
- });
188
- }
189
-
190
- function confirmName(nameCaptured) {
191
- recognition.start();
192
- recognition.onresult = function (event) {
193
- let confirmation = event.results[0][0].transcript.trim().toLowerCase();
194
- recognition.stop();
195
- if (confirmation.includes("yes") || confirmation.includes("ok")) {
196
- captureEmail();
197
- } else {
198
- captureName();
199
- }
200
- };
201
- }
202
-
203
- function captureEmail() {
204
- speak("Now, say your email.", function () {
205
- recognition.start();
206
- recognition.onresult = function (event) {
207
- let emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
208
- document.getElementById('email').value = emailCaptured;
209
- recognition.stop();
210
- speak("You said " + emailCaptured + ". Is it correct?", function () {
211
- confirmEmail(emailCaptured);
212
- });
213
- };
214
- });
215
- }
216
-
217
- function confirmEmail(emailCaptured) {
218
- recognition.start();
219
- recognition.onresult = function (event) {
220
- let confirmation = event.results[0][0].transcript.trim().toLowerCase();
221
- recognition.stop();
222
- if (confirmation.includes("yes") || confirmation.includes("ok")) {
223
- captureMobile();
224
- } else {
225
- captureEmail();
226
- }
227
- };
228
- }
229
-
230
- function captureMobile() {
231
- speak("Now, say your mobile number.", function () {
232
- recognition.start();
233
- recognition.onresult = function (event) {
234
- let mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
235
- document.getElementById('mobile').value = mobileCaptured;
236
- recognition.stop();
237
- speak("You said " + mobileCaptured + ". Is it correct?", function () {
238
- confirmMobile(mobileCaptured);
239
- });
240
- };
241
- });
242
- }
243
-
244
- function confirmMobile(mobileCaptured) {
245
- recognition.start();
246
- recognition.onresult = function (event) {
247
- let confirmation = event.results[0][0].transcript.trim().toLowerCase();
248
- recognition.stop();
249
- if (confirmation.includes("yes") || confirmation.includes("ok")) {
250
- // Show confirmation page with details
251
- confirmDetailsAndShow();
252
- } else {
253
- captureMobile();
254
- }
255
- };
256
- }
257
-
258
- // Show details for confirmation
259
- function confirmDetailsAndShow() {
260
- const name = document.getElementById('name').value;
261
- const email = document.getElementById('email').value;
262
- const phone = document.getElementById('mobile').value;
263
-
264
- document.getElementById('confirmName').textContent = name;
265
- document.getElementById('confirmEmail').textContent = email;
266
- document.getElementById('confirmPhone').textContent = phone;
267
-
268
- // Show confirmation form and hide registration form
269
- document.getElementById('registrationForm').style.display = 'none';
270
- document.getElementById('confirmationForm').style.display = 'block';
271
  }
272
 
273
- // Submit details to the backend (Salesforce)
274
- function submitDetails() {
275
  const name = document.getElementById('name').value;
276
  const email = document.getElementById('email').value;
277
- const phone = document.getElementById('mobile').value;
278
 
279
- // Send to backend for Salesforce submission
280
- fetch('/submit', {
281
- method: 'POST',
282
- headers: { 'Content-Type': 'application/json' },
283
- body: JSON.stringify({ name, email, phone })
284
- })
285
- .then(response => response.json())
286
- .then(data => {
287
- if (data.success) {
288
- document.getElementById('statusText').textContent = 'Your details have been successfully submitted!';
289
- document.getElementById('statusMessage').style.display = 'block';
290
- setTimeout(() => {
291
- window.location.href = '/login'; // Redirect to login page
292
- }, 3000);
293
- } else {
294
- document.getElementById('statusText').textContent = 'There was an error submitting your details. Please try again.';
295
- document.getElementById('statusMessage').style.display = 'block';
296
- }
297
- })
298
- .catch(error => {
299
- document.getElementById('statusText').textContent = 'An error occurred. Please try again.';
300
- document.getElementById('statusMessage').style.display = 'block';
301
- });
302
  }
303
 
304
- // Handle login submission
305
  function submitLogin() {
306
- const loginEmail = document.getElementById('loginEmail').value;
307
- const loginMobile = document.getElementById('loginMobile').value;
308
 
309
- // Here, you can add validation for login based on Salesforce or your database
310
- // For now, it's just a simple check to show success.
311
- if (loginEmail && loginMobile) {
312
- speak("Login successful! Welcome back.");
313
- window.location.href = '/dashboard'; // Redirect to a dashboard or home page after successful login
 
 
314
  } else {
315
- speak("Please provide valid login details.");
316
  }
317
  }
318
 
 
75
  </style>
76
  </head>
77
  <body>
78
+ <div class="container" id="welcomePage">
79
+ <h1>Welcome to Biriyani Hub 🍽</h1>
80
+ <h2 class="info" id="infoMessage">Welcome! Are you a new customer or an existing one?</h2>
81
+ <p class="status" id="status">🔊 Please say 'new' to register or 'existing' to login.</p>
82
+ </div>
 
 
 
 
 
83
 
84
+ <div class="container" id="registrationForm" style="display: none;">
85
+ <h2>Register</h2>
86
+ <label for="name">Your Name</label>
87
+ <input type="text" id="name" placeholder="Enter your name" required>
88
 
89
+ <label for="email">Your Email</label>
90
+ <input type="text" id="email" placeholder="Enter your email" required>
91
 
92
+ <label for="mobile">Your Mobile Number</label>
93
+ <input type="text" id="mobile" placeholder="Enter your mobile number" required>
 
94
 
95
+ <button class="confirm-button" onclick="submitRegistration()">Submit Registration</button>
96
+ <button class="switch-button" onclick="showLoginForm()">Switch to Login</button>
97
+ </div>
 
 
98
 
99
+ <div class="container" id="loginForm" style="display: none;">
100
+ <h2>Login</h2>
101
+ <label for="loginEmail">Your Email</label>
102
+ <input type="text" id="loginEmail" placeholder="Enter your email" required>
103
 
104
+ <label for="loginMobile">Your Mobile Number</label>
105
+ <input type="text" id="loginMobile" placeholder="Enter your mobile number" required>
 
106
 
107
+ <button class="confirm-button" onclick="submitLogin()">Login</button>
108
+ <button class="switch-button" onclick="showRegistrationForm()">Switch to Register</button>
109
+ </div>
 
 
 
 
 
110
 
111
+ <div id="statusMessage" style="display: none;">
112
+ <h2 id="statusText"></h2>
 
113
  </div>
114
 
115
  <script>
 
137
  recognition.stop();
138
  if (response.includes("new")) {
139
  showRegistrationForm();
 
140
  } else if (response.includes("existing")) {
141
  showLoginForm();
142
  } else {
 
147
  }
148
 
149
  function showRegistrationForm() {
150
+ document.getElementById('welcomePage').style.display = 'none';
151
  document.getElementById('registrationForm').style.display = 'block';
152
  document.getElementById('loginForm').style.display = 'none';
 
 
153
  }
154
 
155
  function showLoginForm() {
156
+ document.getElementById('welcomePage').style.display = 'none';
157
  document.getElementById('registrationForm').style.display = 'none';
158
+ document.getElementById('loginForm').style.display = 'block';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  }
160
 
161
+ function submitRegistration() {
 
162
  const name = document.getElementById('name').value;
163
  const email = document.getElementById('email').value;
164
+ const mobile = document.getElementById('mobile').value;
165
 
166
+ // Simulate submission (e.g., send data to backend or Salesforce)
167
+ document.getElementById('statusText').textContent = `Thank you for registering, ${name}!`;
168
+ document.getElementById('statusMessage').style.display = 'block';
169
+ setTimeout(() => {
170
+ window.location.href = '/login'; // Redirect to login page
171
+ }, 3000);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  }
173
 
 
174
  function submitLogin() {
175
+ const email = document.getElementById('loginEmail').value;
176
+ const mobile = document.getElementById('loginMobile').value;
177
 
178
+ // Simulate login check (e.g., match against backend or Salesforce)
179
+ if (email && mobile) {
180
+ document.getElementById('statusText').textContent = 'Login successful! Redirecting...';
181
+ document.getElementById('statusMessage').style.display = 'block';
182
+ setTimeout(() => {
183
+ window.location.href = '/dashboard'; // Redirect to dashboard
184
+ }, 3000);
185
  } else {
186
+ speak("Please enter valid login details.");
187
  }
188
  }
189