lokeshloki143 commited on
Commit
6e8d0a8
·
verified ·
1 Parent(s): 76f3266

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +230 -270
templates/menu.html CHANGED
@@ -165,68 +165,46 @@
165
  color: white;
166
  font-size: 20px;
167
  font-weight: bold;
168
- transition: transform 0.2s ease, box-shadow 0.2s ease;
169
  }
170
  .avatar-icon:hover {
171
  transform: scale(1.1);
172
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
173
  }
174
  .dropdown-menu {
175
  position: absolute;
176
  right: 0;
177
  top: 100%;
178
- background: linear-gradient(135deg, #ffffff, #f8f9fa);
179
- border-radius: 12px;
180
  width: 240px;
181
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
182
  display: none;
183
- border: 1px solid rgba(0, 0, 0, 0.05);
184
- padding: 12px 0;
185
- animation: slideDown 0.3s ease-out;
186
  z-index: 1000;
187
- font-family: 'Segoe UI', Arial, sans-serif;
188
- }
189
- .dropdown-menu.show {
190
- display: block;
191
  }
192
  .dropdown-menu .dropdown-item {
193
- padding: 12px 18px;
194
  text-decoration: none;
195
- color: #2c3e50;
196
  display: flex;
197
  align-items: center;
198
  font-size: 15px;
199
- font-weight: 500;
200
- transition: all 0.2s ease;
201
- border-radius: 8px;
202
- margin: 0 8px;
203
  }
204
  .dropdown-menu .dropdown-item i {
205
- margin-right: 12px;
206
  font-size: 18px;
207
- color: #0FAA39;
208
- transition: color 0.2s ease;
209
  }
210
  .dropdown-menu .dropdown-item:hover {
211
- background-color: #e6f4ea;
212
- color: #0FAA39;
213
  transform: translateX(5px);
214
  }
215
- .dropdown-menu .dropdown-item:hover i {
216
- color: #0D9232;
217
- }
218
- .dropdown-menu .dropdown-item:active {
219
- background-color: #d1e7dd;
220
- }
221
- @keyframes slideDown {
222
- from {
223
- opacity: 0;
224
- transform: translateY(-15px);
225
- }
226
- to {
227
- opacity: 1;
228
- transform: translateY(0);
229
- }
230
  }
231
  .fixed-top-bar {
232
  position: relative;
@@ -898,6 +876,7 @@
898
  border-radius: 8px;
899
  font-weight: bold;
900
  font-size: 16px;
 
901
  display: flex;
902
  align-items: center;
903
  justify-content: center;
@@ -908,22 +887,20 @@
908
  .bottom-action-bar .btn-order-history {
909
  background: linear-gradient(45deg, #FF8C00, #32CD32);
910
  border-color: transparent;
911
- color: #000000;
912
  }
913
  .bottom-action-bar .btn-order-history:hover {
914
  background: linear-gradient(45deg, #FF4500, #228B22);
915
  border-color: transparent;
916
- color: #000000;
917
  }
918
  .bottom-action-bar .btn-view-cart {
919
  background-color: #0FAA39;
920
  border-color: #0FAA39;
921
- color: white;
922
  }
923
  .bottom-action-bar .btn-view-cart:hover {
924
  background-color: #0D9232;
925
  border-color: #0D9232;
926
- color: white;
927
  }
928
  .cart-icon-badge {
929
  background-color: white;
@@ -972,17 +949,11 @@
972
  font-size: 20px;
973
  }
974
  .dropdown-menu {
975
- width: 200px;
976
- border-radius: 8px;
977
- padding: 8px 0;
978
  }
979
  .dropdown-menu .dropdown-item {
980
- padding: 8px 12px;
981
- font-size: 13px;
982
- }
983
- .dropdown-menu .dropdown-item i {
984
- font-size: 14px;
985
- margin-right: 8px;
986
  }
987
  .modal-dialog {
988
  max-width: 90%;
@@ -1004,19 +975,7 @@
1004
  max-width: 150px;
1005
  margin: 0 auto 8px;
1006
  display: block;
1007
- }
1008
- .modal-body #modal-name {
1009
- font-size: 18px;
1010
- margin-bottom: 5px;
1011
- }
1012
- .modal-body #modal-price {
1013
- font-size: 14px;
1014
- margin-bottom: 8px;
1015
- }
1016
- .modal-body #modal-description {
1017
- font-size: 12px;
1018
- margin-bottom: 10px;
1019
- }
1020
  .modal-body .nutritional-info {
1021
  font-size: 10px;
1022
  margin-bottom: 5px;
@@ -1237,43 +1196,6 @@
1237
  font-size: 0.9rem;
1238
  }
1239
  }
