lokesh341 commited on
Commit
c141bc3
·
verified ·
1 Parent(s): c1d1415

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +33 -129
templates/menu.html CHANGED
@@ -49,14 +49,14 @@
49
  border-radius: 15px 15px 0 0;
50
  opacity: 0;
51
  transition: opacity 0.5s ease-in-out;
52
- background-color: #000; /* Fallback color if video fails */
53
  }
54
  .menu-video.loaded {
55
  opacity: 1;
56
  }
57
  .menu-card:hover .menu-video {
58
  opacity: 1;
59
- transform: scale(1.05); /* Slight zoom effect on hover */
60
  }
61
  .menu-card .card-body .card-title {
62
  font-size: 1.2rem;
@@ -854,7 +854,14 @@
854
  </div>
855
  {% if item.Section__c != 'Soft Drinks' %}
856
  <div class="toggle-details" data-item-name="{{ item.Name | default('Unnamed Item') }}">Show Details</div>
857
- <div class="item-details" id="details-{{ item.Name | default('unnamed-item') | replace(' ', '-') }}"></div>
 
 
 
 
 
 
 
858
  {% endif %}
859
  </div>
860
  </div>
@@ -871,7 +878,7 @@
871
  </a>
872
  <a href="{{ url_for('cart.cart') }}" class="btn btn-view-cart">
873
  <i class="bi bi-cart"></i> View Cart
874
- <span class="cart-icon-badge" id="cart-item-count">0</span>
875
  </a>
876
  </div>
877
 
@@ -968,99 +975,6 @@
968
  "Whole Wheat Flour", "Yogurt (Curd)"
969
  ];
970
 
