lokesh341 commited on
Commit
14f0913
·
verified ·
1 Parent(s): c326a0e

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +115 -198
templates/menu_page.html CHANGED
@@ -5,149 +5,132 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Biryani Hub Menu</title>
7
  <style>
8
- body {
9
- font-family: Arial, sans-serif;
10
- background-color: #f8f8f8;
11
- margin: 0;
12
- padding: 0;
13
- }
14
- .menu-container {
15
- max-width: 1200px;
16
- margin: 0 auto;
17
- padding: 20px;
18
- background-color: #4169E1;
19
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
20
- border-radius: 8px;
21
- margin-top: 50px;
22
- }
23
- h1 {
24
- text-align: center;
25
- font-size: 2.5rem;
26
- color: #87CEFA;
27
- margin-bottom: 30px;
28
- }
29
- .menu-item {
30
- border-bottom: 1px solid #eee;
31
- padding: 15px 0;
32
- display: flex;
33
- justify-content: space-between;
34
- align-items: center;
35
- }
36
- .order-btn {
37
- padding: 10px 20px;
38
- background-color: #4CAF50; /* Default green color */
39
- color: white;
40
- border: none;
41
- border-radius: 5px;
42
- cursor: pointer;
43
- }
44
- .order-btn:hover {
45
- background-color: #45a049;
46
- }
47
-
48
- /* New styles for the category buttons */
49
- #main-course-btn, #appetizer-btn {
50
- padding: 10px 20px;
51
- background-color: orange; /* Change button color to orange */
52
- color: white;
53
- border: none;
54
- border-radius: 5px;
55
- cursor: pointer;
56
- font-size: 2.2rem;
57
- margin: 10px 0;
58
- }
59
-
60
- #main-course-btn:hover, #appetizer-btn:hover {
61
- background-color: #FF7F00; /* Darker orange for hover effect */
62
- }
63
-
64
- #cart-summary {
65
- display: none;
66
- }
67
- </style>
68
 
69
- <div class="menu-container">
 
70
  <h1>Welcome to Biryani Hub menu</h1>
71
  <h3 id="category-title">Please select a category:</h3>
 
 
 
72
 
73
- <!-- Buttons for selecting categories -->
74
- <div id="category-buttons">
75
- <button id="main-course-btn">Main Course</button>
76
- <button id="appetizer-btn">Appetizers</button>
77
- </div>
78
-
79
- <!-- Dynamic Menu Item List -->
80
- <div id="menu-items"></div>
81
 
82
- <div id="cart-summary" style="display:none;">
83
- <h2>Your Cart:</h2>
84
- <div id="cart-details"></div>
85
- <button id="place-order-btn">Place Final Order</button>
86
- </div>
87
  </div>
88
 
89
  <script>
