lokeshloki143 commited on
Commit
c29e358
·
verified ·
1 Parent(s): ccfadf3

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +223 -166
templates/menu.html CHANGED
@@ -157,7 +157,7 @@
157
  width: 40px;
158
  height: 40px;
159
  border-radius: 50%;
160
- background-color: #007bff;
161
  cursor: pointer;
162
  display: flex;
163
  align-items: center;
@@ -165,33 +165,61 @@
165
  color: white;
166
  font-size: 20px;
167
  font-weight: bold;
 
 
 
 
 
168
  }
169
  .dropdown-menu {
170
  position: absolute;
171
  right: 0;
172
  top: 100%;
173
- background-color: #fff8f0;
174
- border-radius: 5px;
175
  width: 220px;
176
- box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
177
  display: none;
178
- border: 1px solid #ffd8b1;
 
 
 
 
 
 
 
179
  }
180
  .dropdown-menu .dropdown-item {
181
- padding: 12px 16px;
182
  text-decoration: none;
183
  color: #333;
184
- border-bottom: 1px solid #ffd8b1;
185
- display: block;
186
- font-size: 15px;
187
- transition: background-color 0.2s ease;
 
188
  }
189
- .dropdown-menu .dropdown-item:last-child {
190
- border-bottom: none;
 
 
191
  }
