DSatishchandra commited on
Commit
6dc558a
·
verified ·
1 Parent(s): 6bf4495

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +158 -50
templates/index.html CHANGED
@@ -3,69 +3,177 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Biryani Hub Login</title>
7
- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
 
8
  </head>
 
9
  <body>
10
- <h1>Welcome to Biryani Hub!</h1>
11
- <p>Please provide your details:</p>
 
 
 
 
 
 
 
 
 
 
12
 
13
- <!-- User Input Form -->
14
- <form id="userDetailsForm">
15
- <label for="name">Name:</label>
16
- <input type="text" id="name" name="name" required><br><br>
17
 
18
- <label for="email">Email:</label>
19
- <input type="email" id="email" name="email" required><br><br>
 
 
 
 
 
 
 
 
 
20
 
21
- <label for="phone">Phone Number:</label>
22
- <input type="text" id="phone" name="phone" required><br><br>
 
 
 
23
 
24
- <button type="submit">Submit</button>
25
- </form>
 
 
 
 
 
 
26
 
27
- <div id="responseMessage"></div>
 
 
 
 
28
 
29
- <script>
30
- $(document).ready(function() {
31
- // Handle form submission
32
- $('#userDetailsForm').on('submit', function(event) {
33
- event.preventDefault();
34
-
35
- // Get form values
36
- var name = $('#name').val();
37
- var email = $('#email').val();
38
- var phone = $('#phone').val();
39
-
40
- // Validate the input
41
- if (!name || !email || !phone) {
42
- $('#responseMessage').text("All fields are required.");
43
- return;
44
- }
45
 
46
- // Create an object with the data
47
- var formData = {
48
- name: name,
49
- email: email,
50
- phone: phone
 
 
 
 
 
 
51
  };
 
 
52
 
53
- // Send the data to the backend via POST request
54
- $.ajax({
55
- url: '/submit', // Backend route to handle data
56
- type: 'POST',
57
- contentType: 'application/json',
58
- data: JSON.stringify(formData),
59
- success: function(response) {
60
- // Handle the success response
61
- $('#responseMessage').text("User registered successfully!");
62
- },
63
- error: function(xhr, status, error) {
64
- // Handle the error response
65
- $('#responseMessage').text("Error: " + xhr.responseJSON.error);
66
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  });
68
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  });
70
  </script>
71
  </body>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Biryani Hub Registration</title>
7
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
8
+ <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
9
  </head>
10
+
11
  <body>
12
+ <div class="container">
13
+ <img src="https://yourimageurl.com/logo.png" alt="Logo" class="image-logo">
14
+ <h1>Welcome to Biryani Hub 🍽 🍗</h1>
15
+
16
+ <label for="name">Your Name</label>
17
+ <input type="text" id="name" placeholder="Your name will appear here..." readonly>
18
+
19
+ <label for="email">Your Email</label>
20
+ <input type="text" id="email" placeholder="Your email will appear here..." readonly>
21
+
22
+ <label for="mobile">Your Mobile Number</label>
23
+ <input type="text" id="mobile" placeholder="Your mobile number will appear here..." readonly>
24
 
25
+ <button type="button" id="confirmBtn">Confirm</button>
 
 
 
26
 
27
+ <p class="info" id="infoMessage">Listening 🗣🎙️...</p>
28
+ <p class="status" id="status">🔊...</p>
29
+ </div>
30
+
31
+ <div id="confirmation" style="display: none;">
32
+ <h2>Confirm Your Details:</h2>
33
+ <p><strong>Name:</strong> <span id="confirmName"></span></p>
34
+ <p><strong>Email:</strong> <span id="confirmEmail"></span></p>
35
+ <p><strong>Phone:</strong> <span id="confirmPhone"></span></p>
36
+ <button type="button" id="submitBtn">Submit</button>
37
+ </div>
38
 
39
+ <script>
40
+ let recognition;
41
+ let nameCaptured = "";
42
+ let emailCaptured = "";
43
+ let mobileCaptured = "";
44
 
45
+ if ('webkitSpeechRecognition' in window) {
46
+ recognition = new webkitSpeechRecognition();
47
+ recognition.continuous = false;
48
+ recognition.interimResults = false;
49
+ recognition.lang = 'en-US';
50
+ } else {
51
+ alert("Speech Recognition API is not supported in this browser.");
52
+ }
53
 
54
+ function speak(text, callback) {
55
+ const speech = new SpeechSynthesisUtterance(text);
56
+ speech.onend = callback;
57
+ window.speechSynthesis.speak(speech);
58
+ }
59
 
60
+ function startListeningForName() {
61
+ recognition.start();
62
+ recognition.onresult = function(event) {
63
+ nameCaptured = event.results[0][0].transcript.trim();
64
+ document.getElementById('name').value = nameCaptured;
65
+ recognition.stop();
66
+ setTimeout(confirmName, 500);
67
+ };
68
+ }
 
 
 
 
 
 
 
69
 
70
+ function confirmName() {
71
+ speak("You said " + nameCaptured + ". Is it okay, or do you want to change it?", function() {
72
+ recognition.start();
73
+ recognition.onresult = function(event) {
74
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
75
+ recognition.stop();
76
+ if (confirmation.includes("ok") || confirmation.includes("yes")) {
77
+ setTimeout(() => speak("Great! Now, tell me your email.", startListeningForEmail), 500);
78
+ } else {
79
+ setTimeout(() => speak("Let's try again. Tell me your name.", startListeningForName), 500);
80
+ }
81
  };
82
+ });
83
+ }
84
 
85
+ function startListeningForEmail() {
86
+ recognition.start();
87
+ recognition.onresult = function(event) {
88
+ emailCaptured = event.results[0][0].transcript.trim().replace(/\bat\b/g, '@').replace(/\s+/g, '');
89
+ document.getElementById('email').value = emailCaptured;
90
+ recognition.stop();
91
+ speak("You said " + emailCaptured + ". Is it correct?", function() {
92
+ recognition.start();
93
+ recognition.onresult = function(event) {
94
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
95
+ recognition.stop();
96
+ if (confirmation.includes("ok") || confirmation.includes("yes")) {
97
+ setTimeout(() => speak("Great! Now, tell me your mobile number.", startListeningForMobile), 500);
98
+ } else {
99
+ speak("Let's try again. Tell me your email.", startListeningForEmail);
100
+ }
101
+ };
102
+ });
103
+ };
104
+ }
105
+
106
+ function startListeningForMobile() {
107
+ recognition.start();
108
+ recognition.onresult = function(event) {
109
+ mobileCaptured = event.results[0][0].transcript.trim().replace(/\s+/g, '');
110
+ document.getElementById('mobile').value = mobileCaptured;
111
+ recognition.stop();
112
+ speak("You said " + mobileCaptured + ". Is it correct?", function() {
113
+ recognition.start();
114
+ recognition.onresult = function(event) {
115
+ let confirmation = event.results[0][0].transcript.trim().toLowerCase();
116
+ recognition.stop();
117
+ if (confirmation.includes("ok") || confirmation.includes("yes")) {
118
+ speak("Your registration is complete. Thank you for registering.");
119
+ setTimeout(() => location.reload(), 20000);
120
+ } else {
121
+ speak("Let's try again. Tell me your mobile number.", startListeningForMobile);
122
+ }
123
+ };
124
+ });
125
+ };
126
+ }
127
+
128
+ function startProcess() {
129
+ speak("Welcome to Biryani Hub", function() {
130
+ speak("Tell me your name, and I will confirm it with you.", function() {
131
+ setTimeout(startListeningForName, 500);
132
  });
133
  });
134
+ }
135
+
136
+ window.onload = function () {
137
+ setTimeout(startProcess, 4000);
138
+ };
139
+
140
+ document.getElementById('confirmBtn').addEventListener('click', function() {
141
+ var name = document.getElementById('name').value;
142
+ var email = document.getElementById('email').value;
143
+ var phone = document.getElementById('mobile').value;
144
+
145
+ // Show confirmation details
146
+ document.getElementById('confirmName').textContent = name;
147
+ document.getElementById('confirmEmail').textContent = email;
148
+ document.getElementById('confirmPhone').textContent = phone;
149
+
150
+ // Hide the form and show confirmation
151
+ document.getElementById('confirmation').style.display = 'block';
152
+ document.getElementById('confirmBtn').style.display = 'none';
153
+ });
154
+
155
+ document.getElementById('submitBtn').addEventListener('click', function() {
156
+ var name = document.getElementById('name').value;
157
+ var email = document.getElementById('email').value;
158
+ var phone = document.getElementById('mobile').value;
159
+
160
+ fetch('/submit', {
161
+ method: 'POST',
162
+ headers: {
163
+ 'Content-Type': 'application/json'
164
+ },
165
+ body: JSON.stringify({ name: name, email: email, phone: phone })
166
+ })
167
+ .then(response => response.json())
168
+ .then(data => {
169
+ if (data.success) {
170
+ document.getElementById('status').textContent = 'Your details were submitted successfully!';
171
+ document.getElementById('confirmation').style.display = 'none';
172
+ } else {
173
+ document.getElementById('status').textContent = 'There was an error submitting your details.';
174
+ }
175
+ document.getElementById('status').style.display = 'block';
176
+ });
177
  });
178
  </script>
179
  </body>