lokesh341 commited on
Commit
d9059f7
·
verified ·
1 Parent(s): f8ccf24

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +70 -66
templates/menu_page.html CHANGED
@@ -20,7 +20,7 @@
20
  </head>
21
  <body>
22
  <div class="menu-container">
23
- <h1>Welcome to the Menu</h1>
24
  <div id="menu-items"></div>
25
  <button onclick="viewCart()">View Cart</button>
26
  </div>
@@ -31,37 +31,64 @@
31
  </div>
32
 
33
  <script>
34
- const menuItems = [
35
- { name: 'Samosa', price: 9, ingredients: 'Potatoes, Peas, Flour, Spices', description: 'Crispy fried pastry filled with spiced potatoes and peas.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
36
- { name: 'Onion Pakoda', price: 10, ingredients: 'Onions, Gram Flour, Spices', description: 'Deep-fried onion fritters seasoned with herbs and spices.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
37
- { name: 'Chilli Gobi', price: 12, ingredients: 'Cauliflower, Chili Sauce, Spices', description: 'Cauliflower florets tossed in a spicy chili sauce.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
38
- { name: 'Paneer Butter Masala', price: 13, ingredients: 'Paneer, Tomato, Butter, Spices', description: 'Soft paneer cubes in a creamy, flavorful gravy.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
39
- { name: 'Aloo Gobi', price: 10, ingredients: 'Potatoes, Cauliflower, Spices', description: 'A traditional Indian curry with potatoes and cauliflower.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
40
- { name: 'Vegetable Biryani', price: 15, ingredients: 'Basmati Rice, Mixed Vegetables, Spices', description: 'Aromatic rice cooked with seasonal vegetables and spices.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
41
- { name: 'Palak Paneer', price: 14, ingredients: 'Spinach, Paneer, Spices', description: 'Spinach and cottage cheese cooked with mild spices.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
42
- { name: 'Dal Tadka', price: 8, ingredients: 'Yellow Lentils, Garlic, Ginger, Spices', description: 'Lentils cooked with spices and topped with tempering.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
43
- { name: 'Veg Manchurian', price: 11, ingredients: 'Vegetables, Soy Sauce, Spices', description: 'Crispy vegetable balls served in a spicy Chinese sauce.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
 
 
44
 
45
- // Non-Vegetarian Items
46
- { name: 'Chicken Biryani', price: 14, ingredients: 'Chicken, Basmati Rice, Spices', description: 'Aromatic basmati rice cooked with tender chicken and spices.', imageUrl: 'https://via.placeholder.com/100', category: 'non-veg' },
47
- { name: 'Mutton Biryani', price: 16, ingredients: 'Mutton, Basmati Rice, Spices', description: 'Flavorful rice dish made with succulent mutton and aromatic spices.', imageUrl: 'https://via.placeholder.com/100', category: 'non-veg' },
48
- { name: 'Fish Curry', price: 18, ingredients: 'Fish, Spices, Coconut Milk', description: 'Delicious fish curry made with fresh fish and coconut milk.', imageUrl: 'https://via.placeholder.com/100', category: 'non-veg' },
49
- { name: 'Butter Chicken', price: 15, ingredients: 'Chicken, Tomato, Butter, Cream', description: 'Tender chicken cooked in a rich, creamy tomato sauce.', imageUrl: 'https://via.placeholder.com/100', category: 'non-veg' },
50
- { name: 'Chicken Tikka', price: 12, ingredients: 'Chicken, Yogurt, Spices', description: 'Grilled chicken marinated in yogurt and spices.', imageUrl: 'https://via.placeholder.com/100', category: 'non-veg' },
51
- { name: 'Lamb Korma', price: 17, ingredients: 'Lamb, Cream, Spices', description: 'Lamb cooked in a rich, creamy gravy with a blend of aromatic spices.', imageUrl: 'https://via.placeholder.com/100', category: 'non-veg' },
52
- { name: 'Prawn Masala', price: 20, ingredients: 'Prawns, Spices, Tomatoes', description: 'Juicy prawns cooked in a flavorful, spicy masala.', imageUrl: 'https://via.placeholder.com/100', category: 'non-veg' },
53
- { name: 'Chicken Shawarma', price: 13, ingredients: 'Chicken, Garlic, Spices', description: 'Grilled chicken served in a flatbread with garlic sauce.', imageUrl: 'https://via.placeholder.com/100', category: 'non-veg' },
54
- { name: 'Egg Curry', price: 9, ingredients: 'Eggs, Spices, Tomatoes', description: 'Hard-boiled eggs cooked in a spicy curry.', imageUrl: 'https://via.placeholder.com/100', category: 'non-veg' },
55
- ];
56
-
57
- const menuContainer = document.getElementById('menu-items');
58
  const cart = [];
59
 
60
- // Function to automatically display the menu
61
- function showMenu() {
62
- menuContainer.innerHTML = ''; // Clear previous menu items
 
 
 
 
 
 
 
 
63
 
64
- menuItems.forEach(item => {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  const div = document.createElement('div');
66
  div.classList.add('menu-item');
67
  div.innerHTML = `<div class="details">
@@ -71,46 +98,28 @@
71
  <p>${item.description}</p>
72
  <p><strong>Ingredients:</strong> ${item.ingredients}</p>
73
  <p><strong>Price:</strong> $${item.price}</p>
74
- <button onclick="askForQuantity('${item.name}')">Add to Cart</button>
 
75
  </div>
76
  </div>`;
77
  menuContainer.appendChild(div);
78
  });
79
  }
80
 
81
- // Function to ask for quantity and add the item to the cart
82
- function askForQuantity(itemName) {
83
- const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
84
- recognition.lang = 'en-US';
85
- recognition.interimResults = false;
86
-
87
- recognition.onresult = (event) => {
88
- const command = event.results[0][0].transcript.toLowerCase();
89
- const quantityMatch = command.match(/(\d+)\s*([\w\s]*)/);
90
-
91
- if (quantityMatch) {
92
- const quantity = parseInt(quantityMatch[1]);
93
- const item = menuItems.find(item => item.name.toLowerCase() === itemName.toLowerCase());
94
- if (item) {
95
- const cartItem = { ...item, quantity };
96
- cart.push(cartItem);
97
- speak(`Added ${quantity} ${itemName} to the cart.`);
98
- }
99
- } else {
100
- speak('Please specify the quantity for the item.');
101
- }
102
- };
103
-
104
- recognition.onerror = () => {
105
- speak('Sorry, I couldn’t understand that. Please try again.');
106
- };
107
-
108
- speak(`How many ${itemName}s would you like to add to the cart?`, () => {
109
  recognition.start();
110
  });
111
  }
112
 
113
- // Function to view the cart
 
 
 
 
 
 
 
114
  function viewCart() {
115
  const cartContainer = document.getElementById('cart-container');
116
  const cartItemsContainer = document.getElementById('cart-items');
@@ -124,15 +133,10 @@
124
  cartContainer.style.display = 'block';
125
  }
126
 
127
- // Function for speech synthesis
128
- function speak(text) {
129
- const msg = new SpeechSynthesisUtterance(text);
130
- window.speechSynthesis.speak(msg);
131
- }
132
-
133
- window.onload = showMenu;
134
  </script>
135
  </body>
136
  </html>
137
 
138
-
 
20
  </head>
21
  <body>
22
  <div class="menu-container">
23
+ <h1>Welcome to the Biryani Hub Menu</h1>
24
  <div id="menu-items"></div>
25
  <button onclick="viewCart()">View Cart</button>
26
  </div>
 
31
  </div>
32
 
33
  <script>
34
+ const menuItems = {
35
+ veg: [
36
+ { name: 'Samosa', price: 9, ingredients: 'Potatoes, Peas, Flour, Spices', description: 'Crispy fried pastry filled with spiced potatoes and peas.', imageUrl: 'https://via.placeholder.com/100' },
37
+ { name: 'Onion Pakoda', price: 10, ingredients: 'Onions, Gram Flour, Spices', description: 'Deep-fried onion fritters seasoned with herbs and spices.', imageUrl: 'https://via.placeholder.com/100' },
38
+ { name: 'Chilli Gobi', price: 12, ingredients: 'Cauliflower, Chili Sauce, Spices', description: 'Cauliflower florets tossed in a spicy chili sauce.', imageUrl: 'https://via.placeholder.com/100' },
39
+ ],
40
+ nonVeg: [
41
+ { name: 'Chicken Biryani', price: 14, ingredients: 'Chicken, Basmati Rice, Spices', description: 'Aromatic basmati rice cooked with tender chicken and spices.', imageUrl: 'https://via.placeholder.com/100' },
42
+ { name: 'Mutton Biryani', price: 16, ingredients: 'Mutton, Basmati Rice, Spices', description: 'Flavorful rice dish made with succulent mutton and aromatic spices.', imageUrl: 'https://via.placeholder.com/100' },
43
+ { name: 'Butter Chicken', price: 15, ingredients: 'Chicken, Tomato, Butter, Cream', description: 'Tender chicken cooked in a rich, creamy tomato sauce.', imageUrl: 'https://via.placeholder.com/100' },
44
+ ]
45
+ };
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  const cart = [];
48
 
49
+ // Speech recognition to interact with the user
50
+ const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
51
+ recognition.lang = 'en-US';
52
+ recognition.interimResults = false;
53
+ recognition.maxAlternatives = 1;
54
+
55
+ function speak(text, callback) {
56
+ const msg = new SpeechSynthesisUtterance(text);
57
+ msg.onend = callback;
58
+ window.speechSynthesis.speak(msg);
59
+ }
60
 
61
+ function askForVegOrNonVeg() {
62
+ speak("Would you prefer the veg or non-veg menu?", () => {
63
+ recognition.start();
64
+ });
65
+ }
66
+
67
+ recognition.onresult = (event) => {
68
+ const command = event.results[0][0].transcript.toLowerCase();
69
+ console.log("User said:", command);
70
+ if (command.includes('veg')) {
71
+ showMenu('veg');
72
+ speak("Here are the vegetarian items.", () => askForItemsToAdd());
73
+ } else if (command.includes('non-veg')) {
74
+ showMenu('nonVeg');
75
+ speak("Here are the non-vegetarian items.", () => askForItemsToAdd());
76
+ } else {
77
+ speak("Please say either veg or non-veg.", () => {
78
+ recognition.start();
79
+ });
80
+ }
81
+ };
82
+
83
+ recognition.onerror = (event) => {
84
+ console.error("Speech recognition error:", event.error);
85
+ speak("Sorry, I couldn't understand that. Please try again.", () => recognition.start());
86
+ };
87
+
88
+ function showMenu(type) {
89
+ const menuContainer = document.getElementById('menu-items');
90
+ menuContainer.innerHTML = ''; // Clear previous menu items
91
+ menuItems[type].forEach(item => {
92
  const div = document.createElement('div');
93
  div.classList.add('menu-item');
94
  div.innerHTML = `<div class="details">
 
98
  <p>${item.description}</p>
99
  <p><strong>Ingredients:</strong> ${item.ingredients}</p>
100
  <p><strong>Price:</strong> $${item.price}</p>
101
+ <p><strong>Quantity:</strong> <input type="number" id="quantity-${item.name}" value="1" min="1" /></p>
102
+ <button onclick="addToCart('${item.name}')">Add to Cart</button>
103
  </div>
104
  </div>`;
105
  menuContainer.appendChild(div);
106
  });
107
  }
108
 
109
+ function askForItemsToAdd() {
110
+ speak("Please say the name of the item you'd like to add to the cart.", () => {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  recognition.start();
112
  });
113
  }
114
 
115
+ function addToCart(itemName) {
116
+ const quantity = document.getElementById(`quantity-${itemName}`).value;
117
+ const item = menuItems.veg.concat(menuItems.nonVeg).find(i => i.name === itemName);
118
+ const cartItem = { ...item, quantity: parseInt(quantity) };
119
+ cart.push(cartItem);
120
+ speak(`Added ${quantity} of ${itemName} to the cart.`);
121
+ }
122
+
123
  function viewCart() {
124
  const cartContainer = document.getElementById('cart-container');
125
  const cartItemsContainer = document.getElementById('cart-items');
 
133
  cartContainer.style.display = 'block';
134
  }
135
 
136
+ window.onload = () => {
137
+ speak("Welcome to the Biryani Hub menu.", () => askForVegOrNonVeg());
138
+ };
 
 
 
 
139
  </script>
140
  </body>
141
  </html>
142