lokesh341 commited on
Commit
316469c
·
verified ·
1 Parent(s): 5e824a1

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +146 -153
templates/menu_page.html CHANGED
@@ -35,7 +35,7 @@
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;
@@ -44,10 +44,9 @@
44
  .order-btn:hover {
45
  background-color: #45a049;
46
  }
47
- /* New styles for the category buttons */
48
  #main-course-btn, #appetizer-btn {
49
  padding: 10px 20px;
50
- background-color: orange; /* Change button color to orange */
51
  color: white;
52
  border: none;
53
  border-radius: 5px;
@@ -56,161 +55,155 @@
56
  margin: 10px 0;
57
  }
58
  #main-course-btn:hover, #appetizer-btn:hover {
59
- background-color: #FF7F00; /* Darker orange for hover effect */
60
  }
61
  #cart-summary {
62
  display: none;
63
  }
64
  </style>
 
 
65
 
66
- <div class="menu-container">
67
- <h1>Welcome to Biryani Hub menu</h1>
68
- <h3 id="category-title">Please select a category:</h3>
69
-
70
- <!-- Buttons for selecting categories -->
71
- <div id="category-buttons">
72
- <button id="main-course-btn">Main Course</button>
73
- <button id="appetizer-btn">Appetizers</button>
74
- </div>
75
-
76
- <!-- Dynamic Menu Item List -->
77
- <div id="menu-items"></div>
78
-
79
- <div id="cart-summary" style="display:none;">
80
- <h2>Your Cart:</h2>
81
- <div id="cart-details"></div>
82
- <button id="place-order-btn">Place Final Order</button>
83
- </div>
84
- </div>
85
-
86
- <script>
87
- const cartSummary = document.getElementById("cart-summary");
88
- const cartDetails = document.getElementById("cart-details");
89
- const categoryButtons = document.getElementById("category-buttons");
90
- let cart = []; // Global cart variable to store items
91
- let menuData = {}; // Will store menu items based on categories
92
- const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
93
- recognition.lang = "en-US";
94
- recognition.interimResults = false;
95
- // Function to speak text
96
- function speak(text) {
97
- const msg = new SpeechSynthesisUtterance(text);
98
- window.speechSynthesis.speak(msg);
99
- }
100
- // Start voice recognition automatically on page load
101
- window.onload = function() {
102
- // Sample menu data for Main Course and Appetizers
103
- menuData = {
104
- 'Main Course': [
105
- { name: "Chicken Biryani", price: 250 },
106
- { name: "Veg Biryani", price: 200 },
107
- { name: "Mutton Biryani", price: 300 }
108
- ],
109
- 'Appetizers': [
110
- { name: "Paneer Tikka", price: 180 },
111
- { name: "Chicken Wings", price: 220 }
112
- ]
113
- };
114
- // Populate categories dynamically
115
- document.getElementById("main-course-btn").addEventListener("click", () => {
116
- displayMenuItems('Main Course');
117
- });
118
- document.getElementById("appetizer-btn").addEventListener("click", () => {
119
- displayMenuItems('Appetizers');
120
- });
121
- // Voice greeting for menu categories
122
- speak("Welcome to Biryani Hub! We have the following categories: Main Course and Appetizers. Please say 'Main Course' or 'Appetizers' to select a category.");
123
- // Automatically trigger voice recognition for category selection
124
- recognition.start();
125
- recognition.onresult = (event) => {
126
- const categoryCommand = event.results[0][0].transcript.toLowerCase();
127
- if (categoryCommand.includes("main course")) {
128
- displayMenuItems('Main Course');
129
- } else if (categoryCommand.includes("appetizers")) {
130
- displayMenuItems('Appetizers');
131
- } else {
132
- speak("Sorry, I couldn't understand that. Please say 'Main Course' or 'Appetizers'.");
133
- }
134
- };
135
- };
136
- // Function to populate the menu based on selected category
137
- function displayMenuItems(category) {
138
- const menuContainer = document.getElementById('menu-items');
139
- menuContainer.innerHTML = ''; // Clear previous menu
140
- if (menuData[category]) {
141
- menuData[category].forEach(item => {
142
- const itemElement = document.createElement('div');
143
- itemElement.classList.add('menu-item');
144
- itemElement.innerHTML =
145
- <div class="details">
146
- <h3>${item.name}</h3>
147
- <p class="price">Price: ₹${item.price}</p>
148
- </div>
149
- <button class="order-btn" onclick="addToCart('${item.name}', 1)">Order</button>
150
- ;
151
- menuContainer.appendChild(itemElement);
152
- });
153
- // Automatically prompt the user to order
154
- speak("Here are the items in the selected category. Please say the item you want to order.");
155
- recognition.start();
156
- recognition.onresult = (event) => {
157
- const itemName = event.results[0][0].transcript.toLowerCase();
158
- const item = findItem(itemName);
159
- if (item) {
160
- speak(You selected ${item.name}. How many would you like?);
161
- recognition.start();
162
- recognition.onresult = (event) => {
163
- const quantity = parseInt(event.results[0][0].transcript);
164
- if (quantity) {
165
- addToCart(item.name, quantity);
166
- speak(${quantity} ${item.name} added to your cart.);
167
- askMoreItems();
168
- } else {
169
- speak("Please say a valid quantity.");
170
- }
171
- };
172
- } else {
173
- speak("Sorry, I couldn't find that item. Please try again.");
174
- }
175
- };
176
- }
177
- }
178
- // Function to add an item to the cart
179
- function addToCart(itemName, quantity) {
180
- const item = findItem(itemName);
181
- cart.push({ name: item.name, price: item.price, quantity: quantity });
182
- }
183
- // Function to show cart details
184
- function showCartDetails() {
185
- if (cart.length > 0) {
186
- let cartHtml = "";
187
- cart.forEach(item => {
188
- cartHtml += <p>${item.quantity} x ${item.name} - ₹${item.price * item.quantity}</p>;
189
- });
190
- cartDetails.innerHTML = cartHtml;
191
- cartSummary.style.display = "block";
192
- speak(Your cart contains ${cart.length} items.);
193
- } else {
194
- speak("Your cart is empty.");
195
- }
196
- }
197
- // Function to ask if the user wants to order more items
198
- function askMoreItems() {
199
- speak("Would you like to order more items?");
200
- recognition.start();
201
- recognition.onresult = (event) => {
202
- const response = event.results[0][0].transcript.toLowerCase();
203
- if (response.includes("yes")) {
204
- recognition.start();
205
- } else {
206
- showCartDetails();
207
- }
208
- };
209
- }
210
- // Function to find item in the menu
211
- function findItem(itemName) {
212
- const menu = menuData['Main Course']; // Default category to check first
213
- return menu.find(item => item.name.toLowerCase() === itemName.toLowerCase());
214
  }
