lokesh341 commited on
Commit
2e36cf4
Β·
verified Β·
1 Parent(s): e308054

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +55 -53
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%;
@@ -75,6 +75,24 @@
75
  color: gray;
76
  margin-top: 10px;
77
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  </style>
79
  </head>
80
  <body>
@@ -93,7 +111,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,10 +124,17 @@
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
 
 
 
 
 
 
 
 
 
114
  <script>
115
  let recognition;
116
  if ('webkitSpeechRecognition' in window) {
@@ -129,7 +153,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 +163,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 +172,7 @@
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,52 +180,36 @@
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
-
169
- function confirmName() {
170
- recognition.start();
171
- recognition.onresult = function(event) {
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
- }
181
-
182
- function startListeningForEmail() {
183
- recognition.start();
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
 
191
- function confirmEmail() {
192
- recognition.start();
193
- recognition.onresult = function(event) {
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
- }
203
-
204
- function startListeningForLoginEmail() {
205
- recognition.start();
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
 
213
  window.onload = function () {
 
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%;
 
75
  color: gray;
76
  margin-top: 10px;
77
  }
78
+ #confirmation {
79
+ display: none;
80
+ background-color: #f9f9f9;
81
+ padding: 20px;
82
+ border-radius: 10px;
83
+ margin-top: 20px;
84
+ }
85
+ .confirm-button {
86
+ padding: 10px 20px;
87
+ background-color: #ff6a00;
88
+ color: white;
89
+ border: none;
90
+ border-radius: 5px;
91
+ cursor: pointer;
92
+ }
93
+ .confirm-button:hover {
94
+ background-color: #e65e00;
95
+ }
96
  </style>
97
  </head>
98
  <body>
 
111
  <input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
112
 
113
  <p class="info" id="infoMessage">Listening πŸ—£πŸŽ™οΈ...</p>
 
114
  </div>
115
  </div>
116
 
 
124
  <input type="text" id="loginMobile" placeholder="Your mobile number will appear here..." readonly>
125
 
126
  <p class="info" id="infoMessageLogin">Listening πŸ—£πŸŽ™οΈ...</p>
 
127
  </div>
128
  </div>
129
 
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="autoSubmit()">Confirm</button>
136
+ </div>
137
+
138
  <script>
139
  let recognition;
140
  if ('webkitSpeechRecognition' in window) {
 
153
  }
154
 
155
  function askLoginOrRegister() {
156
+ speak("Welcome to Biryani Hub. Say 'Register' to create an account or 'Login' to sign in.", function() {
157
  recognition.start();
158
  recognition.onresult = function(event) {
159
  let response = event.results[0][0].transcript.trim().toLowerCase();
 
163
  } else if (response.includes("login")) {
164
  showLoginForm();
165
  } else {
166
+ speak("I didn't understand. Please say 'Register' to sign up or 'Login' to sign in.", askLoginOrRegister);
167
  }
168
  };
169
  });
 
172
  function showRegistrationForm() {
173
  document.getElementById('registrationForm').style.display = 'block';
174
  document.getElementById('loginForm').style.display = 'none';
175
+ speak("Please say your name to begin registration.", startListeningForName);
 
 
 
 
 
 
176
  }
177
 
178
  function startListeningForName() {
 
180
  recognition.onresult = function(event) {
181
  document.getElementById('name').value = event.results[0][0].transcript.trim();
182
  recognition.stop();
183
+ autoConfirm();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  };
185
  }
186
 
187
+ function autoConfirm() {
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
+ setTimeout(autoSubmit, 3000);
193
+ }
194
+
195
+ function autoSubmit() {
196
+ var name = document.getElementById('name').value;
197
+ var email = document.getElementById('email').value;
198
+ var phone = document.getElementById('mobile').value;
199
+ fetch('/submit', {
200
+ method: 'POST',
201
+ headers: { 'Content-Type': 'application/json' },
202
+ body: JSON.stringify({ name: name, email: email, phone: phone })
203
+ })
204
+ .then(response => response.json())
205
+ .then(data => {
206
+ if (data.success) {
207
+ speak("Your registration is complete. Thank you for registering.");
208
+ setTimeout(() => location.reload(), 5000);
209
  } else {
210
+ speak("There was an error submitting your details. Please try again.");
211
  }
212
+ });
 
 
 
 
 
 
 
 
 
213
  }
214
 
215
  window.onload = function () {