1240
- .autocomplete-suggestions {
1241
- position: absolute;
1242
- top: 100%;
1243
- left: 0;
1244
- right: 0;
1245
- background-color: #fff;
1246
- border: 1px solid #ced4da;
1247
- border-radius: 4px;
1248
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
1249
- max-height: 150px;
1250
- overflow-y: auto;
1251
- z-index: 1000;
1252
- display: none;
1253
- }
1254
- .autocomplete-suggestion {
1255
- padding: 8px 12px;
1256
- cursor: pointer;
1257
- font-size: 0.9rem;
1258
- color: #333;
1259
- transition: background-color 0.2s ease;
1260
- }
1261
- .autocomplete-suggestion:hover {
1262
- background-color: #e6f4ea;
1263
- }
1264
- .autocomplete-suggestions::-webkit-scrollbar {
1265
- width: 6px;
1266
- }
1267
- .autocomplete-suggestions::-webkit-scrollbar-track {
1268
- background: #f1f1f1;
1269
- }
1270
- .autocomplete-suggestions::-webkit-scrollbar-thumb {
1271
- background: #0FAA39;
1272
- border-radius: 10px;
1273
- }
1274
- .autocomplete-suggestions::-webkit-scrollbar-thumb:hover {
1275
- background: #0D9232;
1276
- }
1277
  </style>
1278
  </head>
1279
  <body>
@@ -1283,10 +1205,10 @@
1283
  <span>{{ first_letter }}</span>
1284
  </div>
1285
  <div class="dropdown-menu">
1286
- <a href="{{ url_for('user_details.customer_details') }}" class="dropdown-item"><i class="bi bi-person"></i>View Profile</a>
1287
- <a href="{{ url_for('orderhistory.order_history') }}" class="dropdown-item"><i class="bi bi-clock-history"></i>Order History</a>
1288
- <a href="{{ url_for('combined_summary.combined_summary') }}" class="dropdown-item"><i class="bi bi-bar-chart"></i>MY Summary</a>
1289
- <a href="{{ url_for('logout') }}" class="dropdown-item"><i class="bi bi-box-arrow-right"></i>Logout</a>
1290
  </div>
1291
  </div>
1292
  <div class="search-bar-container">
@@ -1493,7 +1415,7 @@
1493
 
1494
  <!-- Microphone Modal -->
1495
  <div class="modal fade" id="micModal" tabindex="-1" aria-labelledby="micModalLabel" aria-hidden="true">
1496
- <div class="modal-dialog modal-dialog-centered">
1497
  <div class="modal-content">
1498
  <div class="modal-header">
1499
  <h5 class="modal-title" id="micModalLabel">Speak Now</h5>
@@ -1905,84 +1827,114 @@
1905
  const dropdownMenu = document.querySelector('.dropdown-menu');
1906
  avatarContainer.addEventListener('click', function (event) {
1907
  event.stopPropagation();
1908
- dropdownMenu.classList.toggle('show');
1909
  });
1910
  document.addEventListener('click', function (event) {
1911
  if (!avatarContainer.contains(event.target)) {
1912
- dropdownMenu.classList.remove('show');
1913
  }
1914
  });
1915
  const dropdownItems = document.querySelectorAll('.dropdown-item');
1916
  dropdownItems.forEach(item => {
1917
  item.addEventListener('click', function () {
1918
- dropdownMenu.classList.remove('show');
1919
- });
1920
  });
1921
-
1922
- // Search functionality
1923
  const searchBar = document.getElementById('searchBar');
1924
- searchBar.addEventListener('input', debounce(() => {
1925
- const query = searchBar.value.toLowerCase();
1926
- document.querySelectorAll('.menu-card').forEach(card => {
1927
- const itemName = card.getAttribute('data-item-name').toLowerCase();
1928
- const section = card.getAttribute('data-item-section').toLowerCase();
1929
- if (itemName.includes(query) || section.includes(query)) {
1930
- card.style.display = 'block';
1931
- } else {
1932
- card.style.display = 'none';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1933
  }
1934
- });
1935
- }, 300));
 
 
 
 
1936
 
