lokesh341 commited on
Commit
a5ae5d4
ยท
verified ยท
1 Parent(s): 2e36cf4

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +120 -128
templates/index.html CHANGED
@@ -4,139 +4,56 @@
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Biryani Hub - Register & Login</title>
8
  <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
 
9
  <style>
10
- body {
11
- font-family: 'Roboto', sans-serif;
12
- background: linear-gradient(135deg, #f4c542, #ff8f6a);
13
- margin: 0;
14
- display: flex;
15
- flex-direction: column;
16
- justify-content: center;
17
- align-items: center;
18
- height: 100vh;
19
- text-align: center;
20
- }
21
- .header-title {
22
- font-size: 40px;
23
- font-weight: bold;
24
- color: white;
25
- text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
26
- margin-bottom: 20px;
27
- }
28
- .container {
29
- background-color: #fff;
30
- padding: 40px 50px;
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%;
38
- }
39
- h2 {
40
- font-size: 24px;
41
- font-weight: bold;
42
- color: #ff6a00;
43
- margin-bottom: 20px;
44
- }
45
- label {
46
- font-size: 16px;
47
- display: block;
48
- text-align: left;
49
- font-weight: bold;
50
- color: #333;
51
- margin-top: 10px;
52
- }
53
- input {
54
- width: 100%;
55
- padding: 12px;
56
- font-size: 16px;
57
- border: 2px solid #ccc;
58
- border-radius: 8px;
59
- margin-top: 8px;
60
- box-sizing: border-box;
61
- background-color: #f9f9f9;
62
- }
63
- input:focus {
64
- border-color: #ff6a00;
65
- outline: none;
66
- }
67
- .info {
68
- margin-top: 20px;
69
- font-size: 16px;
70
- color: #ff6a00;
71
- font-weight: bold;
72
- }
73
- .status {
74
- font-size: 14px;
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>
99
- <h1 class="header-title">Welcome to Biryani Hub ๐Ÿฝ</h1>
100
-
101
- <div class="container" id="registrationForm">
102
- <div class="form-container">
103
- <h2>Register</h2>
104
- <label for="name">Your Name</label>
105
- <input type="text" id="name" placeholder="Your name will appear here..." readonly>
106
-
107
- <label for="email">Your Email</label>
108
- <input type="text" id="email" placeholder="Your email will appear here..." readonly>
109
 
110
- <label for="mobile">Your Mobile Number</label>
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
-
117
- <div class="container" id="loginForm">
118
  <div class="form-container">
119
- <h2>Login</h2>
120
- <label for="loginEmail">Your Email</label>
121
- <input type="text" id="loginEmail" placeholder="Your email will appear here..." readonly>
122
-
123
- <label for="loginMobile">Your Mobile Number</label>
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) {
141
  recognition = new webkitSpeechRecognition();
142
  recognition.continuous = false;
@@ -152,18 +69,19 @@
152
  window.speechSynthesis.speak(speech);
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();
160
  recognition.stop();
161
- if (response.includes("register")) {
162
  showRegistrationForm();
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,18 +90,88 @@
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() {
179
  recognition.start();
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;
@@ -192,6 +180,7 @@
192
  setTimeout(autoSubmit, 3000);
193
  }
194
 
 
195
  function autoSubmit() {
196
  var name = document.getElementById('name').value;
197
  var email = document.getElementById('email').value;
@@ -204,9 +193,12 @@
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
  });
 
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Biryani Hub Login & Registration</title>
8
  <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
9
+ <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
10
  <style>
11
+ /* Styling remains unchanged */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  </style>
13
  </head>
14
  <body>
15
+ <div class="container">
16
+ <h1>Welcome to Biryani Hub ๐Ÿฝ ๐Ÿ—</h1>
 
 
 
 
 
 
 
 
17
 
18
+ <!-- Form Section -->
 
 
 
 
 
 
 
19
  <div class="form-container">
20
+ <!-- Registration Form -->
21
+ <div class="form-section" id="registrationForm" style="display: block;">
22
+ <h2 class="header">Register</h2>
23
+ <label for="name">Your Name</label>
24
+ <input type="text" id="name" placeholder="Your name will appear here..." readonly>
25
+
26
+ <label for="email">Your Email</label>
27
+ <input type="text" id="email" placeholder="Your email will appear here..." readonly>
28
+
29
+ <label for="mobile">Your Mobile Number</label>
30
+ <input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
31
+
32
+ <p class="info" id="infoMessage">Listening ๐Ÿ—ฃ๐ŸŽ™๏ธ...</p>
33
+ <p class="status" id="status">๐Ÿ”Š...</p>
34
+ </div>
35
+
36
+ <!-- Login Form -->
37
+ <div class="form-section" id="loginForm" style="display: none;">
38
+ <h2 class="header">Login</h2>
39
+ <label for="loginEmail">Your Email</label>
40
+ <input type="text" id="loginEmail" placeholder="Your email will appear here..." readonly>
41
+
42
+ <label for="loginMobile">Your Mobile Number</label>
43
+ <input type="text" id="loginMobile" placeholder="Your mobile number will appear here..." readonly>
44
+
45
+ <p class="info" id="infoMessageLogin">Listening ๐Ÿ—ฃ๐ŸŽ™๏ธ...</p>
46
+ <p class="status" id="statusLogin">๐Ÿ”Š...</p>
47
+ </div>
48
  </div>
49
  </div>
50
 
 
 
 
 
 
 
 
 
51
  <script>
52
  let recognition;
53
+ let nameCaptured = "";
54
+ let emailCaptured = "";
55
+ let mobileCaptured = "";
56
+
57
  if ('webkitSpeechRecognition' in window) {
58
  recognition = new webkitSpeechRecognition();
59
  recognition.continuous = false;
 
69
  window.speechSynthesis.speak(speech);
70
  }
71
 
72
+ // Start by asking if the user is a new or existing customer
73
  function askLoginOrRegister() {
74
+ speak("Are you a new customer or an existing customer? Say 'new' for registration or 'existing' for login.", function() {
75
  recognition.start();
76
  recognition.onresult = function(event) {
77
  let response = event.results[0][0].transcript.trim().toLowerCase();
78
  recognition.stop();
79
+ if (response.includes("new")) {
80
  showRegistrationForm();
81
+ } else if (response.includes("existing")) {
82
  showLoginForm();
83
  } else {
84
+ speak("Sorry, I didn't understand. Please say 'new' for registration or 'existing' for login.", askLoginOrRegister);
85
  }
86
  };
87
  });
 
90
  function showRegistrationForm() {
91
  document.getElementById('registrationForm').style.display = 'block';
92
  document.getElementById('loginForm').style.display = 'none';
93
+ speak("Please tell me your name to begin the registration.", startListeningForName);
94
+ }
95
+
96
+ function showLoginForm() {
97
+ document.getElementById('loginForm').style.display = 'block';
98
+ document.getElementById('registrationForm').style.display = 'none';
99
+ speak("Please tell me your email to begin the login process.", startListeningForLoginEmail);
100
  }
101
 
102
+ // Capture the name for registration
103
  function startListeningForName() {
104
  recognition.start();
105
  recognition.onresult = function(event) {
106
+ nameCaptured = event.results[0][0].transcript.trim();
107
+ document.getElementById('name').value = nameCaptured;
108
  recognition.stop();
109
+ speak("You said " + nameCaptured + ". Is it correct?", confirmName);
110
+ };
111
+ }
112
+
113
+ function confirmName() {
114
+ recognition.start();
115
+ recognition.onresult = function(event) {
116
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
117
+ recognition.stop();
118
+ if (confirmation.includes("ok")) {
119
+ speak("Great! Now, tell me your email.", startListeningForEmail);
120
+ } else {
121
+ speak("Let's try again. Tell me your name.", startListeningForName);
122
+ }
123
+ };
124
+ }
125
+
126
+ // Capture email for registration
127
+ function startListeningForEmail() {
128
+ recognition.start();
129
+ recognition.onresult = function(event) {
130
+ emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
131
+ document.getElementById('email').value = emailCaptured;
132
+ recognition.stop();
133
+ speak("You said " + emailCaptured + ". Is it correct?", confirmEmail);
134
+ };
135
+ }
136
+
137
+ function confirmEmail() {
138
+ recognition.start();
139
+ recognition.onresult = function(event) {
140
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
141
+ recognition.stop();
142
+ if (confirmation.includes("ok")) {
143
+ speak("Great! Now, tell me your mobile number.", startListeningForMobile);
144
+ } else {
145
+ speak("Let's try again. Tell me your email.", startListeningForEmail);
146
+ }
147
+ };
148
+ }
149
+
150
+ // Capture mobile number for registration
151
+ function startListeningForMobile() {
152
+ recognition.start();
153
+ recognition.onresult = function(event) {
154
+ mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
155
+ document.getElementById('mobile').value = mobileCaptured;
156
+ recognition.stop();
157
+ speak("You said " + mobileCaptured + ". Is it correct?", confirmMobile);
158
+ };
159
+ }
160
+
161
+ function confirmMobile() {
162
+ recognition.start();
163
+ recognition.onresult = function(event) {
164
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
165
+ recognition.stop();
166
+ if (confirmation.includes("ok")) {
167
+ autoConfirm();
168
+ } else {
169
+ speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
170
+ }
171
  };
172
  }
173
 
174
+ // Confirm details and submit automatically
175
  function autoConfirm() {
176
  document.getElementById('confirmName').textContent = document.getElementById('name').value;
177
  document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
 
180
  setTimeout(autoSubmit, 3000);
181
  }
182
 
183
+ // Submit details to Salesforce
184
  function autoSubmit() {
185
  var name = document.getElementById('name').value;
186
  var email = document.getElementById('email').value;
 
193
  .then(response => response.json())
194
  .then(data => {
195
  if (data.success) {
196
+ document.getElementById('status').textContent = 'Your details were submitted successfully!';
197
+ document.getElementById('confirmation').style.display = 'none';
198
  speak("Your registration is complete. Thank you for registering.");
199
  setTimeout(() => location.reload(), 5000);
200
  } else {
201
+ document.getElementById('status').textContent = 'There was an error submitting your details.';
202
  speak("There was an error submitting your details. Please try again.");
203
  }
204
  });