192
  .dropdown-menu .dropdown-item:hover {
193
- background-color: #ffe4c4;
194
- color: #333;
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  }
196
  .fixed-top-bar {
197
  position: relative;
@@ -863,7 +891,6 @@
863
  border-radius: 8px;
864
  font-weight: bold;
865
  font-size: 16px;
866
- color: white;
867
  display: flex;
868
  align-items: center;
869
  justify-content: center;
@@ -874,20 +901,22 @@
874
  .bottom-action-bar .btn-order-history {
875
  background: linear-gradient(45deg, #FF8C00, #32CD32);
876
  border-color: transparent;
877
- color: #ffffff;
878
  }
879
  .bottom-action-bar .btn-order-history:hover {
880
  background: linear-gradient(45deg, #FF4500, #228B22);
881
  border-color: transparent;
882
- color: #ffffff;
883
  }
884
  .bottom-action-bar .btn-view-cart {
885
  background-color: #0FAA39;
886
  border-color: #0FAA39;
 
887
  }
888
  .bottom-action-bar .btn-view-cart:hover {
889
  background-color: #0D9232;
890
  border-color: #0D9232;
 
891
  }
892
  .cart-icon-badge {
893
  background-color: white;
@@ -936,11 +965,17 @@
936
  font-size: 20px;
937
  }
938
  .dropdown-menu {
939
- width: 220px;
 
 
940
  }
941
  .dropdown-menu .dropdown-item {
942
- padding: 12px 16px;
943
- font-size: 15px;
 
 
 
 
944
  }
945
  .modal-dialog {
946
  max-width: 90%;
@@ -1204,10 +1239,10 @@
1204
  <span>{{ first_letter }}</span>
1205
  </div>
1206
  <div class="dropdown-menu">
1207
- <a href="{{ url_for('user_details.customer_details') }}" class="dropdown-item">View Profile</a>
1208
- <a href="{{ url_for('orderhistory.order_history') }}" class="dropdown-item">Order History</a>
1209
- <a href="{{ url_for('combined_summary.combined_summary') }}" class="dropdown-item">MY Summary</a>
1210
- <a href="{{ url_for('logout') }}" class="dropdown-item">Logout</a>
1211
  </div>
1212
  </div>
1213
  <div class="search-bar-container">
@@ -1826,17 +1861,17 @@
1826
  const dropdownMenu = document.querySelector('.dropdown-menu');
1827
  avatarContainer.addEventListener('click', function (event) {
1828
  event.stopPropagation();
1829
- dropdownMenu.style.display = dropdownMenu.style.display === 'block' ? 'none' : 'block';
1830
  });
1831
  document.addEventListener('click', function (event) {
1832
  if (!avatarContainer.contains(event.target)) {
1833
- dropdownMenu.style.display = 'none';
1834
  }
1835
  });
1836
  const dropdownItems = document.querySelectorAll('.dropdown-item');
1837
  dropdownItems.forEach(item => {
1838
  item.addEventListener('click', function () {
1839
- dropdownMenu.style.display = 'none';
1840
  });
1841
  });
1842
  const searchBar = document.getElementById('searchBar');
@@ -1896,58 +1931,47 @@
1896
  // Hover events for desktop
1897
  wrapper.addEventListener('mouseenter', () => {
1898
  image.classList.add('hidden');
1899
- video.classList.add('active');
1900
- video.play().catch(err => console.error('Video play error:', err));
 
 
 
 
1901
  });
1902
-
1903
  wrapper.addEventListener('mouseleave', () => {
1904
  video.classList.remove('active');
1905
- image.classList.remove('hidden');
1906
  video.pause();
1907
  video.currentTime = 0;
 
1908
  });
1909
 
1910
  // Touch events for mobile
 
1911
  wrapper.addEventListener('touchstart', (e) => {
1912
  e.preventDefault();
1913
  wrapper.classList.add('touched');
1914
  image.classList.add('hidden');
1915
  video.classList.add('active');
1916
- video.play().catch(err => console.error('Video play error:', err));
 
 
 
 
 
 
 
 
 
 
1917
  });
1918
-
1919
  wrapper.addEventListener('touchend', () => {
1920
- wrapper.classList.remove('touched');
1921
- video.classList.remove('active');
1922
- image.classList.remove('hidden');
1923
- video.pause();
1924
- video.currentTime = 0;
1925
- });
1926
- });
1927
-
1928
- // IntersectionObserver for lazy-loaded videos
1929
- const videoObserver = new IntersectionObserver((entries, observer) => {
1930
- entries.forEach(entry => {
1931
- if (entry.isIntersecting) {
1932
- const video = entry.target;
1933
- video.load();
1934
- observer.unobserve(video);
1935
- }
1936
- });
1937
- }, { threshold: 0.2 });
1938
-
1939
- document.querySelectorAll('.menu-video').forEach(video => {
1940
- videoObserver.observe(video);
1941
- });
1942
-
1943
- // Toggle item details
1944
- document.querySelectorAll('.toggle-details').forEach(toggle => {
1945
- toggle.addEventListener('click', function () {
1946
- const details = document.getElementById(`details-${this.getAttribute('data-item-name').replace(/\s+/g, '-')}`);
1947
- if (details) {
1948
- details.classList.toggle('show');
1949
- this.textContent = details.classList.contains('show') ? 'Hide Details' : 'Show Details';
1950
- }
1951
  });
1952
  });
1953
 
@@ -1960,112 +1984,107 @@
1960
  let value = parseInt(quantityInput.value) || 1;
1961
  if (value > 1) {
1962
  quantityInput.value = value - 1;
1963
- updateModalPrice();
1964
  }
1965
  });
1966
 
1967
  increaseBtn.addEventListener('click', () => {
1968
  let value = parseInt(quantityInput.value) || 1;
1969
  quantityInput.value = value + 1;
1970
- updateModalPrice();
1971
  });
1972
 
1973
- // Initialize cart UI from local storage
1974
- updateCartUI(getCartLocalStorage());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1975
 
1976
  // Speech recognition setup