1937
- // Enhanced video hover handling for desktop and touch for mobile
1938
- document.querySelectorAll('.media-wrapper').forEach(wrapper => {
 
1939
  const video = wrapper.querySelector('.menu-video');
1940
  const image = wrapper.querySelector('.menu-image');
1941
 
1942
- // Desktop hover events
1943
  wrapper.addEventListener('mouseenter', () => {
1944
- image.classList.add('hidden');
1945
- video.classList.add('active');
1946
- video.play().catch(err => {
1947
- console.error('Video playback failed:', err);
1948
- image.classList.remove('hidden');
1949
- video.classList.remove('active');
1950
- });
 
 
1951
  });
 
1952
  wrapper.addEventListener('mouseleave', () => {
1953
- video.classList.remove('active');
1954
- video.pause();
1955
- video.currentTime = 0;
1956
- image.classList.remove('hidden');
 
 
1957
  });
1958
 
1959
- // Mobile touch events
1960
- let touchTimeout;
1961
  wrapper.addEventListener('touchstart', (e) => {
1962
  e.preventDefault();
1963
  wrapper.classList.add('touched');
1964
  image.classList.add('hidden');
1965
  video.classList.add('active');
1966
  video.play().catch(err => {
1967
- console.error('Video playback failed:', err);
1968
- image.classList.remove('hidden');
1969
- video.classList.remove('active');
1970
- });
1971
- touchTimeout = setTimeout(() => {
1972
- video.pause();
1973
  video.classList.remove('active');
1974
  image.classList.remove('hidden');
1975
- wrapper.classList.remove('touched');
1976
- }, 3000);
1977
  });
 
1978
  wrapper.addEventListener('touchend', () => {
1979
- clearTimeout(touchTimeout);
1980
- setTimeout(() => {
1981
- video.pause();
1982
- video.classList.remove('active');
1983
- image.classList.remove('hidden');
1984
- wrapper.classList.remove('touched');
1985
- }, 500);
1986
  });
1987
  });
1988
 
@@ -1992,27 +1944,27 @@
1992
  const quantityInput = document.getElementById('quantityInput');
1993
 
1994
  decreaseBtn.addEventListener('click', () => {
1995
- let value = parseInt(quantityInput.value) || 1;
1996
- if (value > 1) {
1997
- quantityInput.value = value - 1;
 
1998
  }
1999
  });
2000
 
2001
  increaseBtn.addEventListener('click', () => {
2002
- let value = parseInt(quantityInput.value) || 1;
2003
- quantityInput.value = value + 1;
 
2004
  });
2005
 
2006
  // Toggle item details
2007
- document.querySelectorAll('.toggle-details').forEach(link => {
2008
- link.addEventListener('click', () => {
2009
- const details = link.nextElementSibling;
2010
- if (details.classList.contains('show')) {
2011
- details.classList.remove('show');
2012
- link.textContent = 'Show Details';
2013
- } else {
2014
- details.classList.add('show');
2015
- link.textContent = 'Hide Details';
2016
  }
2017
  });
2018
  });
@@ -2032,88 +1984,101 @@
2032
  updateCartUI(getCartLocalStorage());
2033
  });
2034
 
