lokesh341 commited on
Commit
b0082be
·
verified ·
1 Parent(s): 8f3a5d1

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +126 -30
templates/menu_page.html CHANGED
@@ -14,7 +14,6 @@
14
  }
15
  h1 {
16
  color: #ff5722;
17
- margin-bottom: 30px;
18
  }
19
  .menu-container {
20
  display: flex;
@@ -52,38 +51,57 @@
52
  background-color: #e64a19;
53
  }
54
  .cart-container {
55
- position: fixed;
56
- bottom: 20px;
57
- right: 20px;
58
- z-index: 999;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
60
- .cart-button {
 
 
 
 
 
 
 
 
61
  background-color: #007bff;
62
  color: white;
63
- padding: 10px 20px;
64
- border-radius: 50px;
65
- font-size: 1rem;
66
- font-weight: bold;
67
- text-decoration: none;
68
- display: flex;
69
- align-items: center;
70
- justify-content: center;
71
  }
72
- .cart-button:hover {
73
  background-color: #0056b3;
74
- text-decoration: none;
75
  }
76
  </style>
77
  </head>
78
  <body>
 
79
  <h1>Restaurant Menu</h1>
80
 
 
 
 
 
 
 
81
  <!-- Menu Display -->
82
- <div class="menu-container">
83
  {% for item in menu %}
84
- <div class="menu-item">
85
  <h3>{{ item.name }}</h3>
86
- <img src="{{ url_for('static', filename='images/' + item.image_url) }}" alt="{{ item.name }}" style="width: 100px; height: 100px; border-radius: 8px;">
87
  <p><strong>Category:</strong> {{ item.category }}</p>
88
  <p><strong>Price:</strong> ${{ item.price }}</p>
89
  <p><strong>Ingredients:</strong> {{ item.ingredients }}</p>
@@ -92,24 +110,102 @@
92
  {% endfor %}
93
  </div>
94
 
95
- <!-- Cart Button -->
96
- <div class="cart-container">
97
- <a href="/cart" class="cart-button">View Cart</a>
 
 
98
  </div>
99
 
 
 
 
100
  <script>
101
  let cart = [];
102
-
103
- // Add items to cart
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  function addToCart(name, price) {
105
- cart.push({ name, price });
106
- alert(name + " added to cart!");
 
 
 
 
 
107
  }
108
-
109
- // View cart function (you can further expand it based on cart items)
110
  function viewCart() {
111
- console.log(cart); // Display cart items in the browser console for now
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
 
 
113
  </script>
 
114
  </body>
115
- </html>
 
14
  }
15
  h1 {
16
  color: #ff5722;
 
17
  }
18
  .menu-container {
19
  display: flex;
 
51
  background-color: #e64a19;
52
  }
53
  .cart-container {
54
+ margin-top: 20px;
55
+ padding: 15px;
56
+ background-color: white;
57
+ border: 1px solid #ddd;
58
+ border-radius: 5px;
59
+ width: 50%;
60
+ margin-left: auto;
61
+ margin-right: auto;
62
+ display: none;
63
+ }
64
+ .cart-item {
65
+ display: flex;
66
+ justify-content: space-between;
67
+ padding: 5px;
68
+ border-bottom: 1px solid #ddd;
69
+ }
70
+ .cart-item:last-child {
71
+ border-bottom: none;
72
  }
73
+ .filter-buttons {
74
+ margin: 15px;
75
+ }
76
+ .filter-buttons button {
77
+ margin: 5px;
78
+ padding: 10px;
79
+ border: none;
80
+ cursor: pointer;
81
+ border-radius: 5px;
82
  background-color: #007bff;
83
  color: white;
 
 
 
 
 
 
 
 
84
  }
85
+ .filter-buttons button:hover {
86
  background-color: #0056b3;
 
87
  }
88
  </style>
89
  </head>
90
  <body>
91
+
92
  <h1>Restaurant Menu</h1>
93
 
94
+ <!-- Filter Buttons -->
95
+ <div class="filter-buttons">
96
+ <button onclick="filterMenu('Veg')">Vegetarian</button>
97
+ <button onclick="filterMenu('Non-Veg')">Non-Vegetarian</button>
98
+ </div>
99
+
100
  <!-- Menu Display -->
101
+ <div class="menu-container" id="menu-list">
102
  {% for item in menu %}
103
+ <div class="menu-item" data-category="{{ item.category }}">
104
  <h3>{{ item.name }}</h3>
 
105
  <p><strong>Category:</strong> {{ item.category }}</p>
106
  <p><strong>Price:</strong> ${{ item.price }}</p>
107
  <p><strong>Ingredients:</strong> {{ item.ingredients }}</p>
 
110
  {% endfor %}
111
  </div>
112
 
113
+ <!-- Cart Section -->
114
+ <div class="cart-container" id="cart-container">
115
+ <h2>Your Cart</h2>
116
+ <div id="cart-items"></div>
117
+ <button onclick="checkout()">Checkout</button>
118
  </div>
119
 
120
+ <!-- View Cart Button -->
121
+ <button onclick="viewCart()">View Cart</button>
122
+
123
  <script>
124
  let cart = [];
125
+ // ✅ Speech Synthesis - Welcome message
126
+ function speak(text, callback) {
127
+ const msg = new SpeechSynthesisUtterance(text);
128
+ msg.onend = callback;
129
+ window.speechSynthesis.speak(msg);
130
+ }
131
+ // ✅ Ask user Veg or Non-Veg
132
+ function askMenuType() {
133
+ speak("Welcome to Biryani Hub Menu. Would you like to see Vegetarian or Non-Vegetarian options?", function() {
134
+ startListening();
135
+ });
136
+ }
137
+ // ✅ Speech Recognition (User says Veg or Non-Veg)
138
+ function startListening() {
139
+ const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
140
+ recognition.lang = "en-US";
141
+ recognition.start();
142
+ recognition.onresult = function(event) {
143
+ const command = event.results[0][0].transcript.toLowerCase();
144
+ if (command.includes("vegetarian") || command.includes("veg")) {
145
+ filterMenu("Veg");
146
+ } else if (command.includes("non-vegetarian") || command.includes("non veg")) {
147
+ filterMenu("Non-Veg");
148
+ } else {
149
+ speak("Sorry, I didn't understand. Please say Vegetarian or Non-Vegetarian.", function() {
150
+ startListening();
151
+ });
152
+ }
153
+ };
154
+ }
155
+ // ✅ Function to filter menu by category and speak items
156
+ function filterMenu(type) {
157
+ const allItems = document.querySelectorAll('.menu-item');
158
+ let availableItems = [];
159
+ allItems.forEach(item => {
160
+ const category = item.dataset.category.toLowerCase();
161
+ if (type === "Veg" && (category.includes("veg") || category.includes("paneer") || category.includes("channa"))) {
162
+ item.style.display = "block";
163
+ availableItems.push(item.querySelector('h3').innerText);
164
+ } else if (type === "Non-Veg" && (category.includes("chicken") || category.includes("mutton") || category.includes("fish") || category.includes("prawn"))) {
165
+ item.style.display = "block";
166
+ availableItems.push(item.querySelector('h3').innerText);
167
+ } else {
168
+ item.style.display = "none";
169
+ }
170
+ });
171
+ speak("Here are the available items: " + availableItems.join(", "));
172
+ }
173
+ // ✅ Function to add items to cart
174
  function addToCart(name, price) {
175
+ const existingItem = cart.find(item => item.name === name);
176
+ if (existingItem) {
177
+ existingItem.quantity += 1;
178
+ } else {
179
+ cart.push({ name, price, quantity: 1 });
180
+ }
181
+ speak(name + " added to cart!");
182
  }
183
+ // ✅ Function to view cart
 
184
  function viewCart() {
185
+ const cartContainer = document.getElementById("cart-container");
186
+ const cartItemsContainer = document.getElementById("cart-items");
187
+ cartItemsContainer.innerHTML = "";
188
+ cart.forEach(cartItem => {
189
+ const div = document.createElement("div");
190
+ div.classList.add("cart-item");
191
+ div.innerHTML = `<span>${cartItem.name} (x${cartItem.quantity}) - $${cartItem.price * cartItem.quantity}</span>`;
192
+ cartItemsContainer.appendChild(div);
193
+ });
194
+ cartContainer.style.display = "block";
195
+ }
196
+ // ✅ Function to checkout
197
+ function checkout() {
198
+ if (cart.length > 0) {
199
+ speak("Your order has been placed successfully!");
200
+ cart = [];
201
+ viewCart();
202
+ } else {
203
+ speak("Your cart is empty. Please add items before placing the order.");
204
+ }
205
  }
206
+ // ✅ Welcome Message on Page Load
207
+ window.onload = askMenuType;
208
  </script>
209
+
210
  </body>
211
+ </html>