971
- const menuItemDetails = {
972
- "Veg Manchurian": {
973
- ingredients: "Cauliflower, Onion, Ginger, Garlic, Soy Sauce, Cornflour, Green Chilies, Capsicum, Spring Onion",
974
- nutritionalInfo: { calories: 250, protein: 5, carbs: 35, fats: 12, fiber: 3, sugar: 2 },
975
- allergens: "Soy, Gluten"
976
- },
977
- "Veg Biryani": {
978
- ingredients: "Basmati Rice, Mixed Vegetables (Carrot, Peas, Potato, Cauliflower), Ginger, Garlic, Biryani Masala, Mint Leaves, Curd, Onion, Ghee",
979
- nutritionalInfo: { calories: 300, protein: 6, carbs: 50, fats: 12, fiber: 5, sugar: 3 },
980
- allergens: "Dairy"
981
- },
982
- "Sukka Gosht (Goat)": {
983
- ingredients: "Goat Meat, Ginger-Garlic Paste, Green Chilies, Onion, Tomatoes, Garam Masala, Coriander Powder, Cumin Powder, Fresh Coriander",
984
- nutritionalInfo: { calories: 450, protein: 35, carbs: 10, fats: 30, fiber: 2, sugar: 1 },
985
- allergens: "None"
986
- },
987
- "Samosa": {
988
- ingredients: "Potatoes, Peas, Onion, Ginger, Cumin Seeds, Garam Masala, Wheat Flour (for dough), Oil (for frying)",
989
- nutritionalInfo: { calories: 150, protein: 3, carbs: 25, fats: 7, fiber: 2, sugar: 1 },
990
- allergens: "Gluten"
991
- },
992
- "Roti": {
993
- ingredients: "Whole Wheat Flour, Water, Salt",
994
- nutritionalInfo: { calories: 150, protein: 4, carbs: 30, fats: 1, fiber: 3, sugar: 0 },
995
- allergens: "Gluten"
996
- },
997
- "Prawn Fry": {
998
- ingredients: "Prawns, Garlic, Ginger, Chili Powder, Coriander Powder, Cumin Powder, Lemon Juice, Oil",
999
- nutritionalInfo: { calories: 350, protein: 25, carbs: 10, fats: 20, fiber: 1, sugar: 1 },
1000
- allergens: "Shellfish"
1001
- },
1002
- "Paneer Butter Masala": {
1003
- ingredients: "Paneer, Butter, Cream, Tomato Puree, Onion, Ginger, Garlic, Garam Masala",
1004
- nutritionalInfo: { calories: 400, protein: 15, carbs: 20, fats: 25, fiber: 2, sugar: 3 },
1005
- allergens: "Dairy"
1006
- },
1007
- "Paneer Biryani": {
1008
- ingredients: "Paneer, Basmati Rice, Mixed Vegetables (Carrot, Peas, Potato), Onion, Tomatoes, Biryani Masala, Mint Leaves, Curd",
1009
- nutritionalInfo: { calories: 350, protein: 12, carbs: 55, fats: 15, fiber: 4, sugar: 3 },
1010
- allergens: "Dairy"
1011
- },
1012
- "Onion Pakoda": {
1013
- ingredients: "Onion, Chickpea Flour (Besan), Rice Flour, Green Chilies, Cumin Seeds, Ginger, Turmeric Powder, Oil (for frying)",
1014
- nutritionalInfo: { calories: 200, protein: 5, carbs: 30, fats: 8, fiber: 3, sugar: 2 },
1015
- allergens: "Gluten (if cross-contamination)"
1016
- },
1017
- "Mutton Biryani": {
1018
- ingredients: "Mutton, Basmati Rice, Onion, Tomatoes, Ginger-Garlic Paste, Biryani Masala, Mint Leaves, Yogurt, Ghee",
1019
- nutritionalInfo: { calories: 500, protein: 30, carbs: 50, fats: 25, fiber: 4, sugar: 3 },
1020
- allergens: "Dairy"
1021
- },
1022
- "Fish Curry": {
1023
- ingredients: "Fish (any firm fish like Salmon or King Fish), Onion, Tomato, Ginger-Garlic Paste, Curry Leaves, Coconut Milk, Tamarind, Mustard Seeds",
1024
- nutritionalInfo: { calories: 300, protein: 25, carbs: 10, fats: 20, fiber: 2, sugar: 1 },
1025
- allergens: "Fish"
1026
- },
1027
- "Fiery Mango Glaze Chicken": {
1028
- ingredients: "Chicken, Mango Puree, Chili Sauce, Soy Sauce, Honey, Garlic, Ginger, Lemon Juice",
1029
- nutritionalInfo: { calories: 350, protein: 30, carbs: 15, fats: 18, fiber: 1, sugar: 5 },
1030
- allergens: "Soy"
1031
- },
1032
- "Chilli Gobi": {
1033
- ingredients: "Cauliflower, Onion, Green Chilies, Soy Sauce, Cornflour, Garlic, Ginger, Cumin Powder",
1034
- nutritionalInfo: { calories: 250, protein: 6, carbs: 35, fats: 12, fiber: 3, sugar: 2 },
1035
- allergens: "Soy, Gluten"
1036
- },
1037
- "Chilli Chicken": {
1038
- ingredients: "Chicken, Bell Pepper, Onion, Green Chilies, Soy Sauce, Cornflour, Garlic, Ginger",
1039
- nutritionalInfo: { calories: 400, protein: 35, carbs: 20, fats: 18, fiber: 2, sugar: 2 },
1040
- allergens: "Soy, Gluten"
1041
- },
1042
- "Chicken Manchurian": {
1043
- ingredients: "Chicken, Onion, Garlic, Ginger, Soy Sauce, Cornflour, Green Chilies, Capsicum",
1044
- nutritionalInfo: { calories: 350, protein: 25, carbs: 20, fats: 18, fiber: 2, sugar: 2 },
1045
- allergens: "Soy, Gluten"
1046
- },
1047
- "Chicken Curry": {
1048
- ingredients: "Chicken, Onion, Tomatoes, Ginger-Garlic Paste, Garam Masala, Coconut Milk, Coriander Leaves",
1049
- nutritionalInfo: { calories: 350, protein: 28, carbs: 15, fats: 12, fiber: 4, sugar: 2 },
1050
- allergens: "None"
1051
- },
1052
- "Chicken Biryani": {
1053
- ingredients: "Chicken, Basmati Rice, Onion, Tomatoes, Ginger-Garlic Paste, Biryani Masala, Mint Leaves, Curd",
1054
- nutritionalInfo: { calories: 500, protein: 35, carbs: 60, fats: 20, fiber: 5, sugar: 3 },
1055
- allergens: "Dairy"
1056
- },
1057
- "Channa Masala": {
1058
- ingredients: "Chickpeas, Onion, Tomatoes, Ginger-Garlic Paste, Garam Masala, Coriander Powder, Cumin Seeds, Lemon Juice",
1059
- nutritionalInfo: { calories: 250, protein: 10, carbs: 45, fats: 5, fiber: 6, sugar: 2 },
1060
- allergens: "None"
1061
- }
1062
- };
1063
-
1064
  function addToCartLocalStorage(payload) {
1065
  let cart = JSON.parse(localStorage.getItem('cart')) || [];
1066
  const existingItem = cart.find(item =>
@@ -1069,7 +983,7 @@
1069
  JSON.stringify(item.addons) === JSON.stringify(payload.addons)
1070
  );
1071
  if (existingItem) {
1072
- existingItem.quantity = payload.quantity;
1073
  } else {
1074
  cart.push(payload);
1075
  }
@@ -1157,7 +1071,7 @@
1157
  .then(response => response.json())
1158
  .then(data => {
1159
  if (data.success) {
1160
- updateCartUI(data.cart);
1161
  const modal = bootstrap.Modal.getInstance(document.getElementById('softDrinkModal'));
1162
  modal.hide();
1163
  } else {
@@ -1180,7 +1094,7 @@
1180
  function updateCartUI(cart) {
1181
  if (!Array.isArray(cart)) {
1182
  console.error('Invalid cart data:', cart);
1183
- return;
1184
  }
1185
 
1186
  let totalQuantity = 0;
@@ -1213,29 +1127,8 @@
1213
  dropdownMenu.style.display = 'none';
1214
  });
1215
  });
 
1216
  const menuCards = document.querySelectorAll('.menu-card');
1217
- menuCards.forEach(card => {
1218
- const itemName = card.querySelector('.card-title').innerText;
1219
- const detailsDiv = card.querySelector('.item-details');
1220
- const detailsData = menuItemDetails[itemName];
1221
- if (detailsDiv && detailsData) {
1222
- detailsDiv.innerHTML = `
1223
- <h6>Ingredients</h6>
1224
- <p>${detailsData.ingredients}</p>
1225
- <h6>Nutritional Info</h6>
1226
- <div class="nutritional-info">
1227
- <span>Calories: ${detailsData.nutritionalInfo.calories} kcal</span>
1228
- <span>Carbs: ${detailsData.nutritionalInfo.carbs}g</span>
1229
- <span>Protein: ${detailsData.nutritionalInfo.protein}g</span>
1230
- <span>Fats: ${detailsData.nutritionalInfo.fats}g</span>
1231
- </div>
1232
- <h6>Allergens</h6>
1233
- <p>${detailsData.allergens}</p>
1234
- `;
1235
- } else if (detailsDiv) {
1236
- detailsDiv.innerHTML = '<p>No details available for this item.</p>';
1237
- }
1238
- });
1239
  const menuVideos = document.querySelectorAll('.menu-video');
1240
  const cardObserver = new IntersectionObserver((entries, observer) => {
1241
  entries.forEach(entry => {
@@ -1270,6 +1163,7 @@
1270
  });
1271
  menuCards.forEach(card => cardObserver.observe(card));
1272
  menuVideos.forEach(video => videoObserver.observe(video));
 
1273
  const toggleLinks = document.querySelectorAll('.toggle-details');
1274
  toggleLinks.forEach(link => {
1275
  link.addEventListener('click', function () {
@@ -1279,6 +1173,7 @@
1279
  this.innerText = detailsDiv.classList.contains('show') ? 'Hide Details' : 'Show Details';
1280
  });
1281
  });
 
1282
  const categoryButtons = document.querySelectorAll('.category-button');
1283
  const categoryForm = document.getElementById('categoryForm');
1284
  const selectedCategoryInput = document.getElementById('selectedCategoryInput');
@@ -1294,9 +1189,10 @@
1294
  categoryForm.submit();
1295
  });
1296
  });
 