2035
- // Enhanced speech recognition setup
2036
- if ('webkitSpeechRecognition' in window) {
2037
- recognition = new webkitSpeechRecognition();
2038
- recognition.continuous = false;
2039
- recognition.interimResults = false;
2040
- recognition.lang = 'en-US';
 
 
 
2041
 
2042
- recognition.onstart = () => {
2043
- document.getElementById('micIcon').classList.add('active');
2044
- document.getElementById('mic-status').textContent = 'Listening...';
2045
- };
 
 
2046
 
2047
- recognition.onresult = (event) => {
2048
- const transcript = event.results[0][0].transcript.trim().toLowerCase();
2049
- console.log('Recognized speech:', transcript);
2050
- const matchedItem = menuItems.find(item =>
2051
- item.name.toLowerCase().includes(transcript)
2052
- );
2053
 
2054
- if (matchedItem) {
2055
- // Show item details in mic modal
2056
- document.getElementById('mic-status').style.display = 'none';
2057
- document.getElementById('mic-item-details').style.display = 'block';
2058
- document.getElementById('mic-item-name').textContent = matchedItem.name;
2059
- document.getElementById('mic-item-image').src = matchedItem.image;
 
2060
 
2061
- // Stop recognition and hide modal after 2 seconds
2062
- recognition.stop();
2063
- setTimeout(() => {
2064
- const micModal = bootstrap.Modal.getInstance(document.getElementById('micModal'));
2065
- micModal.hide();
2066
- resetMicModal();
 
 
 
 
 
2067
 
2068
- // Navigate to the matched item
2069
- const card = document.querySelector(`.menu-card[data-item-name="${matchedItem.name}"]`);
2070
- if (card) {
2071
- card.classList.add('highlighted');
2072
- card.scrollIntoView({ behavior: 'smooth', block: 'center' });
2073
- setTimeout(() => card.classList.remove('highlighted'), 3000);
2074
- const buttonContainer = card.querySelector('.button-container');
2075
- if (buttonContainer) {
2076
- if (matchedItem.section === 'Soft Drinks') {
2077
- showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
2078
- } else {
2079
- showItemDetails(
2080
- buttonContainer.getAttribute('data-item-name'),
2081
- buttonContainer.getAttribute('data-item-price'),
2082
- buttonContainer.getAttribute('data-item-image2'),
2083
- buttonContainer.getAttribute('data-item-description'),
2084
- matchedItem.section,
2085
- buttonContainer.getAttribute('data-item-category')
2086
- );
2087
- const modal = new bootstrap.Modal(document.getElementById('itemModal'));
2088
- modal.show();
2089
  }
2090
  }
2091
- }
2092
- }, 2000);
2093
- } else {
2094
- document.getElementById('mic-status').textContent = 'Item not found. Try again.';
2095
- }
2096
- };
2097
 
2098
- recognition.onerror = (event) => {
2099
- console.error('Speech recognition error:', event.error);
2100
- document.getElementById('mic-status').textContent = 'Error occurred. Please try again.';
2101
- document.getElementById('micIcon').classList.remove('active');
2102
- };
2103
 
2104
- recognition.onend = () => {
2105
- document.getElementById('micIcon').classList.remove('active');
2106
- };
 
 
 
 
 
 
 
 
 
2107
 
2108
- document.getElementById('micIcon').addEventListener('click', () => {
2109
- if (!recognition) return;
2110
- const micModal = new bootstrap.Modal(document.getElementById('micModal'));
2111
- micModal.show();
2112
- resetMicModal();
2113
  recognition.start();
2114
- });
2115
- } else {
2116
- document.getElementById('micIcon').style.display = 'none';
2117
  }
2118
 
2119
  // Autocomplete for custom dish description
@@ -2121,45 +2086,41 @@
2121
  const suggestionsContainer = document.getElementById('descriptionSuggestions');
2122
 
2123
  if (descriptionInput && suggestionsContainer) {
2124
- descriptionInput.addEventListener('input', debounce(() => {
2125
- const query = descriptionInput.value.toLowerCase();
2126
  suggestionsContainer.innerHTML = '';
2127
 
2128
- if (query.length < 2) {
2129
- suggestionsContainer.style.display = 'none';
2130
- return;
2131
- }
2132
 
2133
- const filteredIngredients = ingredientsList.filter(ingredient =>
2134
- ingredient.toLowerCase().includes(query)
2135
- );
 
 
 
 
 
2136
 
2137
- if (filteredIngredients.length === 0) {
2138
- suggestionsContainer.style.display = 'none';
2139
- return;
2140
- }
2141
 
2142
- filteredIngredients.forEach(ingredient => {
2143
- const suggestionItem = document.createElement('div');
2144
- suggestionItem.classList.add('autocomplete-suggestion');
2145
- suggestionItem.textContent = ingredient;
2146
- suggestionItem.addEventListener('click', () => {
2147
- const currentValue = descriptionInput.value;
2148
- const words = currentValue.split(' ');
2149
- words[words.length - 1] = ingredient;
2150
- descriptionInput.value = words.join(' ') + ' ';
2151
- suggestionsContainer.innerHTML = '';
2152
- suggestionsContainer.style.display = 'none';
2153
- descriptionInput.focus();
2154
  });
2155
- suggestionsContainer.appendChild(suggestionItem);
2156
- });
2157
 
2158
- suggestionsContainer.style.display = 'block';
 
 
 
2159
  }, 300));
2160
 
2161
- document.addEventListener('click', (event) => {
2162
- if (!descriptionInput.contains(event.target) && !suggestionsContainer.contains(event.target)) {
 
2163
  suggestionsContainer.style.display = 'none';
2164
  }
2165
  });
@@ -2167,5 +2128,4 @@
2167
  });