1977
- if ('webkitSpeechRecognition' in window || 'SpeechRecognition' in window) {
1978
- const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
1979
- recognition = new SpeechRecognition();
1980
  recognition.continuous = false;
1981
- recognition.interimResults = true;
1982
  recognition.lang = 'en-US';
1983
 
1984
  recognition.onstart = () => {
 
1985
  document.getElementById('mic-status').textContent = 'Listening...';
1986
- document.getElementById('mic-icon-animation').classList.add('bi-mic-fill');
1987
- document.getElementById('mic-icon-animation').classList.remove('bi-mic');
1988
  };
1989
 
1990
  recognition.onresult = (event) => {
1991
- let interimTranscript = '';
1992
- let finalTranscript = '';
 
 
 
1993
 
1994
- for (let i = event.resultIndex; i < event.results.length; i++) {
1995
- const transcript = event.results[i][0].transcript;
1996
- if (event.results[i].isFinal) {
1997
- finalTranscript += transcript;
1998
- } else {
1999
- interimTranscript += transcript;
2000
- }
2001
- }
2002
-
2003
- document.getElementById('mic-status').textContent = interimTranscript || finalTranscript;
2004
-
2005
- if (finalTranscript) {
2006
- const spokenItem = menuItems.find(item =>
2007
- item.name.toLowerCase().includes(finalTranscript.toLowerCase())
2008
- );
2009
 
2010
- if (spokenItem) {
2011
- document.getElementById('mic-status').style.display = 'none';
2012
- document.getElementById('mic-item-details').style.display = 'block';
2013
- document.getElementById('mic-item-name').textContent = spokenItem.name;
2014
- document.getElementById('mic-item-image').src = spokenItem.image || '/static/placeholder.jpg';
2015
-
2016
- const menuCards = document.querySelectorAll('.menu-card');
2017
- let targetButton = null;
2018
- menuCards.forEach(card => {
2019
- if (card.getAttribute('data-item-name') === spokenItem.name &&
2020
- card.getAttribute('data-item-section') === spokenItem.section) {
2021
- targetButton = card.querySelector('.button-container');
 
 
 
 
 
 
 
2022
  }
2023
- });
2024
-
2025
- if (targetButton) {
2026
- const name = targetButton.getAttribute('data-item-name');
2027
- const price = targetButton.getAttribute('data-item-price');
2028
- const image = targetButton.getAttribute('data-item-image2');
2029
- const description = targetButton.getAttribute('data-item-description');
2030
- const section = targetButton.getAttribute('data-item-section');
2031
- const category = targetButton.getAttribute('data-item-category');
2032
-
2033
- setTimeout(() => {
2034
- recognition.stop();
2035
- const micModal = bootstrap.Modal.getInstance(document.getElementById('micModal'));
2036
- micModal.hide();
2037
-
2038
- if (section === 'Soft Drinks') {
2039
- showSoftDrinkModal(targetButton.querySelector('.add-to-cart-btn'));
2040
- } else {
2041
- showItemDetails(name, price, image, description, section, category);
2042
- const modal = new bootstrap.Modal(document.getElementById('itemModal'));
2043
- modal.show();
2044
- }
2045
- }, 500);
2046
  }
2047
  }
 
 
2048
  }
2049
  };
2050
 
2051
- recognition.onend = () => {
2052
- document.getElementById('mic-icon-animation').classList.remove('bi-mic-fill');
2053
- document.getElementById('mic-icon-animation').classList.add('bi-mic');
2054
- document.getElementById('micIcon').classList.remove('active');
2055
- };
2056
-
2057
  recognition.onerror = (event) => {
2058
  console.error('Speech recognition error:', event.error);
2059
  document.getElementById('mic-status').textContent = 'Error occurred. Please try again.';
2060
- setTimeout(() => {
2061
- stopSpeechRecognition();
2062
- }, 2000);
 
 
2063
  };
2064
 
2065
  document.getElementById('micIcon').addEventListener('click', () => {
2066
  if (!recognition) return;
2067
-
2068
- document.getElementById('micIcon').classList.add('active');
2069
  const micModal = new bootstrap.Modal(document.getElementById('micModal'));
2070
  micModal.show();
2071
  resetMicModal();
@@ -2073,7 +2092,6 @@
2073
  });
2074
  } else {
2075
  document.getElementById('micIcon').style.display = 'none';
2076
- console.warn('Speech recognition not supported in this browser.');
2077
  }
2078
 
2079
  // Autocomplete for custom dish description
@@ -2081,42 +2099,41 @@
2081
  const suggestionsContainer = document.getElementById('descriptionSuggestions');
2082
 
