lokesh341 commited on
Commit
d6576ad
·
verified ·
1 Parent(s): 6928c0e

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +32 -20
templates/menu_page.html CHANGED
@@ -52,17 +52,6 @@
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
- // Desserts
57
- { name: 'Gulab Jamun', price: 5, ingredients: 'Milk Powder, Sugar, Cardamom', description: 'Deep-fried dough balls soaked in sugary syrup.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
58
- { name: 'Rasgulla', price: 6, ingredients: 'Chhena, Sugar, Rose Water', description: 'Soft, spongy balls made from chhena and soaked in syrup.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
59
- { name: 'Kulfi', price: 7, ingredients: 'Milk, Sugar, Cardamom, Pistachios', description: 'Traditional Indian ice cream flavored with cardamom and pistachios.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
60
-
61
- // Drinks
62
- { name: 'Mango Lassi', price: 6, ingredients: 'Mango, Yogurt, Sugar', description: 'A sweet and tangy mango yogurt drink.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
63
- { name: 'Sweet Lime Soda', price: 4, ingredients: 'Lime, Soda, Sugar', description: 'A refreshing drink made with lime and soda.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
64
- { name: 'Masala Chai', price: 3, ingredients: 'Tea, Milk, Spices', description: 'Spiced Indian tea served hot with milk.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
65
- { name: 'Coconut Water', price: 5, ingredients: 'Coconut Water', description: 'Fresh coconut water served chilled.', imageUrl: 'https://via.placeholder.com/100', category: 'veg' },
66
  ];
67
 
68
  const menuContainer = document.getElementById('menu-items');
@@ -82,21 +71,43 @@
82
  <p>${item.description}</p>
83
  <p><strong>Ingredients:</strong> ${item.ingredients}</p>
84
  <p><strong>Price:</strong> $${item.price}</p>
85
- <p><strong>Quantity:</strong> <input type="number" id="quantity-${item.name}" value="1" min="1" /></p>
86
- <button onclick="addToCart('${item.name}')">Add to Cart</button>
87
  </div>
88
  </div>`;
89
  menuContainer.appendChild(div);
90
  });
91
  }
92
 
93
- // Function to add items to the cart
94
- function addToCart(itemName) {
95
- const quantity = document.getElementById(`quantity-${itemName}`).value;
96
- const item = menuItems.find(item => item.name === itemName);
97
- const cartItem = { ...item, quantity: parseInt(quantity) };
98
- cart.push(cartItem);
99
- speak(`Added ${quantity} of ${itemName} to the cart.`);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  }
101
 
102
  // Function to view the cart
@@ -123,3 +134,4 @@
123
  </script>
124
  </body>
125
  </html>
 
 
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');
 
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
 
134
  </script>
135
  </body>
136
  </html>
137
+