Subbu1304 commited on
Commit
78ce5bd
·
verified ·
1 Parent(s): 148fa44

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +28 -41
templates/index.html CHANGED
@@ -126,63 +126,50 @@
126
  window.speechSynthesis.speak(speech);
127
  }
128
 
129
- function askLoginOrRegister() {
130
- speak("Welcome to Biryani Hub. Are you a new user or an existing user?", function() {
131
- recognition.start();
132
- recognition.onresult = function(event) {
133
- let response = event.results[0][0].transcript.trim().toLowerCase();
134
- recognition.stop();
135
- if (response.includes("new user")) {
136
- showRegistrationForm();
137
- } else if (response.includes("existing user")) {
138
- showLoginForm();
139
- } else {
140
- speak("Please say 'new user' or 'existing user'.", askLoginOrRegister);
141
- }
142
- };
143
- });
144
- }
145
-
146
- function showLoginForm() {
147
- document.getElementById('loginForm').style.display = 'block';
148
- speak("Please say your email.", startListeningForEmail);
149
- }
150
-
151
- function showRegistrationForm() {
152
- document.getElementById('registrationForm').style.display = 'block';
153
- speak("Please say your name.", startListeningForName);
154
- }
155
-
156
- function startListeningForName() {
157
  recognition.start();
158
  recognition.onresult = function(event) {
159
- let name = event.results[0][0].transcript.trim();
160
- document.getElementById('name').value = name;
161
  recognition.stop();
162
- speak("You said " + name + ". Is it correct?", confirmName);
163
  };
164
  }
165
 
166
- function confirmName() {
167
  recognition.start();
168
  recognition.onresult = function(event) {
169
- let confirmation = event.results[0][0].transcript.trim().toLowerCase();
 
170
  recognition.stop();
171
- if (confirmation.includes("yes")) {
172
- speak("Great! Now, say your email.", startListeningForEmail);
173
- } else {
174
- speak("Let's try again. Please say your name.", startListeningForName);
175
- }
176
  };
177
  }
178
 
 
 
 
 
 
 
 
179
  function submitForm() {
180
  speak("Your details have been submitted. Welcome to Biryani Hub!");
181
  }
182
 
183
- window.onload = askLoginOrRegister;
 
 
 
 
 
 
 
 
 
 
 
 
184
  </script>
185
  </body>
186
  </html>
187
-
188
-
 
126
  window.speechSynthesis.speak(speech);
127
  }
128
 
129
+ function startListeningForEmail() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  recognition.start();
131
  recognition.onresult = function(event) {
132
+ let email = event.results[0][0].transcript.trim();
133
+ document.getElementById('email').value = email;
134
  recognition.stop();
135
+ speak("You said " + email + ". Is it correct?", startListeningForMobile);
136
  };
137
  }
138
 
139
+ function startListeningForMobile() {
140
  recognition.start();
141
  recognition.onresult = function(event) {
142
+ let mobile = event.results[0][0].transcript.trim();
143
+ document.getElementById('mobile').value = mobile;
144
  recognition.stop();
145
+ speak("You said " + mobile + ". Is it correct?", confirmDetails);
 
 
 
 
146
  };
147
  }
148
 
149
+ function confirmDetails() {
150
+ document.getElementById('confirmName').innerText = document.getElementById('name').value;
151
+ document.getElementById('confirmEmail').innerText = document.getElementById('email').value;
152
+ document.getElementById('confirmPhone').innerText = document.getElementById('mobile').value;
153
+ document.getElementById('confirmation').style.display = 'block';
154
+ }
155
+
156
  function submitForm() {
157
  speak("Your details have been submitted. Welcome to Biryani Hub!");
158
  }
159
 
160
+ function startListeningForName() {
161
+ recognition.start();
162
+ recognition.onresult = function(event) {
163
+ let name = event.results[0][0].transcript.trim();
164
+ document.getElementById('name').value = name;
165
+ recognition.stop();
166
+ speak("You said " + name + ". Is it correct?", startListeningForEmail);
167
+ };
168
+ }
169
+
170
+ window.onload = function () {
171
+ speak("Please say your name.", startListeningForName);
172
+ };
173
  </script>
174
  </body>
175
  </html>