2083
  if (descriptionInput && suggestionsContainer) {
2084
- const showSuggestions = (suggestions) => {
 
2085
  suggestionsContainer.innerHTML = '';
2086
- if (suggestions.length === 0) {
 
2087
  suggestionsContainer.style.display = 'none';
2088
  return;
2089
  }
2090
- suggestions.forEach(suggestion => {
2091
- const div = document.createElement('div');
2092
- div.classList.add('suggestion-item');
2093
- div.textContent = suggestion;
2094
- div.addEventListener('click', () => {
2095
- descriptionInput.value = suggestion;
2096
- suggestionsContainer.style.display = 'none';
2097
- });
2098
- suggestionsContainer.appendChild(div);
2099
- });
2100
- suggestionsContainer.style.display = 'block';
2101
- };
2102
 
2103
- const filterSuggestions = (input) => {
2104
- const inputWords = input.toLowerCase().split(/\s+/);
2105
- return ingredientsList.filter(ingredient =>
2106
- inputWords.every(word =>
2107
- ingredient.toLowerCase().includes(word)
2108
- )
2109
- ).slice(0, 5);
2110
- };
2111
 
2112
- descriptionInput.addEventListener('input', debounce(() => {
2113
- const input = descriptionInput.value.trim();
2114
- if (input) {
2115
- const suggestions = filterSuggestions(input);
2116
- showSuggestions(suggestions);
2117
- } else {
2118
  suggestionsContainer.style.display = 'none';
 
2119
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2120
  }, 300));
2121
 
2122
  document.addEventListener('click', (event) => {
@@ -2127,5 +2144,45 @@
2127
  }
2128
  });
2129
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2130
  </body>
2131
  </html>
 
 
157
  width: 40px;
158
  height: 40px;
159
  border-radius: 50%;
160
+ background: linear-gradient(45deg, #FFA07A, #FFB347);
161
  cursor: pointer;
162
  display: flex;
163
  align-items: center;
 
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.2);
173
  }
174
  .dropdown-menu {
175
  position: absolute;
176
  right: 0;
177
  top: 100%;
178
+ background-color: #ffffff;
179
+ border-radius: 10px;
180
  width: 220px;
181
+ box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
182
  display: none;
183
+ border: none;
184
+ padding: 10px 0;
185
+ animation: slideDown 0.3s ease-out;
186
+ z-index: 1000;
187
+ overflow: hidden;
188
+ }
189
+ .dropdown-menu.show {
190
+ display: block;
191
  }
192
  .dropdown-menu .dropdown-item {
193
+ padding: 10px 15px;
194
  text-decoration: none;
195
  color: #333;
196
+ display: flex;
197
+ align-items: center;
198
+ font-size: 14px;
199
+ font-weight: 500;
200
+ transition: background-color 0.2s ease, color 0.2s ease;
201
  }
202
+ .dropdown-menu .dropdown-item i {
203
+ margin-right: 10px;
204
+ font-size: 16px;
205
+ color: #0FAA39;
206
  }
207
  .dropdown-menu .dropdown-item:hover {
208
+ background-color: #e6f4ea;
209
+ color: #0FAA39;
210
+ }
211
+ .dropdown-menu .dropdown-item:hover i {
212
+ color: #0D9232;
213
+ }
214
+ @keyframes slideDown {
215
+ from {
216
+ opacity: 0;
217
+ transform: translateY(-10px);
218
+ }
219
+ to {
220
+ opacity: 1;
221
+ transform: translateY(0);
222
+ }
223
  }