2168
  </script>
2169
  </body>
2170
- </html>
2171
- </xaiArtifact>
 
165
  color: white;
166
  font-size: 20px;
167
  font-weight: bold;
168
+ transition: transform 0.3s ease;
169
  }
170
  .avatar-icon:hover {
171
  transform: scale(1.1);
 
172
  }
173
  .dropdown-menu {
174
  position: absolute;
175
  right: 0;
176
  top: 100%;
177
+ background: linear-gradient(135deg, #fff, #f5f5f5);
178
+ border-radius: 10px;
179
  width: 240px;
180
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
181
  display: none;
182
+ border: none;
183
+ padding: 10px 0;
 
184
  z-index: 1000;
185
+ overflow: hidden;
 
 
 
186
  }
187
  .dropdown-menu .dropdown-item {
188
+ padding: 12px 20px;
189
  text-decoration: none;
190
+ color: #333;
191
  display: flex;
192
  align-items: center;
193
  font-size: 15px;
194
+ transition: all 0.3s ease;
 
 
 
195
  }
196
  .dropdown-menu .dropdown-item i {
197
+ margin-right: 10px;
198
  font-size: 18px;
199
+ color: #FF4500;
 
200
  }
201
  .dropdown-menu .dropdown-item:hover {
202
+ background: linear-gradient(45deg, #FFE4B5, #FFDAB9);
203
+ color: #000;
204
  transform: translateX(5px);
205
  }
206
+ .dropdown-menu .dropdown-item:last-child {
207
+ border-bottom: none;
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  }
209
  .fixed-top-bar {
210
  position: relative;
 
876
  border-radius: 8px;
877
  font-weight: bold;
878
  font-size: 16px;
879
+ color: white;
880
  display: flex;
881
  align-items: center;
882
  justify-content: center;
 
887
  .bottom-action-bar .btn-order-history {
888
  background: linear-gradient(45deg, #FF8C00, #32CD32);
889
  border-color: transparent;
890
+ color: #ffffff;
891
  }
892
  .bottom-action-bar .btn-order-history:hover {
893
  background: linear-gradient(45deg, #FF4500, #228B22);
894
  border-color: transparent;
895
+ color: #ffffff;
896
  }
897
  .bottom-action-bar .btn-view-cart {
898
  background-color: #0FAA39;
899
  border-color: #0FAA39;
 
900
  }
901
  .bottom-action-bar .btn-view-cart:hover {
902
  background-color: #0D9232;
903
  border-color: #0D9232;
 
904
  }
905
  .cart-icon-badge {
906
  background-color: white;
 
949
  font-size: 20px;
950
  }
951
  .dropdown-menu {
952
+ width: 220px;
 
 
953
  }
954
  .dropdown-menu .dropdown-item {
955
+ padding: 12px 16px;
956
+ font-size: 15px;
 
 
 
 
957
  }
958
  .modal-dialog {
959
  max-width: 90%;
 
975
  max-width: 150px;
976
  margin: 0 auto 8px;
977
  display: block;
978
+ Roborock Q7 Max Ultra Robot Vacuum Cleaner
 
 
 
 
 
 
 
 
 
 
 
 
979
  .modal-body .nutritional-info {
980
  font-size: 10px;
981
  margin-bottom: 5px;
 
1196
  font-size: 0.9rem;
1197
  }
1198
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1199
  </style>
1200
  </head>
1201
  <body>
 
1205
  <span>{{ first_letter }}</span>
1206
  </div>
1207
  <div class="dropdown-menu">
1208
+ <a href="{{ url_for('user_details.customer_details') }}" class="dropdown-item"><i class="bi bi-person"></i> View Profile</a>
1209
+ <a href="{{ url_for('orderhistory.order_history') }}" class="dropdown-item"><i class="bi bi-clock-history"></i> Order History</a>
1210
+ <a href="{{ url_for('combined_summary.combined_summary') }}" class="dropdown-item"><i class="bi bi-file-earmark-text"></i> MY Summary</a>
1211
+ <a href="{{ url_for('logout') }}" class="dropdown-item"><i class="bi bi-box-arrow-right"></i> Logout</a>
1212
  </div>
1213
  </div>
1214
  <div class="search-bar-container">
 
1415
 
1416
  <!-- Microphone Modal -->
1417
  <div class="modal fade" id="micModal" tabindex="-1" aria-labelledby="micModalLabel" aria-hidden="true">
1418
+ <div class = "modal-dialog modal-dialog-centered">
1419
  <div class="modal-content">
1420
  <div class="modal-header">
1421
  <h5 class="modal-title" id="micModalLabel">Speak Now</h5>
 
1827
  const dropdownMenu = document.querySelector('.dropdown-menu');
1828
  avatarContainer.addEventListener('click', function (event) {
1829
  event.stopPropagation();
1830
+ dropdownMenu.style.display = dropdownMenu.style.display === 'block' ? 'none' : 'block';
1831
  });
1832
  document.addEventListener('click', function (event) {
1833
  if (!avatarContainer.contains(event.target)) {
1834
+ dropdownMenu.style.display = 'none';
1835
  }
1836
  });
1837
  const dropdownItems = document.querySelectorAll('.dropdown-item');
1838
  dropdownItems.forEach(item => {
1839
  item.addEventListener('click', function () {
1840
+ dropdownMenu.style.display = 'none';
1841
+ });
1842
  });
 
 
1843
  const searchBar = document.getElementById('searchBar');
1844
+ searchBar.addEventListener('click', function () {
1845
+ window.location.href = '/search';
1846
+ });
1847
+ const selectedItem = localStorage.getItem('selectedItem');
1848
+ if (selectedItem) {
1849
+ try {
1850
+ const { name, section } = JSON.parse(selectedItem);
1851
+ const menuCards = document.querySelectorAll('.menu-card');
1852
+ let targetCard = null;
1853
+ let buttonContainer = null;
1854
+ menuCards.forEach(card => {
1855
+ const itemName = card.getAttribute('data-item-name');
1856
+ const itemSection = card.getAttribute('data-item-section');
1857
+ if (itemName === name && itemSection === section) {
1858
+ targetCard = card;
1859
+ buttonContainer = card.querySelector('.button-container');
1860
+ card.classList.add('highlighted');
1861
+ card.scrollIntoView({ behavior: 'smooth', block: 'center' });
1862
+ const toggleLink = card.querySelector('.toggle-details');
1863
+ if (toggleLink) {
1864
+ toggleLink.click();
1865
+ }
1866
+ }
1867
+ });
1868
+ if (targetCard && buttonContainer) {
1869
+ const name = buttonContainer.getAttribute('data-item-name');
1870
+ const price = buttonContainer.getAttribute('data-item-price');
1871
+ const image = buttonContainer.getAttribute('data-item-image2');
1872
+ const description = buttonContainer.getAttribute('data-item-description');
1873
+ const category = buttonContainer.getAttribute('data-item-category');
1874
+ setTimeout(() => {
1875
+ if (section === 'Soft Drinks') {
1876
+ showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
1877
+ } else {
1878
+ showItemDetails(name, price, image, description, section, category);
1879
+ const modal = new bootstrap.Modal(document.getElementById('itemModal'));
1880
+ modal.show();
1881
+ }
1882
+ }, 1000);
1883
  }
1884
+ } catch (e) {
1885
+ console.error('Error parsing selectedItem:', e);
1886
+ } finally {
1887
+ localStorage.removeItem('selectedItem');
1888
+ }
1889
+ }
1890
 
1891
+ // Image-to-Video hover/touch functionality
1892
+ const mediaWrappers = document.querySelectorAll('.media-wrapper');
1893
+ mediaWrappers.forEach(wrapper => {
1894
  const video = wrapper.querySelector('.menu-video');
1895
  const image = wrapper.querySelector('.menu-image');
1896
 
1897
+ // Hover events for desktop
1898
  wrapper.addEventListener('mouseenter', () => {
1899
+ if (window.innerWidth > 576) { // Only for non-mobile devices
1900
+ image.classList.add('hidden');
1901
+ video.classList.add('active');
1902
+ video.play().catch(err => {
1903
+ console.error('Video play error:', err);
1904
+ video.classList.remove('active');
1905
+ image.classList.remove('hidden');
1906
+ });
1907
+ }
1908
  });
1909
+
1910
  wrapper.addEventListener('mouseleave', () => {
1911
+ if (window.innerWidth > 576) { // Only for non-mobile devices
1912
+ video.classList.remove('active');
1913
+ image.classList.remove('hidden');
1914
+ video.pause();
1915
+ video.currentTime = 0;
1916
+ }
1917
  });
1918
 
1919
+ // Touch events for mobile
 
1920
  wrapper.addEventListener('touchstart', (e) => {
1921
  e.preventDefault();
1922
  wrapper.classList.add('touched');
1923
  image.classList.add('hidden');
1924
  video.classList.add('active');
1925
  video.play().catch(err => {
1926
+ console.error('Video play error:', err);
 
 
 
 
 
1927
  video.classList.remove('active');
1928
  image.classList.remove('hidden');
1929
+ });
 
1930
  });
1931
+
1932
  wrapper.addEventListener('touchend', () => {
1933
+ wrapper.classList.remove('touched');
1934
+ video.classList.remove('active');
1935
+ image.classList.remove(''hidden');
1936
+ video.pause();
1937
+ video.currentTime = 0;
 
 
1938
  });
1939
  });
1940
 
 
1944
  const quantityInput = document.getElementById('quantityInput');
1945
 
1946
  decreaseBtn.addEventListener('click', () => {
1947
+ let currentValue = parseInt(quantityInput.value) || 1;
1948
+ if (currentValue > 1) {
1949
+ quantityInput.value = currentValue - 1;
1950
+ updateModalPrice();
1951
  }
1952
  });
1953
 
1954
  increaseBtn.addEventListener('click', () => {
1955
+ let currentValue = parseInt(quantityInput.value) || 1;
1956
+ quantityInput.value = currentValue + 1;
1957
+ updateModalPrice();
1958
  });
1959
 
1960
  // Toggle item details
1961
+ document.querySelectorAll('.toggle-details').forEach(toggle => {
1962
+ toggle.addEventListener('click', () => {
1963
+ const itemName = toggle.getAttribute('data-item-name').replace(/\s+/g, '-');
1964
+ const details = document.getElementById(`details-${itemName}`);
1965
+ if (details) {
1966
+ details.classList.toggle('show');
1967
+ toggle.textContent = details.classList.contains('show') ? 'Hide Details' : 'Show Details';
 
 
1968
  }
1969
  });
1970
  });
 
1984
  updateCartUI(getCartLocalStorage());
1985
  });
1986
 
1987
+ // Speech recognition setup
1988
+ const micIcon = document.getElementById('micIcon');
1989
+ micIcon.addEventListener('click', () => {
1990
+ if (!recognition || !recognition.running) {
1991
+ startSpeechRecognition();
1992
+ } else {
1993
+ stopSpeechRecognition();
1994
+ }
1995
+ });
1996
 
1997
+ function startSpeechRecognition() {
1998
+ if ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) {
1999
+ recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
2000
+ recognition.lang = 'en-US';
2001
+ recognition.interimResults = false;
2002
+ recognition.maxAlternatives = 1;
2003
 
2004
+ recognition.onstart = () => {
2005
+ micIcon.classList.add('active');
2006
+ document.getElementById('mic-status').textContent = 'Listening...';
2007
+ const micModal = new bootstrap.Modal(document.getElementById('micModal'));
2008
+ micModal.show();
2009
+ };
2010
 
2011
+ recognition.onresult = (event) => {
2012
+ const transcript = event.results[0][0].transcript.trim().toLowerCase();
2013
+ document.getElementById('mic-status').textContent = `Heard: "${transcript}"`;
2014
+ const matchedItem = menuItems.find(item =>
2015
+ item.name.toLowerCase().includes(transcript) ||
2016
+ item.section.toLowerCase().includes(transcript)
2017
+ );
2018
 
2019
+ if (matchedItem) {
2020
+ recognition.stop();
2021
+ document.getElementById('mic-status').style.display = 'none';
2022
+ document.getElementById('mic-item-details').style.display = 'block';
2023
+ document.getElementById('mic-item-name').textContent = matchedItem.name;
2024
+ document.getElementById('mic-item-image').src = matchedItem.image || '/static/placeholder.jpg';
2025
+
2026
+ setTimeout(() => {
2027
+ const micModal = bootstrap.Modal.getInstance(document.getElementById('micModal'));
2028
+ micModal.hide();
2029
+ resetMicModal();
2030
 
2031
+ const menuCard = document.querySelector(`.menu-card[data-item-name="${matchedItem.name}"]`);
2032
+ if (menuCard) {
2033
+ menuCard.classList.add('highlighted');
2034
+ menuCard.scrollIntoView({ behavior: 'smooth', block: 'center' });
2035
+ const buttonContainer = menuCard.querySelector('.button-container');
2036
+ if (buttonContainer) {
2037
+ const name = buttonContainer.getAttribute('data-item-name');
2038
+ const price = buttonContainer.getAttribute('data-item-price');
2039
+ const image = buttonContainer.getAttribute('data-item-image2');
2040
+ const description = buttonContainer.getAttribute('data-item-description');
2041
+ const section = buttonContainer.getAttribute('data-item-section');
2042
+ const category = buttonContainer.getAttribute('data-item-category');
2043
+
2044
+ if (section === 'Soft Drinks') {
2045
+ showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
2046
+ } else {
2047
+ showItemDetails(name, price, image, description, section, category);
2048
+ const modal = new bootstrap.Modal(document.getElementById('itemModal'));
2049
+ modal.show();
2050
+ }
 
2051
  }
2052
  }
2053
+ }, 2000);
2054
+ } else {
2055
+ document.getElementById('mic-status').textContent = 'No matching item found. Try again.';
2056
+ }
2057
+ };
 
2058
 
2059
+ recognition.onerror = (event) => {
2060
+ console.error('Speech recognition error:', event.error);
2061
+ document.getElementById('mic-status').textContent = 'Error occurred. Please try again.';
2062
+ stopSpeechRecognition();
2063
+ };
2064
 
2065
+ recognition.onend = () => {
2066
+ micIcon.classList.remove('active');
2067
+ if (document.getElementById('mic-item-details').style.display !== 'block') {
2068
+ setTimeout(() => {
2069
+ const micModal = bootstrap.Modal.getInstance(document.getElementById('micModal'));
2070
+ if (micModal) {
2071
+ micModal.hide();
2072
+ resetMicModal();
2073
+ }
2074
+ }, 1000);
2075
+ }
2076
+ };
2077
 
 
 
 
 
 
2078
  recognition.start();
2079
+ } else {
2080
+ alert('Speech recognition is not supported in this browser.');
2081
+ }
2082
  }
2083
 
2084
  // Autocomplete for custom dish description
 
2086
  const suggestionsContainer = document.getElementById('descriptionSuggestions');
2087
 
2088
  if (descriptionInput && suggestionsContainer) {
2089
+ descriptionInput.addEventListener('input', debounce(function () {
2090
+ const query = this.value.trim();
2091
  suggestionsContainer.innerHTML = '';
2092
 
2093
+ if (query.length > 2) {
2094
+ const filteredIngredients = ingredientsList.filter(ingredient =>
2095
+ ingredient.toLowerCase().includes(query.toLowerCase())
2096
+ );
2097
 
2098
+ filteredIngredients.forEach(ingredient => {
2099
+ const suggestionDiv = document.createElement('div');
2100
+ suggestionDiv.classList.add('suggestion-item');
2101
+ suggestionDiv.textContent = ingredient;
2102
+ suggestionDiv.style.padding = '8px';
2103
+ suggestionDiv.style.cursor = 'pointer';
2104
+ suggestionDiv.style.backgroundColor = '#fff';
2105
+ suggestionDiv.style.borderBottom = '1px solid #eee';
2106
 
2107
+ suggestionDiv.addEventListener('click', () => {
2108
+ descriptionInput.value = descriptionInput.value + ' ' + ingredient;
2109
+ suggestionsContainer.innerHTML = '';
2110
+ });
2111
 
2112
+ suggestionsContainer.appendChild(suggestionDiv);
 
 
 
 
 
 
 
 
 
 
 
2113
  });
 
 
2114
 
2115
+ suggestionsContainer.style.display = filteredIngredients.length > 0 ? 'block' : 'none';
2116
+ } else {
2117
+ suggestionsContainer.style.display = 'none';
2118
+ }
2119
  }, 300));
2120
 
2121
+ document.addEventListener('click', (e) => {
2122
+ if (!descriptionInput.contains(e.target) && !suggestionsContainer.contains(e.target)) {
2123
+ suggestionsContainer.innerHTML = '';
2124
  suggestionsContainer.style.display = 'none';
2125
  }
2126
  });
 
2128
  });
2129
  </script>
2130
  </body>
2131
+ </html>