1297
  const searchBar = document.getElementById('searchBar');
1298
  const suggestionsContainer = document.getElementById('autocompleteSuggestions');
1299
- searchBar.addEventListener('input', function () {
1300
  const input = this.value.trim().toLowerCase();
1301
  suggestionsContainer.innerHTML = '';
1302
  suggestionsContainer.style.display = 'none';
@@ -1320,12 +1216,14 @@
1320
  }
1321
  }
1322
  filterMenu();
1323
- });
 
1324
  document.addEventListener('click', function (event) {
1325
  if (!searchBar.contains(event.target) && !suggestionsContainer.contains(event.target)) {
1326
  suggestionsContainer.style.display = 'none';
1327
  }
1328
  });
 
1329
  const descriptionTextarea = document.getElementById('custom-dish-description');
1330
  const descriptionSuggestions = document.getElementById('descriptionSuggestions');
1331
  if (descriptionTextarea && descriptionSuggestions) {
@@ -1342,7 +1240,7 @@
1342
  });
1343
  }
1344
  }
1345
- descriptionTextarea.addEventListener('input', function () {
1346
  const inputText = this.value.trim();
1347
  const words = inputText.split(/,\s*/);
1348
  const lastWord = words[words.length - 1].trim().toLowerCase();
@@ -1372,13 +1270,14 @@
1372
  descriptionSuggestions.style.display = 'block';
1373
  }
1374
  }