215
- </script>
 
 
216
 
 
 
 
35
  }
36
  .order-btn {
37
  padding: 10px 20px;
38
+ background-color: #4CAF50;
39
  color: white;
40
  border: none;
41
  border-radius: 5px;
 
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;
 
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');
137
+ itemElement.classList.add('menu-item');
138
+ itemElement.innerHTML = `
139
+ <div class="details">
140
+ <h3>${item.name}</h3>
141
+ <p class="price">Price: ₹${item.price}</p>
142
+ </div>
143
+ <button class="order-btn" onclick="addToCart('${item.name}', 1)">Order</button>
144
+ `;
145
+ menuContainer.appendChild(itemElement);
146
+ });
147
+ }
148
+ }
149
+
150
+ // Function to add an item to the cart
151
+ let cart = [];
152
+ function addToCart(itemName, quantity) {
153
+ const item = findItem(itemName);
154
+ cart.push({ name: item.name, price: item.price, quantity: quantity });
155
+ }
156
+
157
+ // Function to find item in the menu
158
+ function findItem(itemName) {
159
+ const menu = menuData['Main Course']; // Default category to check first
160
+ return menu.find(item => item.name.toLowerCase() === itemName.toLowerCase());
161
+ }
162
+
163
+ // Voice greeting for menu categories
164
+ const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
165
+ recognition.lang = "en-US";
166
+ recognition.interimResults = false;
167
+ function speak(text) {
168
+ const msg = new SpeechSynthesisUtterance(text);
169
+ window.speechSynthesis.speak(msg);
170
+ }
171
+
172
+ window.onload = function() {
173
+ // Sample menu data for Main Course and Appetizers
174
+ menuData = {
175
+ 'Main Course': [
176
+ { name: "Chicken Biryani", price: 250 },
177
+ { name: "Veg Biryani", price: 200 },
178
+ { name: "Mutton Biryani", price: 300 }
179
+ ],
180
+ 'Appetizers': [
181
+ { name: "Paneer Tikka", price: 180 },
182
+ { name: "Chicken Wings", price: 220 }
183
+ ]
184
+ };
185
+
186
+ // Automatically greet the user and prompt for category selection
187
+ speak("Welcome to Biryani Hub! We have the following categories: Main Course and Appetizers. Please say 'Main Course' or 'Appetizers' to select a category.");
188
+
189
+ // Automatically trigger voice recognition for category selection
190
+ recognition.start();
191
+ recognition.onresult = (event) => {
192
+ const categoryCommand = event.results[0][0].transcript.toLowerCase();
193
+ if (categoryCommand.includes("main course")) {
194
+ displayMenuItems('Main Course');
195
+ mainCoursePage.style.display = "block";
196
+ categoryButtons.style.display = "none";
197
+ } else if (categoryCommand.includes("appetizers")) {
198
+ displayMenuItems('Appetizers');
199
+ appetizerPage.style.display = "block";
200
+ categoryButtons.style.display = "none";
201
+ } else {
202
+ speak("Sorry, I couldn't understand that. Please say 'Main Course' or 'Appetizers'.");
 
 
 
 
 
 
 
 
 
 
 
 
203
  }
204
+ };
205
+ };
206
+ </script>
207
 
208
+ </body>
209
+ </html>