lokesh341 commited on
Commit
72a81f7
Β·
verified Β·
1 Parent(s): 28591dd

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +187 -54
templates/index.html CHANGED
@@ -4,87 +4,220 @@
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Login - Biryani Hub</title>
 
8
  <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
9
  </head>
10
- <body>
11
-
12
- <div class="container">
13
- <h2>Welcome to Biryani Hub 🍽️ πŸ—</h2>
14
 
15
- <!-- Voice Input Section -->
16
- <div class="voice-section">
17
- <label for="name">Your Name</label>
18
- <input type="text" id="name" placeholder="Your name will appear here..." disabled>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- <label for="email">Your Email</label>
21
- <input type="email" id="voice-email" placeholder="Your email will appear here..." disabled>
 
 
 
 
 
 
 
 
 
 
22
 
23
- <label for="phone">Your Mobile Number</label>
24
- <input type="text" id="voice-phone" placeholder="Your mobile number will appear here..." disabled>
 
 
 
 
 
 
 
 
25
 
26
- <p><span class="listening">Listening πŸŽ™οΈ...</span></p>
27
- <button onclick="startVoiceRecognition()">Start Voice Recognition</button>
28
- </div>
 
 
29
 
30
- <!-- Login Section -->
31
- <div class="login-section">
32
- <h2>Login to Biryani Hub</h2>
33
- <label for="login-email">Email</label>
34
- <input type="email" id="login-email" placeholder="Enter your email">
 
 
 
35
 
36
- <label for="login-phone">Phone Number</label>
37
- <input type="text" id="login-phone" placeholder="Enter your phone number">
 
 
 
38
 
39
- <button onclick="login()">Login</button>
40
- </div>
41
- </div>
 
 
 
 
 
 
42
 
43
- <script>
44
- // Initialize Speech Recognition (for voice assistance)
45
- var recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
 
 
 
 
 
 
 
 
 
 
 
46
 