90
- const cartSummary = document.getElementById("cart-summary");
91
- const cartDetails = document.getElementById("cart-details");
92
- const categoryButtons = document.getElementById("category-buttons");
93
- let cart = []; // Global cart variable to store items
94
- let menuData = {}; // Will store menu items based on categories
95
-
96
- const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
97
- recognition.lang = "en-US";
98
- recognition.interimResults = false;
99
-
100
- // Function to speak text
101
- function speak(text) {
102
- const msg = new SpeechSynthesisUtterance(text);
103
- window.speechSynthesis.speak(msg);
104
- }
105
-
106
- // Start voice recognition automatically on page load
107
- window.onload = function() {
108
- // Sample menu data for Main Course and Appetizers
109
- menuData = {
110
- 'Main Course': [
111
- { name: "Chicken Biryani", price: 250 },
112
- { name: "Veg Biryani", price: 200 },
113
- { name: "Mutton Biryani", price: 300 }
114
- ],
115
- 'Appetizers': [
116
- { name: "Paneer Tikka", price: 180 },
117
- { name: "Chicken Wings", price: 220 }
118
- ]
119
- };
120
 
121
- // Populate categories dynamically
122
- document.getElementById("main-course-btn").addEventListener("click", () => {
123
- displayMenuItems('Main Course');
124
- });
125
- document.getElementById("appetizer-btn").addEventListener("click", () => {
126
- displayMenuItems('Appetizers');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  });
 
128
 
129
- // Voice greeting for menu categories
130
- speak("Welcome to Biryani Hub! We have the following categories: Main Course and Appetizers. Please say 'Main Course' or 'Appetizers' to select a category.");
131
-
132
- // Automatically trigger voice recognition for category selection
133
- recognition.start();
134
- recognition.onresult = (event) => {
135
- const categoryCommand = event.results[0][0].transcript.toLowerCase();
136
- if (categoryCommand.includes("main course")) {
137
- displayMenuItems('Main Course');
138
- } else if (categoryCommand.includes("appetizers")) {
139
- displayMenuItems('Appetizers');
140
- } else {
141
- speak("Sorry, I couldn't understand that. Please say 'Main Course' or 'Appetizers'.");
142
- }
143
- };
144
- };
145
-
146
- // Function to populate the menu based on selected category
147
  function displayMenuItems(category) {
148
- const menuContainer = document.getElementById('menu-items');
149
- menuContainer.innerHTML = ''; // Clear previous menu
150
-
151
  if (menuData[category]) {
152
  menuData[category].forEach(item => {
153
  const itemElement = document.createElement('div');
@@ -157,78 +140,12 @@
157
  <h3>${item.name}</h3>
158
  <p class="price">Price: ₹${item.price}</p>
159
  </div>
160
- <button class="order-btn" onclick="addToCart('${item.name}', 1)">Order</button>
161
  `;
162
  menuContainer.appendChild(itemElement);
163
  });
164
-
165
- // Automatically prompt the user to order
166
- speak("Here are the items in the selected category. Please say the item you want to order.");
167
- recognition.start();
168
- recognition.onresult = (event) => {
169
- const itemName = event.results[0][0].transcript.toLowerCase();
170
- const item = findItem(itemName);
171
- if (item) {
172
- speak(`You selected ${item.name}. How many would you like?`);
173
- recognition.start();
174
- recognition.onresult = (event) => {
175
- const quantity = parseInt(event.results[0][0].transcript);
176
- if (quantity) {
177
- addToCart(item.name, quantity);
178
- speak(`${quantity} ${item.name} added to your cart.`);
179
- askMoreItems();
180
- } else {
181
- speak("Please say a valid quantity.");
182
- }
183
- };
184
- } else {
185
- speak("Sorry, I couldn't find that item. Please try again.");
186
- }
187
- };
188
- }
189
- }
190
-
191
- // Function to add an item to the cart
192
- function addToCart(itemName, quantity) {
193
- const item = findItem(itemName);
194
- cart.push({ name: item.name, price: item.price, quantity: quantity });
195
- }
196
-
197
- // Function to show cart details
198
- function showCartDetails() {
199
- if (cart.length > 0) {
200
- let cartHtml = "";
201
- cart.forEach(item => {
202
- cartHtml += `<p>${item.quantity} x ${item.name} - ₹${item.price * item.quantity}</p>`;
203
- });
204
- cartDetails.innerHTML = cartHtml;
205
- cartSummary.style.display = "block";
206
- speak(`Your cart contains ${cart.length} items.`);
207
- } else {
208
- speak("Your cart is empty.");
209
  }
210
  }
211
-
212
- // Function to ask if the user wants to order more items
213
- function askMoreItems() {
214
- speak("Would you like to order more items?");
215
- recognition.start();
216
- recognition.onresult = (event) => {
217
- const response = event.results[0][0].transcript.toLowerCase();
218
- if (response.includes("yes")) {
219
- recognition.start();
220
- } else {
221
- showCartDetails();
222
- }
223
- };
224
- }
225
-
226
- // Function to find item in the menu
227
- function findItem(itemName) {
228
- const menu = menuData['Main Course']; // Default category to check first
229
- return menu.find(item => item.name.toLowerCase() === itemName.toLowerCase());
230
- }
231
  </script>
232
-
233
  </body>
234
  </html>
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Biryani Hub Menu</title>
7
  <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ background-color: #f8f8f8;
11
+ margin: 0;
12
+ padding: 0;
13
+ }
14
+ .menu-container {
15
+ max-width: 1200px;
16
+ margin: 0 auto;
17
+ padding: 20px;
18
+ background-color: #4169E1;
19
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
20
+ border-radius: 8px;
21
+ margin-top: 50px;
22
+ }
23
+ h1 {
24
+ text-align: center;
25
+ font-size: 2.5rem;
26
+ color: #87CEFA;
27
+ margin-bottom: 30px;
28
+ }
29
+ .menu-item {
30
+ border-bottom: 1px solid #eee;
31
+ padding: 15px 0;
32
+ display: flex;
33
+ justify-content: space-between;
34
+ align-items: center;
35
+ }
36
+ .order-btn {
37
+ padding: 10px 20px;
38
+ background-color: #4CAF50;
39
+ color: white;
40
+ border: none;
41
+ border-radius: 5px;
42
+ cursor: pointer;
43
+ }
44
+ .order-btn:hover {
45
+ background-color: #45a049;
46
+ }
47
+ #main-course-btn, #appetizer-btn {
48
+ padding: 10px 20px;
49
+ background-color: orange;
50
+ color: white;
51
+ border: none;
52
+ border-radius: 5px;
53
+ cursor: pointer;
54
+ font-size: 2.2rem;
55
+ margin: 10px 0;
56
+ }
57
+ #main-course-btn:hover, #appetizer-btn:hover {
58
+ background-color: #FF7F00;
59
+ }
60
+ #cart-summary {
61
+ display: none;
62
+ }
63
+ </style>
64
+ </head>
65
+ <body>
 
 
66
 
67
+ <!-- Page 1: Welcome and Category Selection -->
68
+ <div id="page1" class="menu-container">
69
  <h1>Welcome to Biryani Hub menu</h1>
70
  <h3 id="category-title">Please select a category:</h3>
71
+ <button id="main-course-btn">Main Course</button>
72
+ <button id="appetizer-btn">Appetizers</button>
73
+ </div>
74
 
75
+ <!-- Page 2: Main Course Menu -->
76
+ <div id="main-course-page" class="menu-container" style="display: none;">
77
+ <h1>Main Course Menu</h1>
78
+ <div id="main-course-items"></div>
79
+ <button id="back-to-category-btn">Back to Category Selection</button>
80
+ </div>
 
 
81
 
82
+ <!-- Page 3: Appetizers Menu -->
83
+ <div id="appetizer-page" class="menu-container" style="display: none;">
84
+ <h1>Appetizers Menu</h1>
85
+ <div id="appetizer-items"></div>
86
+ <button id="back-to-category-btn2">Back to Category Selection</button>
87
  </div>
88
 
89
  <script>
90
+ // Sample menu data
91
+ const menuData = {
92
+ 'Main Course': [
93
+ { name: "Chicken Biryani", price: 250 },
94
+ { name: "Veg Biryani", price: 200 },
95
+ { name: "Mutton Biryani", price: 300 }
96
+ ],
97
+ 'Appetizers': [
98
+ { name: "Paneer Tikka", price: 180 },
99
+ { name: "Chicken Wings", price: 220 }
100
+ ]
101
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
+ // Selectors for pages and buttons
104
+ const categoryButtons = document.getElementById('page1');
105
+ const mainCoursePage = document.getElementById('main-course-page');
106
+ const appetizerPage = document.getElementById('appetizer-page');
107
+ const backToCategoryBtns = document.querySelectorAll('[id^="back-to-category-btn"]');
108
+
109
+ // Event listeners for buttons to navigate between pages
110
+ document.getElementById("main-course-btn").addEventListener("click", () => {
111
+ categoryButtons.style.display = "none";
112
+ mainCoursePage.style.display = "block";
113
+ displayMenuItems('Main Course');
114
+ });
115
+
116
+ document.getElementById("appetizer-btn").addEventListener("click", () => {
117
+ categoryButtons.style.display = "none";
118
+ appetizerPage.style.display = "block";
119
+ displayMenuItems('Appetizers');
120
+ });
121
+
122
+ backToCategoryBtns.forEach(button => {
123
+ button.addEventListener("click", () => {
124
+ mainCoursePage.style.display = "none";
125
+ appetizerPage.style.display = "none";
126
+ categoryButtons.style.display = "block";
127
  });
128
+ });
129
 
130
+ // Function to populate menu items based on category
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  function displayMenuItems(category) {
132
+ const menuContainer = category === 'Main Course' ? document.getElementById('main-course-items') : document.getElementById('appetizer-items');
133
+ menuContainer.innerHTML = '';
 
134
  if (menuData[category]) {
135
  menuData[category].forEach(item => {
136
  const itemElement = document.createElement('div');
 
140
  <h3>${item.name}</h3>
141
  <p class="price">Price: ₹${item.price}</p>
142
  </div>
143
+ <button class="order-btn">Order</button>
144
  `;
145
  menuContainer.appendChild(itemElement);
146
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  }
148
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  </script>
 
150
  </body>
151
  </html>