224
  .fixed-top-bar {
225
  position: relative;
 
891
  border-radius: 8px;
892
  font-weight: bold;
893
  font-size: 16px;
 
894
  display: flex;
895
  align-items: center;
896
  justify-content: center;
 
901
  .bottom-action-bar .btn-order-history {
902
  background: linear-gradient(45deg, #FF8C00, #32CD32);
903
  border-color: transparent;
904
+ color: #000000;
905
  }
906
  .bottom-action-bar .btn-order-history:hover {
907
  background: linear-gradient(45deg, #FF4500, #228B22);
908
  border-color: transparent;
909
+ color: #000000;
910
  }
911
  .bottom-action-bar .btn-view-cart {
912
  background-color: #0FAA39;
913
  border-color: #0FAA39;
914
+ color: white;
915
  }
916
  .bottom-action-bar .btn-view-cart:hover {
917
  background-color: #0D9232;
918
  border-color: #0D9232;
919
+ color: white;
920
  }
921
  .cart-icon-badge {
922
  background-color: white;
 
965
  font-size: 20px;
966
  }
967
  .dropdown-menu {
968
+ width: 200px;
969
+ border-radius: 8px;
970
+ padding: 8px 0;
971
  }
972
  .dropdown-menu .dropdown-item {
973
+ padding: 8px 12px;
974
+ font-size: 13px;
975
+ }
976
+ .dropdown-menu .dropdown-item i {
977
+ font-size: 14px;
978
+ margin-right: 8px;
979
  }
980
  .modal-dialog {
981
  max-width: 90%;
 
1239
  <span>{{ first_letter }}</span>
1240
  </div>
1241
  <div class="dropdown-menu">
1242
+ <a href="{{ url_for('user_details.customer_details') }}" class="dropdown-item"><i class="bi bi-person"></i>View Profile</a>
1243
+ <a href="{{ url_for('orderhistory.order_history') }}" class="dropdown-item"><i class="bi bi-clock-history"></i>Order History</a>
1244
+ <a href="{{ url_for('combined_summary.combined_summary') }}" class="dropdown-item"><i class="bi bi-bar-chart"></i>MY Summary</a>
1245
+ <a href="{{ url_for('logout') }}" class="dropdown-item"><i class="bi bi-box-arrow-right"></i>Logout</a>
1246
  </div>
1247
  </div>
1248
  <div class="search-bar-container">
 
1861
  const dropdownMenu = document.querySelector('.dropdown-menu');
1862
  avatarContainer.addEventListener('click', function (event) {
1863
  event.stopPropagation();
1864
+ dropdownMenu.classList.toggle('show');
1865
  });
1866
  document.addEventListener('click', function (event) {
1867
  if (!avatarContainer.contains(event.target)) {
1868
+ dropdownMenu.classList.remove('show');
1869
  }
1870
  });
1871
  const dropdownItems = document.querySelectorAll('.dropdown-item');
1872
  dropdownItems.forEach(item => {
1873
  item.addEventListener('click', function () {
1874
+ dropdownMenu.classList.remove('show');
1875
  });
1876
  });
1877
  const searchBar = document.getElementById('searchBar');
 
1931
  // Hover events for desktop
1932
  wrapper.addEventListener('mouseenter', () => {
1933
  image.classList.add('hidden');
1934
+ video.classList.add(' active');
1935
+ video.play().catch(err => {
1936
+ console.error('Video playback failed:', err);
1937
+ image.classList.remove('hidden');
1938
+ video.classList.remove('active');
1939
+ });
1940
  });
 
1941
  wrapper.addEventListener('mouseleave', () => {
1942
  video.classList.remove('active');
 
1943
  video.pause();
1944
  video.currentTime = 0;
1945
+ image.classList.remove('hidden');
1946
  });
1947
 
1948
  // Touch events for mobile
1949
+ let touchTimeout;
1950
  wrapper.addEventListener('touchstart', (e) => {
1951
  e.preventDefault();
1952
  wrapper.classList.add('touched');
1953
  image.classList.add('hidden');
1954
  video.classList.add('active');
1955
+ video.play().catch(err => {
1956
+ console.error('Video playback failed:', err);
1957
+ image.classList.remove('hidden');
1958
+ video.classList.remove('active');
1959
+ });
1960
+ touchTimeout = setTimeout(() => {
1961
+ video.pause();
1962
+ video.classList.remove('active');
1963
+ image.classList.remove('hidden');
1964
+ wrapper.classList.remove('touched');
1965
+ }, 3000);
1966
  });
 
1967
  wrapper.addEventListener('touchend', () => {
1968
+ clearTimeout(touchTimeout);
1969
+ setTimeout(() => {
1970
+ video.pause();
1971
+ video.classList.remove('active');
1972
+ image.classList.remove('hidden');
1973
+ wrapper.classList.remove('touched');
1974
+ }, 500);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1975
  });
1976
  });
1977
 
 
1984
  let value = parseInt(quantityInput.value) || 1;
1985
  if (value > 1) {
1986
  quantityInput.value = value - 1;
 
1987
  }
1988
  });