47
- // Start Voice Recognition when button is clicked
48
- function startVoiceRecognition() {
49
  recognition.start();
50
  recognition.onresult = function(event) {
51
- let transcript = event.results[0][0].transcript;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
- if (document.activeElement.id === "name") {
54
- document.getElementById("name").value = transcript;
55
- } else if (document.activeElement.id === "voice-email") {
56
- document.getElementById("voice-email").value = transcript;
57
- } else if (document.activeElement.id === "voice-phone") {
58
- document.getElementById("voice-phone").value = transcript;
59
- }
60
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
 
63
- // Login function (manual)
64
- function login() {
65
- let email = document.getElementById('login-email').value;
66
- let phone = document.getElementById('login-phone').value;
 
 
 
67
 
68
- fetch('/login', {
 
 
 
 
69
  method: 'POST',
70
  headers: { 'Content-Type': 'application/json' },
71
- body: JSON.stringify({ email: email, phone_number: phone })
72
  })
73
  .then(response => response.json())
74
  .then(data => {
75
  if (data.success) {
76
- localStorage.setItem('userName', data.user.Name);
77
- localStorage.setItem('userEmail', email);
78
- localStorage.setItem('userPhone', phone);
79
- window.location.href = "/dashboard";
80
  } else {
81
- alert('Invalid credentials! Please contact admin to register in Salesforce.');
 
82
  }
83
- })
84
- .catch(error => {
85
- alert('Error logging in!');
86
  });
87
  }
 
 
 
 
 
88
  </script>
89
  </body>
90
  </html>
 
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Biryani Hub 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
  </head>
 
 
 
 
11
 
12
+ <style>
13
+ body {
14
+ font-family: 'Roboto', sans-serif;
15
+ background: linear-gradient(135deg, #f4c542, #ff8f6a);
16
+ margin: 0;
17
+ display: flex;
18
+ justify-content: center;
19
+ align-items: center;
20
+ height: 100vh;
21
+ text-align: center;
22
+ }
23
+ .container {
24
+ background-color: #87ceeb; /* Light blue */
25
+ padding: 40px 50px;
26
+ border-radius: 10px;
27
+ width: 400px;
28
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
29
+ }
30
+ h1 {
31
+ font-size: 30px;
32
+ font-weight: bold;
33
+ color: #ff6a00;
34
+ }
35
+ label {
36
+ font-size: 16px;
37
+ margin-top: 20px;
38
+ display: block;
39
+ text-align: left;
40
+ font-weight: bold;
41
+ }
42
+ input[type="text"] {
43
+ width: 100%;
44
+ padding: 12px;
45
+ font-size: 16px;
46
+ border: 2px solid #ccc;
47
+ border-radius: 8px;
48
+ margin-top: 8px;
49
+ box-sizing: border-box;
50
+ }
51
+ input[type="text"]:focus {
52
+ border-color: #ff6a00;
53
+ outline: none;
54
+ }
55
+ .info {
56
+ margin-top: 20px;
57
+ font-size: 16px;
58
+ color: #ff6a00;
59
+ font-weight: bold;
60
+ }
61
+ .status {
62
+ font-size: 14px;
63
+ color: gray;
64
+ margin-top: 20px;
65
+ }
66
+ .image-logo {
67
+ width: 80px;
68
+ margin-bottom: 20px;
69
+ }
70
+ </style>
71
 
72
+ <body>
73
+ <div class="container">
74
+ <h1>Welcome to Biryani Hub 🍽 πŸ—</h1>
75
+
76
+ <label for="name">Your Name</label>
77
+ <input type="text" id="name" placeholder="Your name will appear here..." readonly>
78
+
79
+ <label for="email">Your Email</label>
80
+ <input type="text" id="email" placeholder="Your email will appear here..." readonly>
81
+
82
+ <label for="mobile">Your Mobile Number</label>
83
+ <input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
84
 
85
+ <p class="info" id="infoMessage">Listening πŸ—£πŸŽ™οΈ...</p>
86
+ <p class="status" id="status">πŸ”Š...</p>
87
+ </div>
88
+
89
+ <div id="confirmation" style="display: none;">
90
+ <h2>Confirm Your Details:</h2>
91
+ <p><strong>Name:</strong> <span id="confirmName"></span></p>
92
+ <p><strong>Email:</strong> <span id="confirmEmail"></span></p>
93
+ <p><strong>Phone:</strong> <span id="confirmPhone"></span></p>
94
+ </div>
95
 
96
+ <script>
97
+ let recognition;
98
+ let nameCaptured = "";
99
+ let emailCaptured = "";
100
+ let mobileCaptured = "";
101
 
102
+ if ('webkitSpeechRecognition' in window) {
103
+ recognition = new webkitSpeechRecognition();
104
+ recognition.continuous = false;
105
+ recognition.interimResults = false;
106
+ recognition.lang = 'en-US';
107
+ } else {
108
+ alert("Speech Recognition API is not supported in this browser.");
109
+ }
110
 
111
+ function speak(text, callback) {
112
+ const speech = new SpeechSynthesisUtterance(text);
113
+ speech.onend = callback;
114
+ window.speechSynthesis.speak(speech);
115
+ }
116
 
117
+ function startListeningForName() {
118
+ recognition.start();
119
+ recognition.onresult = function(event) {
120
+ nameCaptured = event.results[0][0].transcript.trim();
121
+ document.getElementById('name').value = nameCaptured;
122
+ recognition.stop();
123
+ setTimeout(confirmName, 500);
124
+ };
125
+ }
126
 
127
+ function confirmName() {
128
+ speak("You said " + nameCaptured + ". Is it okay, or do you want to change it?", function() {
129
+ recognition.start();
130
+ recognition.onresult = function(event) {
131
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
132
+ recognition.stop();
133
+ if (confirmation.includes("ok") || confirmation.includes("next")) {
134
+ setTimeout(() => speak("Great! Now, tell me your email.", startListeningForEmail), 500);
135
+ } else {
136
+ setTimeout(() => speak("Let's try again. Tell me your name.", startListeningForName), 500);
137
+ }
138
+ };
139
+ });
140
+ }
141
 
142
+ function startListeningForEmail() {
 
143
  recognition.start();
144
  recognition.onresult = function(event) {
145
+ emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
146
+ document.getElementById('email').value = emailCaptured;
147
+ recognition.stop();
148
+ speak("You said " + emailCaptured + ". Is it correct?", function() {
149
+ recognition.start();
150
+ recognition.onresult = function(event) {
151
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
152
+ recognition.stop();
153
+ if (confirmation.includes("ok") || confirmation.includes("next")) {
154
+ setTimeout(() => speak("Great! Now, tell me your mobile number.", startListeningForMobile), 500);
155
+ } else {
156
+ speak("Let's try again. Tell me your email.", startListeningForEmail);
157
+ }
158
+ };
159
+ });
160
+ };
161
+ }
162
 
163
+ function startListeningForMobile() {
164
+ recognition.start();
165
+ recognition.onresult = function(event) {
166
+ mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
167
+ document.getElementById('mobile').value = mobileCaptured;
168
+ recognition.stop();
169
+ speak("You said " + mobileCaptured + ". Is it correct?", function() {
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") || confirmation.includes("next")) {
175
+ speak("All details are captured. Confirming your registration.", function() {
176
+ autoConfirm();
177
+ });
178
+ } else {
179
+ speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
180
+ }
181
+ };
182
+ });
183
+ };
184
  }
185
 
186
+ function autoConfirm() {
187
+ document.getElementById('confirmName').textContent = document.getElementById('name').value;
188
+ document.getElementById('confirmEmail').textContent = document.getElementById('email').value;
189
+ document.getElementById('confirmPhone').textContent = document.getElementById('mobile').value;
190
+ document.getElementById('confirmation').style.display = 'block';
191
+ setTimeout(autoSubmit, 3000);
192
+ }
193
 
194
+ function autoSubmit() {
195
+ var name = document.getElementById('name').value;
196
+ var email = document.getElementById('email').value;
197
+ var phone = document.getElementById('mobile').value;
198
+ fetch('/submit', {
199
  method: 'POST',
200
  headers: { 'Content-Type': 'application/json' },
201
+ body: JSON.stringify({ name: name, email: email, phone: phone })
202
  })
203
  .then(response => response.json())
204
  .then(data => {
205
  if (data.success) {
206
+ document.getElementById('status').textContent = 'Your details were submitted successfully!';
207
+ document.getElementById('confirmation').style.display = 'none';
208
+ speak("Your registration is complete. Thank you for registering.");
209
+ setTimeout(() => location.reload(), 5000);
210
  } else {
211
+ document.getElementById('status').textContent = 'There was an error submitting your details.';
212
+ speak("There was an error submitting your details. Please try again.");
213
  }
 
 
 
214
  });
215
  }
216
+
217
+ window.onload = function () {
218
+ speak("Welcome to Biryani Hub. Please tell me your name to start the registration.");
219
+ setTimeout(startListeningForName, 5000);
220
+ };
221
  </script>
222
  </body>
223
  </html>