1375
- });
1376
  document.addEventListener('click', function (event) {
1377
  if (!descriptionTextarea.contains(event.target) && !descriptionSuggestions.contains(event.target)) {
1378
  descriptionSuggestions.style.display = 'none';
1379
  }
1380
  });
1381
  }
 
1382
  fetch('/cart/get')
1383
  .then(response => {
1384
  if (!response.ok) {
@@ -1400,12 +1299,14 @@
1400
  const cart = getCartLocalStorage();
1401
  updateCartUI(cart);
1402
  });
 
1403
  const preloadedVideos = document.querySelectorAll('link[rel="preload"][as="video"]');
1404
  preloadedVideos.forEach(link => {
1405
  const video = document.createElement('video');
1406
  video.src = link.href;
1407
  video.preload = 'auto';
1408
  });
 
1409
  const decreaseBtn = document.getElementById('decreaseQuantity');
1410
  const increaseBtn = document.getElementById('increaseQuantity');
1411
  const quantityInput = document.getElementById('quantityInput');
@@ -1425,7 +1326,6 @@
1425
  const softDrinkDecreaseBtn = document.getElementById('soft-drink-decrease');
1426
  const softDrinkIncreaseBtn = document.getElementById('soft-drink-increase');
1427
  const softDrinkQuantityInput = document.getElementById('soft-drink-quantity');
1428
-
1429
  softDrinkDecreaseBtn.addEventListener('click', function() {
1430
  let currentQuantity = parseInt(softDrinkQuantityInput.value);
1431
  if (currentQuantity > 1) {
@@ -1433,7 +1333,6 @@
1433
  softDrinkQuantityInput.value = currentQuantity;
1434
  }
1435
  });
1436
-
1437
  softDrinkIncreaseBtn.addEventListener('click', function() {
1438
  let currentQuantity = parseInt(softDrinkQuantityInput.value);
1439
  if (currentQuantity < 10) {
@@ -1619,13 +1518,18 @@
1619
  .then(data => {
1620
  if (data.success) {
1621
  alert('Item added to cart successfully!');
1622
- updateCartUI(data.cart);
1623
  const modal = document.getElementById('itemModal');
1624
  const modalInstance = bootstrap.Modal.getInstance(modal);
1625
  modalInstance.hide();
1626
  } else {
1627
  console.error('Failed to add item to cart:', data.error);
1628
  alert(data.error || 'Failed to add item to cart.');
 
 
 
 
 
1629
  }
1630
  })
1631
  .catch(err => {
 
49
  border-radius: 15px 15px 0 0;
50
  opacity: 0;
51
  transition: opacity 0.5s ease-in-out;
52
+ background-color: #000;
53
  }
54
  .menu-video.loaded {
55
  opacity: 1;
56
  }
57
  .menu-card:hover .menu-video {
58
  opacity: 1;
59
+ transform: scale(1.05);
60
  }
61
  .menu-card .card-body .card-title {
62
  font-size: 1.2rem;
 
854
  </div>
855
  {% if item.Section__c != 'Soft Drinks' %}
856
  <div class="toggle-details" data-item-name="{{ item.Name | default('Unnamed Item') }}">Show Details</div>
857
+ <div class="item-details" id="details-{{ item.Name | default('unnamed-item') | replace(' ', '-') }}">
858
+ <h6>Ingredients</h6>
859
+ <p>{{ item.All_Ingredients__c | default('Not specified') }}</p>
860
+ <h6>Nutritional Info</h6>
861
+ <p>{{ item.Nutritional_Information__c | default('Not available') }}</p>
862
+ <h6>Allergens</h6>
863
+ <p>{{ item.Allergen__c | default('None') }}</p>
864
+ </div>
865
  {% endif %}
866
  </div>
867
  </div>
 
878
  </a>
879
  <a href="{{ url_for('cart.cart') }}" class="btn btn-view-cart">
880
  <i class="bi bi-cart"></i> View Cart
881
+ <span class="cart-icon-badge" id="cart-item-count">{{ cart_item_count }}</span>
882
  </a>
883
  </div>
884
 
 
975
  "Whole Wheat Flour", "Yogurt (Curd)"
976
  ];
977
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
978
  function addToCartLocalStorage(payload) {
979
  let cart = JSON.parse(localStorage.getItem('cart')) || [];
980
  const existingItem = cart.find(item =>
 
983
  JSON.stringify(item.addons) === JSON.stringify(payload.addons)
984
  );
985
  if (existingItem) {
986
+ existingItem.quantity += payload.quantity;
987
  } else {
988
  cart.push(payload);
989
  }
 
1071
  .then(response => response.json())
1072
  .then(data => {
1073
  if (data.success) {
1074
+ updateCartUI(data.cart || getCartLocalStorage());
1075
  const modal = bootstrap.Modal.getInstance(document.getElementById('softDrinkModal'));
1076
  modal.hide();
1077
  } else {
 
1094
  function updateCartUI(cart) {
1095
  if (!Array.isArray(cart)) {
1096
  console.error('Invalid cart data:', cart);
1097
+ cart = getCartLocalStorage();
1098
  }
1099
 
1100
  let totalQuantity = 0;
 
1127
  dropdownMenu.style.display = 'none';
1128
  });
1129
  });
1130
+
1131
  const menuCards = document.querySelectorAll('.menu-card');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1132
  const menuVideos = document.querySelectorAll('.menu-video');
1133
  const cardObserver = new IntersectionObserver((entries, observer) => {
1134
  entries.forEach(entry => {
 
1163
  });
1164
  menuCards.forEach(card => cardObserver.observe(card));
1165
  menuVideos.forEach(video => videoObserver.observe(video));
1166
+
1167
  const toggleLinks = document.querySelectorAll('.toggle-details');
1168
  toggleLinks.forEach(link => {
1169
  link.addEventListener('click', function () {
 
1173
  this.innerText = detailsDiv.classList.contains('show') ? 'Hide Details' : 'Show Details';
1174
  });
1175
  });
1176
+
1177
  const categoryButtons = document.querySelectorAll('.category-button');
1178
  const categoryForm = document.getElementById('categoryForm');
1179
  const selectedCategoryInput = document.getElementById('selectedCategoryInput');
 
1189
  categoryForm.submit();
1190
  });
1191
  });
1192
+
1193
  const searchBar = document.getElementById('searchBar');
1194
  const suggestionsContainer = document.getElementById('autocompleteSuggestions');
1195
+ searchBar.addEventListener('input', debounce(function () {
1196
  const input = this.value.trim().toLowerCase();
1197
  suggestionsContainer.innerHTML = '';
1198
  suggestionsContainer.style.display = 'none';
 
1216
  }
1217
  }
1218
  filterMenu();
1219
+ }, 300));
1220
+
1221
  document.addEventListener('click', function (event) {
1222
  if (!searchBar.contains(event.target) && !suggestionsContainer.contains(event.target)) {
1223
  suggestionsContainer.style.display = 'none';
1224
  }
1225
  });
1226
+
1227
  const descriptionTextarea = document.getElementById('custom-dish-description');
1228
  const descriptionSuggestions = document.getElementById('descriptionSuggestions');
1229
  if (descriptionTextarea && descriptionSuggestions) {
 
1240
  });
1241
  }