1989
 
1990
  increaseBtn.addEventListener('click', () => {
1991
  let value = parseInt(quantityInput.value) || 1;
1992
  quantityInput.value = value + 1;
 
1993
  });
1994
 
1995
+ // Toggle item details
1996
+ document.querySelectorAll('.toggle-details').forEach(link => {
1997
+ link.addEventListener('click', () => {
1998
+ const details = link.nextElementSibling;
1999
+ if (details.classList.contains('show')) {
2000
+ details.classList.remove('show');
2001
+ link.textContent = 'Show Details';
2002
+ } else {
2003
+ details.classList.add('show');
2004
+ link.textContent = 'Hide Details';
2005
+ }
2006
+ });
2007
+ });
2008
+
2009
+ // Initialize cart UI
2010
+ fetch('/cart')
2011
+ .then(response => response.json())
2012
+ .then(data => {
2013
+ if (data.success) {
2014
+ updateCartUI(data.cart);
2015
+ } else {
2016
+ updateCartUI(getCartLocalStorage());
2017
+ }
2018
+ })
2019
+ .catch(err => {
2020
+ console.error('Error fetching cart:', err);
2021
+ updateCartUI(getCartLocalStorage());
2022
+ });
2023
 
2024
  // Speech recognition setup
2025
+ if ('webkitSpeechRecognition' in window) {
2026
+ recognition = new webkitSpeechRecognition();
 
2027
  recognition.continuous = false;
2028
+ recognition.interimResults = false;
2029
  recognition.lang = 'en-US';
2030
 
2031
  recognition.onstart = () => {
2032
+ document.getElementById('micIcon').classList.add('active');
2033
  document.getElementById('mic-status').textContent = 'Listening...';
 
 
2034
  };
2035
 
2036
  recognition.onresult = (event) => {
2037
+ const transcript = event.results[0][0].transcript.trim().toLowerCase();
2038
+ console.log('Recognized speech:', transcript);
2039
+ const matchedItem = menuItems.find(item =>
2040
+ item.name.toLowerCase().includes(transcript)
2041
+ );
2042
 
2043
+ if (matchedItem) {
2044
+ document.getElementById('mic-status').style.display = 'none';
2045
+ document.getElementById('mic-item-details').style.display = 'block';
2046
+ document.getElementById('mic-item-name').textContent = matchedItem.name;
2047
+ document.getElementById('mic-item-image').src = matchedItem.image;
 
 
 
 
 
 
 
 
 
 
2048
 
2049
+ const card = document.querySelector(`.menu-card[data-item-name="${matchedItem.name}"]`);
2050
+ if (card) {
2051
+ card.classList.add('highlighted');
2052
+ card.scrollIntoView({ behavior: 'smooth', block: 'center' });
2053
+ const buttonContainer = card.querySelector('.button-container');
2054
+ if (buttonContainer) {
2055
+ if (matchedItem.section === 'Soft Drinks') {
2056
+ showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
2057
+ } else {
2058
+ showItemDetails(
2059
+ buttonContainer.getAttribute('data-item-name'),
2060
+ buttonContainer.getAttribute('data-item-price'),
2061
+ buttonContainer.getAttribute('data-item-image2'),
2062
+ buttonContainer.getAttribute('data-item-description'),
2063
+ matchedItem.section,
2064
+ buttonContainer.getAttribute('data-item-category')
2065
+ );
2066
+ const modal = new bootstrap.Modal(document.getElementById('itemModal'));
2067
+ modal.show();
2068
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2069
  }
2070
  }
2071
+ } else {
2072
+ document.getElementById('mic-status').textContent = 'Item not found. Try again.';
2073
  }
2074
  };
2075
 
 
 
 
 
 
 
2076
  recognition.onerror = (event) => {
2077
  console.error('Speech recognition error:', event.error);
2078
  document.getElementById('mic-status').textContent = 'Error occurred. Please try again.';
2079
+ document.getElementById('micIcon').classList.remove('active');
2080
+ };
2081
+
2082
+ recognition.onend = () => {
2083
+ document.getElementById('micIcon').classList.remove('active');
2084
  };
2085
 
2086
  document.getElementById('micIcon').addEventListener('click', () => {
2087
  if (!recognition) return;
 
 
2088
  const micModal = new bootstrap.Modal(document.getElementById('micModal'));
2089
  micModal.show();
2090
  resetMicModal();
 
2092
  });
2093
  } else {
2094
  document.getElementById('micIcon').style.display = 'none';
 
2095
  }
2096
 
2097
  // Autocomplete for custom dish description
 
2099
  const suggestionsContainer = document.getElementById('descriptionSuggestions');
2100
 
2101
  if (descriptionInput && suggestionsContainer) {
2102
+ descriptionInput.addEventListener('input', debounce(() => {
2103
+ const query = descriptionInput.value.toLowerCase();
2104
  suggestionsContainer.innerHTML = '';
2105
+
2106
+ if (query.length < 2) {
2107
  suggestionsContainer.style.display = 'none';
2108
  return;
2109
  }
 
 
 
 
 
 
 
 
 
 
 
 
2110
 
2111
+ const filteredIngredients = ingredientsList.filter(ingredient =>
2112
+ ingredient.toLowerCase().includes(query)
2113
+ );
 
 
 
 
 
2114
 
2115
+ if (filteredIngredients.length === 0) {
 
 
 
 
 
2116
  suggestionsContainer.style.display = 'none';
2117
+ return;
2118
  }
2119
+
2120
+ filteredIngredients.forEach(ingredient => {
2121
+ const suggestionItem = document.createElement('div');
2122
+ suggestionItem.classList.add('autocomplete-suggestion');
2123
+ suggestionItem.textContent = ingredient;
2124
+ suggestionItem.addEventListener('click', () => {
2125
+ const currentValue = descriptionInput.value;
2126
+ const words = currentValue.split(' ');
2127
+ words[words.length - 1] = ingredient;
2128
+ descriptionInput.value = words.join(' ') + ' ';
2129
+ suggestionsContainer.innerHTML = '';
2130
+ suggestionsContainer.style.display = 'none';
2131
+ descriptionInput.focus();
2132
+ });
2133
+ suggestionsContainer.appendChild(suggestionItem);
2134
+ });
2135
+
2136
+ suggestionsContainer.style.display = 'block';
2137
  }, 300));
2138
 
2139
  document.addEventListener('click', (event) => {
 
2144
  }
2145
  });
2146
  </script>
2147
+ <style>
2148
+ .autocomplete-suggestions {
2149
+ position: absolute;
2150
+ top: 100%;
2151
+ left: 0;
2152
+ right: 0;
2153
+ background-color: #fff;
2154
+ border: 1px solid #ced4da;
2155
+ border-radius: 4px;
2156
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
2157
+ max-height: 150px;
2158
+ overflow-y: auto;
2159
+ z-index: 1000;
2160
+ display: none;
2161
+ }
2162
+ .autocomplete-suggestion {
2163
+ padding: 8px 12px;
2164
+ cursor: pointer;
2165
+ font-size: 0.9rem;
2166
+ color: #333;
2167
+ transition: background-color 0.2s ease;
2168
+ }
2169
+ .autocomplete-suggestion:hover {
2170
+ background-color: #e6f4ea;
2171
+ }
2172
+ .autocomplete-suggestions::-webkit-scrollbar {
2173
+ width: 6px;
2174
+ }
2175
+ .autocomplete-suggestions::-webkit-scrollbar-track {
2176
+ background: #f1f1f1;
2177
+ }
2178
+ .autocomplete-suggestions::-webkit-scrollbar-thumb {
2179
+ background: #0FAA39;
2180
+ border-radius: 10px;
2181
+ }
2182
+ .autocomplete-suggestions::-webkit-scrollbar-thumb:hover {
2183
+ background: #0D9232;
2184
+ }
2185
+ </style>
2186
  </body>
2187
  </html>
2188
+ </xaiArtifact>