Spaces:
Running
Running
Update templates/menu_page.html
Browse files- 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 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
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 |
-
//
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
<
|
|
|
75 |
</div>
|
76 |
</div>`;
|
77 |
menuContainer.appendChild(div);
|
78 |
});
|
79 |
}
|
80 |
|
81 |
-
|
82 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
128 |
-
|
129 |
-
|
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 |
|
|