1242
  }
1243
+ descriptionTextarea.addEventListener('input', debounce(function () {
1244
  const inputText = this.value.trim();
1245
  const words = inputText.split(/,\s*/);
1246
  const lastWord = words[words.length - 1].trim().toLowerCase();
 
1270
  descriptionSuggestions.style.display = 'block';
1271
  }
1272
  }
1273
+ }, 300));
1274
  document.addEventListener('click', function (event) {
1275
  if (!descriptionTextarea.contains(event.target) && !descriptionSuggestions.contains(event.target)) {
1276
  descriptionSuggestions.style.display = 'none';
1277
  }
1278
  });
1279
  }
1280
+
1281
  fetch('/cart/get')
1282
  .then(response => {
1283
  if (!response.ok) {
 
1299
  const cart = getCartLocalStorage();
1300
  updateCartUI(cart);
1301
  });
1302
+
1303
  const preloadedVideos = document.querySelectorAll('link[rel="preload"][as="video"]');
1304
  preloadedVideos.forEach(link => {
1305
  const video = document.createElement('video');
1306
  video.src = link.href;
1307
  video.preload = 'auto';
1308
  });
1309
+
1310
  const decreaseBtn = document.getElementById('decreaseQuantity');
1311
  const increaseBtn = document.getElementById('increaseQuantity');
1312
  const quantityInput = document.getElementById('quantityInput');
 
1326
  const softDrinkDecreaseBtn = document.getElementById('soft-drink-decrease');
1327
  const softDrinkIncreaseBtn = document.getElementById('soft-drink-increase');
1328
  const softDrinkQuantityInput = document.getElementById('soft-drink-quantity');
 
1329
  softDrinkDecreaseBtn.addEventListener('click', function() {
1330
  let currentQuantity = parseInt(softDrinkQuantityInput.value);
1331
  if (currentQuantity > 1) {
 
1333
  softDrinkQuantityInput.value = currentQuantity;
1334
  }
1335
  });
 
1336
  softDrinkIncreaseBtn.addEventListener('click', function() {
1337
  let currentQuantity = parseInt(softDrinkQuantityInput.value);
1338
  if (currentQuantity < 10) {
 
1518
  .then(data => {
1519
  if (data.success) {
1520
  alert('Item added to cart successfully!');
1521
+ updateCartUI(data.cart || getCartLocalStorage());
1522
  const modal = document.getElementById('itemModal');
1523
  const modalInstance = bootstrap.Modal.getInstance(modal);
1524
  modalInstance.hide();
1525
  } else {
1526
  console.error('Failed to add item to cart:', data.error);
1527
  alert(data.error || 'Failed to add item to cart.');
1528
+ const cart = addToCartLocalStorage(cartPayload);
1529
+ updateCartUI(cart);
1530
+ const modal = document.getElementById('itemModal');
1531
+ const modalInstance = bootstrap.Modal.getInstance(modal);
1532
+ modalInstance.hide();
1533
  }
1534
  })
1535
  .catch(err => {