lokesh341 commited on
Commit
4e75788
·
verified ·
1 Parent(s): 0613b1a

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +27 -136
templates/menu_page.html CHANGED
@@ -14,6 +14,7 @@
14
  }
15
  h1 {
16
  color: #ff5722;
 
17
  }
18
  .menu-container {
19
  display: flex;
@@ -51,57 +52,38 @@
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,115 +92,24 @@
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
 
126
- // Speech Synthesis - Welcome message
127
- function speak(text, callback) {
128
- const msg = new SpeechSynthesisUtterance(text);
129
- msg.onend = callback;
130
- window.speechSynthesis.speak(msg);
131
- }
132
-
133
- // ✅ Ask user Veg or Non-Veg
134
- function askMenuType() {
135
- speak("Welcome to Biryani Hub Menu. Would you like to see Vegetarian or Non-Vegetarian options?", function() {
136
- startListening();
137
- });
138
- }
139
-
140
- // ✅ Speech Recognition (User says Veg or Non-Veg)
141
- function startListening() {
142
- const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
143
- recognition.lang = "en-US";
144
- recognition.start();
145
-
146
- recognition.onresult = function(event) {
147
- const command = event.results[0][0].transcript.toLowerCase();
148
- if (command.includes("vegetarian") || command.includes("veg")) {
149
- filterMenu("Veg");
150
- } else if (command.includes("non-vegetarian") || command.includes("non veg")) {
151
- filterMenu("Non-Veg");
152
- } else {
153
- speak("Sorry, I didn't understand. Please say Vegetarian or Non-Vegetarian.", function() {
154
- startListening();
155
- });
156
- }
157
- };
158
- }
159
-
160
- // ✅ Function to filter menu by category and speak items
161
- function filterMenu(type) {
162
- const allItems = document.querySelectorAll('.menu-item');
163
- let availableItems = [];
164
-
165
- allItems.forEach(item => {
166
- const category = item.dataset.category.toLowerCase();
167
- if (type === "Veg" && (category.includes("veg") || category.includes("paneer") || category.includes("channa"))) {
168
- item.style.display = "block";
169
- availableItems.push(item.querySelector('h3').innerText);
170
- } else if (type === "Non-Veg" && (category.includes("chicken") || category.includes("mutton") || category.includes("fish") || category.includes("prawn"))) {
171
- item.style.display = "block";
172
- availableItems.push(item.querySelector('h3').innerText);
173
- } else {
174
- item.style.display = "none";
175
- }
176
- });
177
-
178
- speak("Here are the available items: " + availableItems.join(", "));
179
- }
180
-
181
- // ✅ Function to add items to cart
182
  function addToCart(name, price) {
183
- const existingItem = cart.find(item => item.name === name);
184
- if (existingItem) {
185
- existingItem.quantity += 1;
186
- } else {
187
- cart.push({ name, price, quantity: 1 });
188
- }
189
- speak(name + " added to cart!");
190
  }
191
 
192
- // Function to view cart
193
  function viewCart() {
194
- const cartContainer = document.getElementById("cart-container");
195
- const cartItemsContainer = document.getElementById("cart-items");
196
-
197
- cartItemsContainer.innerHTML = "";
198
- cart.forEach(cartItem => {
199
- const div = document.createElement("div");
200
- div.classList.add("cart-item");
201
- div.innerHTML = `<span>${cartItem.name} (x${cartItem.quantity}) - $${cartItem.price * cartItem.quantity}</span>`;
202
- cartItemsContainer.appendChild(div);
203
- });
204
-
205
- cartContainer.style.display = "block";
206
  }
207
-
208
- // ✅ Function to checkout
209
- function checkout() {
210
- if (cart.length > 0) {
211
- speak("Your order has been placed successfully!");
212
- cart = [];
213
- viewCart();
214
- } else {
215
- speak("Your cart is empty. Please add items before placing the order.");
216
- }
217
- }
218
-
219
- // ✅ Welcome Message on Page Load
220
- window.onload = askMenuType;
221
  </script>
222
-
223
  </body>
224
  </html>
 
14
  }
15
  h1 {
16
  color: #ff5722;
17
+ margin-bottom: 30px;
18
  }
19
  .menu-container {
20
  display: flex;
 
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
  {% 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>