lokesh341 commited on
Commit
66cea21
·
verified ·
1 Parent(s): c7510fe

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +38 -93
templates/index.html CHANGED
@@ -75,6 +75,23 @@
75
  color: gray;
76
  margin-top: 10px;
77
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  </style>
79
  </head>
80
  <body>
@@ -109,6 +126,15 @@
109
  </div>
110
  </div>
111
 
 
 
 
 
 
 
 
 
 
112
  <script>
113
  let recognition;
114
  if ('webkitSpeechRecognition' in window) {
@@ -149,76 +175,29 @@
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() {
159
  recognition.start();
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
-
167
- function confirmName() {
168
- recognition.start();
169
- recognition.onresult = function(event) {
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
  }
179
 
180
- function startListeningForEmail() {
181
- recognition.start();
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
-
189
- function confirmEmail() {
190
- recognition.start();
191
- recognition.onresult = function(event) {
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
- function autoConfirm() {
211
  document.getElementById('confirmName').textContent = document.getElementById('name').value;
212
  document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
213
  document.getElementById('confirmPhone').textContent = document.getElementById('mobile').value;
214
  document.getElementById('confirmation').style.display = 'block';
215
- setTimeout(autoSubmit, 3000);
216
  }
217
- function autoSubmit() {
218
- var name = document.getElementById('name').value;
219
- var email = document.getElementById('email').value;
220
- var phone = document.getElementById('mobile').value;
221
- fetch('/submit', {
 
 
222
  method: 'POST',
223
  headers: { 'Content-Type': 'application/json' },
224
  body: JSON.stringify({ name: name, email: email, phone: phone })
@@ -226,46 +205,12 @@ function autoConfirm() {
226
  .then(response => response.json())
227
  .then(data => {
228
  if (data.success) {
229
- document.getElementById('status').textContent = 'Your details were submitted successfully!';
230
- document.getElementById('confirmation').style.display = 'none';
231
- speak("Your registration is complete. Thank you for registering.");
232
- setTimeout(() => location.reload(), 5000);
233
  } else {
234
- document.getElementById('status').textContent = 'There was an error submitting your details.';
235
- speak("There was an error submitting your details. Please try again.");
236
  }
237
  });
238
  }
239
- function confirmMobile() {
240
- recognition.start();
241
- recognition.onresult = function(event) {
242
- let confirmation = event.results[0][0].transcript.trim().toLowerCase();
243
- recognition.stop();
244
- if (confirmation.includes("ok")) {
245
- speak("Registration complete.");
246
- } else {
247
- speak("Let's try again. Say your mobile number.", startListeningForMobile);
248
- }
249
- };
250
- }
251
-
252
- function startListeningForLoginEmail() {
253
- recognition.start();
254
- recognition.onresult = function(event) {
255
- document.getElementById('loginEmail').value = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
256
- recognition.stop();
257
- speak("Now, say your mobile number.", startListeningForLoginMobile);
258
- };
259
- }
260
-
261
- function startListeningForLoginMobile() {
262
- recognition.start();
263
- recognition.onresult = function(event) {
264
- document.getElementById('loginMobile').value = event.results[0][0].transcript.trim().replace(/\s+/g, '');
265
- recognition.stop();
266
- speak("Login successful.");
267
- };
268
- }
269
 
270
  window.onload = function () {
271
  askLoginOrRegister();
 
75
  color: gray;
76
  margin-top: 10px;
77
  }
78
+ #confirmation {
79
+ display: none;
80
+ background-color: white;
81
+ padding: 20px;
82
+ border-radius: 10px;
83
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
84
+ margin-top: 20px;
85
+ }
86
+ .confirm-button {
87
+ padding: 10px 20px;
88
+ background-color: #ff6a00;
89
+ color: white;
90
+ border: none;
91
+ border-radius: 5px;
92
+ cursor: pointer;
93
+ font-size: 16px;
94
+ }
95
  </style>
96
  </head>
97
  <body>
 
126
  </div>
127
  </div>
128
 
129
+ <!-- Confirmation Dialog -->
130
+ <div id="confirmation">
131
+ <h2>Confirm Your Details:</h2>
132
+ <p><strong>Name:</strong> <span id="confirmName"></span></p>
133
+ <p><strong>Email:</strong> <span id="confirmEmail"></span></p>
134
+ <p><strong>Phone:</strong> <span id="confirmPhone"></span></p>
135
+ <button class="confirm-button" onclick="submitDetails()">Confirm & Submit</button>
136
+ </div>
137
+
138
  <script>
139
  let recognition;
140
  if ('webkitSpeechRecognition' in window) {
 
175
  speak("Please say your name to begin registration.", startListeningForName);
176
  }
177
 
 
 
 
 
 
 
178
  function startListeningForName() {
179
  recognition.start();
180
  recognition.onresult = function(event) {
181
  document.getElementById('name').value = event.results[0][0].transcript.trim();
182
  recognition.stop();
183
+ speak("Your name is " + document.getElementById('name').value + ". Is this correct?", confirmDetails);
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  };
185
  }
186
 
187
+ function confirmDetails() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  document.getElementById('confirmName').textContent = document.getElementById('name').value;
189
  document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
190
  document.getElementById('confirmPhone').textContent = document.getElementById('mobile').value;
191
  document.getElementById('confirmation').style.display = 'block';
192
+ speak("Please confirm your details and submit.");
193
  }
194
+
195
+ function submitDetails() {
196
+ let name = document.getElementById('name').value;
197
+ let email = document.getElementById('email').value;
198
+ let phone = document.getElementById('mobile').value;
199
+
200
+ fetch('/register', {
201
  method: 'POST',
202
  headers: { 'Content-Type': 'application/json' },
203
  body: JSON.stringify({ name: name, email: email, phone: phone })
 
205
  .then(response => response.json())
206
  .then(data => {
207
  if (data.success) {
208
+ speak("Registration complete. Thank you for registering.");
 
 
 
209
  } else {
210
+ speak("Error submitting details. Please try again.");
 
211
  }
212
  });
213
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
 
215
  window.onload = function () {
216
  askLoginOrRegister();