lokeshloki143 commited on
Commit
058f58a
·
verified ·
1 Parent(s): 6f34ecc

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +243 -197
templates/menu.html CHANGED
@@ -149,58 +149,67 @@
149
  right: 10px;
150
  top: 50%;
151
  transform: translateY(-50%);
 
 
 
152
  }
153
  .avatar-icon {
154
- width: 38px;
155
- height: 38px;
156
  border-radius: 50%;
157
- background: linear-gradient(135deg, #000000, #0000FF, #008000);
 
158
  display: flex;
159
  align-items: center;
160
  justify-content: center;
161
  color: white;
162
- font-size: 18px;
163
- font-weight: 600;
164
- cursor: pointer;
165
- transition: transform 0.2s ease;
166
- }
167
- .avatar-icon:hover {
168
- transform: scale(1.1);
169
  }
170
  .dropdown-menu {
171
  position: absolute;
172
  right: 0;
173
  top: 100%;
174
- background-color: #fff;
 
175
  border-radius: 8px;
176
- width: 200px;
177
- box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
178
  display: none;
179
- opacity: 0;
180
- transform: translateY(-10px);
181
- transition: opacity 0.3s ease, transform 0.3s ease;
182
- z-index: 1000;
183
- }
184
- .dropdown-menu.show {
185
- display: block;
186
- opacity: 1;
187
- transform: translateY(0);
188
  }
189
- .dropdown-item {
190
- padding: 10px 15px;
191
- color: #333;
192
  text-decoration: none;
 
 
193
  display: flex;
194
  align-items: center;
195
- font-size: 14px;
196
  transition: background-color 0.2s ease;
197
  }
198
- .dropdown-item i {
199
- margin-right: 8px;
200
- font-size: 15px;
 
 
 
 
 
 
 
 
 
 
 
 
201
  }
202
- .dropdown-item:hover {
203
- background-color: #f1f1f1;
 
 
 
 
 
 
204
  }
205
  .fixed-top-bar {
206
  position: relative;
@@ -241,7 +250,7 @@
241
  color: #888;
242
  }
243
  .search-bar-container input:focus {
244
- border-bottom: 2px solid #FFA07A;
245
  }
246
  .search-icon {
247
  position: absolute;
@@ -604,7 +613,7 @@
604
  gap: 15px;
605
  min-height: 200px;
606
  }
607
- #micModal .modal-body i#ADDRESS {
608
  font-size: 2.5rem;
609
  color: #007bff;
610
  animation: pulse 2s infinite;
@@ -940,12 +949,12 @@
940
  right: 10px;
941
  }
942
  .avatar-icon {
943
- width: 34px;
944
- height: 34px;
945
- font-size: 16px;
946
  }
947
  .dropdown-menu {
948
- width: 180px;
949
  }
950
  .dropdown-menu .dropdown-item {
951
  padding: 12px 16px;
@@ -1209,14 +1218,14 @@
1209
  <body>
1210
  <div class="fixed-top-bar">
1211
  <div class="avatar-dropdown-container">
1212
- <div class="avatar-icon" id="avatarIcon">
1213
  <span>{{ first_letter }}</span>
1214
  </div>
1215
- <div class="dropdown-menu" id="dropdownMenu">
1216
- <a href="{{ url_for('user_details.customer_details') }}" class="dropdown-item"><i class="bi bi-person"></i> View Profile</a>
1217
- <a href="{{ url_for('orderhistory.order_history') }}" class="dropdown-item"><i class="bi bi-clock-history"></i> Order History</a>
1218
- <a href="{{ url_for('combined_summary.combined_summary') }}" class="dropdown-item"><i class="bi bi-file-earmark-text"></i> MY Summary</a>
1219
- <a href="{{ url_for('logout') }}" class="dropdown-item"><i class="bi bi-box-arrow-right"></i> Logout</a>
1220
  </div>
1221
  </div>
1222
  <div class="search-bar-container">
@@ -1831,24 +1840,23 @@
1831
  document.getElementById('mic-item-name').textContent = '';
1832
  }
1833
  document.addEventListener('DOMContentLoaded', function () {
1834
- // Avatar Dropdown
1835
- const avatarIcon = document.getElementById('avatarIcon');
1836
- const dropdownMenu = document.getElementById('dropdownMenu');
1837
- avatarIcon.addEventListener('click', function (event) {
1838
  event.stopPropagation();
1839
- dropdownMenu.classList.toggle('show');
1840
  });
1841
  document.addEventListener('click', function (event) {
1842
- if (!avatarIcon.contains(event.target)) {
1843
- dropdownMenu.classList.remove('show');
1844
  }
1845
  });
1846
- document.querySelectorAll('.dropdown-item').forEach(item => {
 
1847
  item.addEventListener('click', function () {
1848
- dropdownMenu.classList.remove('show');
1849
  });
1850
  });
1851
-
1852
  const searchBar = document.getElementById('searchBar');
1853
  searchBar.addEventListener('click', function () {
1854
  window.location.href = '/search';
@@ -1914,7 +1922,7 @@
1914
  }
1915
  });
1916
  card.addEventListener('touchstart', () => {
1917
- isTouching = true;
1918
  video.classList.add('active');
1919
  image.classList.add('hidden');
1920
  video.play().catch(err => {
@@ -1939,155 +1947,193 @@
1939
  const itemDetails = card.querySelector('.item-details');
1940
  if (toggleDetails && itemDetails) {
1941
  toggleDetails.addEventListener('click', () => {
1942
- const isShown = itemDetails.classList.contains('show');
1943
  itemDetails.classList.toggle('show');
1944
- toggleDetails.textContent = isShown ? 'Show Details' : 'Hide Details';
1945
  });
1946
  }
1947
  });
1948
  const quantityInput = document.getElementById('quantityInput');
1949
- const increaseBtn = document.getElementById('increaseQuantity');
1950
- const decreasedecreaseBtn = document.getElementById('decreaseQuantity');
1951
- if (increaseBtn && decreaseBtn && quantityInput) {
1952
- increaseBtn.addEventListener('click', () => {
1953
- let quantity = parseInt(quantityInput.value) || 1;
1954
- quantityInput.value = quantity + 1;
1955
- updateModalPrice();
1956
- });
1957
- decreaseBtn.addEventListener('click', () => {
1958
- let quantity = parseInt(quantityInput.value) || 1;
1959
- if (quantity > 1) {
1960
- quantityInput.value = quantity - 1;
1961
- updateModalPrice();
1962
- }
1963
- });
1964
- }
1965
- const micIcon = document.getElementById('micIcon');
1966
- if (micIcon) {
1967
- micIcon.addEventListener('click', () => {
1968
- if (!recognition || !recognition.isStarted) {
1969
- startSpeechRecognition();
1970
- micIcon.classList.add('active');
1971
- } else {
1972
- stopSpeechRecognition();
1973
- micIcon.classList.remove('active');
1974
- }
1975
- });
1976
- }
1977
- function startSpeechRecognition() {
1978
- if ('webkitSpeechRecognition' in window || 'SpeechRecognition' in window) {
1979
- recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
1980
- recognition.lang = 'en-US';
1981
- recognition.interimResults = false;
1982
- recognition.maxAlternatives = 1;
1983
- const micModal = new bootstrap.Modal(document.getElementById('micModal'));
1984
- micModal.show();
1985
- recognition.onresult = function(event) {
1986
- const transcript = event.results[0][0].transcript.trim().toLowerCase();
1987
- console.log('Recognized speech:', transcript);
1988
- const matchedItem = menuItems.find(item =>
1989
- item.name.toLowerCase().includes(transcript) ||
1990
- transcript.includes(item.name.toLowerCase())
1991
- );
1992
- if (matchedItem) {
1993
- document.getElementById('mic-status').style.display = 'none';
1994
- document.getElementById('mic-item-details').style.display = 'block';
1995
- document.getElementById('mic-item-name').textContent = matchedItem.name;
1996
- document.getElementById('mic-item-image').src = matchedItem.image;
1997
- localStorage.setItem('selectedItem', JSON.stringify({
1998
- name: matchedItem.name,
1999
- section: matchedItem.section
2000
- }));
2001
- setTimeout(() => {
2002
- micModal.hide();
2003
- const card = document.querySelector(`.menu-card[data-item-name="${matchedItem.name}"][data-item-section="${matchedItem.section}"]`);
2004
- if (card) {
2005
- card.classList.add('highlighted');
2006
- setTimeout(() => card.classList.remove('highlighted'), 3000);
2007
- const button = card.querySelector('.btn-primary');
2008
- if (button) {
2009
- if (matchedItem.section === 'Soft Drinks') {
2010
- showSoftDrinkModal(button);
2011
- } else {
2012
- button.click();
 
 
 
2013
  }
2014
- }
 
 
 
 
 
2015
  }
2016
- stopSpeechRecognition();
2017
- }, 1500);
2018
- } else {
2019
- document.getElementById('mic-status').textContent = 'Item not found. Try again...';
2020
- setTimeout(() => {
2021
- document.getElementById('mic-status').textContent = 'Say the name of a menu item...';
2022
- }, 2000);
2023
- }
2024
- };
2025
- recognition.onerror = function(event) {
2026
- console.error('Speech recognition error:', event.error);
2027
- document.getElementById('mic-status').textContent = 'Error occurred. Try again...';
2028
- stopSpeechRecognition();
2029
- };
2030
- recognition.onend = function() {
2031
- if (recognition && recognition.isStarted) {
2032
- recognition.start();
2033
- }
2034
- };
2035
- recognition.isStarted = true;
2036
- recognition.start();
2037
- } else {
2038
- alert('Speech recognition is not supported in this browser.');
2039
- }
2040
- }
2041
- updateCartUI(getCartLocalStorage());
2042
- const descriptionInput = document.getElementById('custom-dish-description');
2043
- const suggestionsContainer = document.getElementById('descriptionSuggestions');
2044
- if (descriptionInput && suggestionsContainer) {
2045
- descriptionInput.addEventListener('input', debounce(function() {
2046
- const query = descriptionInput.value.trim();
2047
- if (query.length < 2) {
2048
- suggestionsContainer.innerHTML = '';
2049
- suggestionsContainer.style.display = 'none';
2050
- return;
2051
- }
2052
- const filteredIngredients = ingredientsList.filter(ingredient =>
2053
- ingredient.toLowerCase().includes(query.toLowerCase())
2054
- );
2055
- suggestionsContainer.innerHTML = '';
2056
- if (filteredIngredients.length > 0) {
2057
- filteredIngredients.slice(0, 5).forEach(ingredient => {
2058
- const suggestionItem = document.createElement('div');
2059
- suggestionItem.classList.add('suggestion-item');
2060
- suggestionItem.textContent = ingredient;
2061
- suggestionItem.style.padding = '8px';
2062
- suggestionItem.style.cursor = 'pointer';
2063
- suggestionItem.style.backgroundColor = '#fff';
2064
- suggestionItem.style.borderBottom = '1px solid #eee';
2065
- suggestionItem.addEventListener('click', () => {
2066
- descriptionInput.value = ingredient;
2067
- suggestionsContainer.innerHTML = '';
2068
- suggestionsContainer.style.display = 'none';
2069
- });
2070
- suggestionsContainer.appendChild(suggestionItem);
2071
  });
2072
- suggestionsContainer.style.display = 'block';
2073
- suggestionsContainer.style.position = 'absolute';
2074
- suggestionsContainer.style.backgroundColor = '#fff';
2075
- suggestionsContainer.style.border = '1px solid #ccc';
2076
- suggestionsContainer.style.borderRadius = '4px';
2077
- suggestionsContainer.style.zIndex = '1000';
2078
- suggestionsContainer.style.width = descriptionInput.offsetWidth + 'px';
2079
- } else {
2080
- suggestionsContainer.style.display = 'none';
2081
- }
2082
- }, 300));
2083
- document.addEventListener('click', (event) => {
2084
- if (!descriptionInput.contains(event.target) && !suggestionsContainer.contains(event.target)) {
2085
- suggestionsContainer.innerHTML = '';
2086
- suggestionsContainer.style.display = 'none';
2087
- }
2088
- });
2089
- }
2090
- });
2091
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2092
  </body>
2093
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
149
  right: 10px;
150
  top: 50%;
151
  transform: translateY(-50%);
152
+ display: flex;
153
+ align-items: center;
154
+ justify-content: center;
155
  }
156
  .avatar-icon {
157
+ width: 40px;
158
+ height: 40px;
159
  border-radius: 50%;
160
+ background: linear-gradient(45deg, #FF8C00, #000000, #0000FF); /* Orange, black, blue gradient */
161
+ cursor: pointer;
162
  display: flex;
163
  align-items: center;
164
  justify-content: center;
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: linear-gradient(45deg, #FF8C00, #000000, #32CD32); /* Orange, black, green gradient */
174
+ border: 1px solid #FFD700; /* Gold border for premium look */
175
  border-radius: 8px;
176
+ box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.2);
 
177
  display: none;
 
 
 
 
 
 
 
 
 
178
  }
179
+ .dropdown-menu .dropdown-item {
180
+ padding: 12px 16px;
 
181
  text-decoration: none;
182
+ color: #FFFFFF; /* White text for contrast */
183
+ border-bottom: 1px solid rgba(255, 215, 0, 0.3); /* Subtle gold separator */
184
  display: flex;
185
  align-items: center;
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: rgba(255, 215, 0, 0.2); /* Gold highlight on hover */
194
+ color: #FFFFFF;
195
+ }
196
+ .dropdown-menu .dropdown-item::before {
197
+ font-family: 'bootstrap-icons';
198
+ margin-right: 10px;
199
+ font-size: 16px;
200
+ color: #FFD700; /* Gold icons */
201
+ }
202
+ .dropdown-menu .dropdown-item:nth-child(1)::before {
203
+ content: '\F4DA'; /* User icon for View Profile */
204
  }
205
+ .dropdown-menu .dropdown-item:nth-child(2)::before {
206
+ content: '\F2EA'; /* Clock icon for Order History */
207
+ }
208
+ .dropdown-menu .dropdown-item:nth-child(3)::before {
209
+ content: '\F4E6'; /* Summary icon for MY Summary */
210
+ }
211
+ .dropdown-menu .dropdown-item:nth-child(4)::before {
212
+ content: '\F52B'; /* Logout icon */
213
  }
214
  .fixed-top-bar {
215
  position: relative;
 
250
  color: #888;
251
  }
252
  .search-bar-container input:focus {
253
+ border-bottom: 2px solid #FFS07A;
254
  }
255
  .search-icon {
256
  position: absolute;
 
613
  gap: 15px;
614
  min-height: 200px;
615
  }
616
+ #micModal .modal-body i#mic-icon-animation {
617
  font-size: 2.5rem;
618
  color: #007bff;
619
  animation: pulse 2s infinite;
 
949
  right: 10px;
950
  }
951
  .avatar-icon {
952
+ width: 40px;
953
+ height: 40px;
954
+ font-size: 20px;
955
  }
956
  .dropdown-menu {
957
+ width: 220px;
958
  }
959
  .dropdown-menu .dropdown-item {
960
  padding: 12px 16px;
 
1218
  <body>
1219
  <div class="fixed-top-bar">
1220
  <div class="avatar-dropdown-container">
1221
+ <div class="avatar-icon">
1222
  <span>{{ first_letter }}</span>
1223
  </div>
1224
+ <div class="dropdown-menu">
1225
+ <a href="{{ url_for('user_details.customer_details') }}" class="dropdown-item">View Profile</a>
1226
+ <a href="{{ url_for('orderhistory.order_history') }}" class="dropdown-item">Order History</a>
1227
+ <a href="{{ url_for('combined_summary.combined_summary') }}" class="dropdown-item">MY Summary</a>
1228
+ <a href="{{ url_for('logout') }}" class="dropdown-item">Logout</a>
1229
  </div>
1230
  </div>
1231
  <div class="search-bar-container">
 
1840
  document.getElementById('mic-item-name').textContent = '';
1841
  }
1842
  document.addEventListener('DOMContentLoaded', function () {
1843
+ const avatarContainer = document.querySelector('.avatar-dropdown-container');
1844
+ const dropdownMenu = document.querySelector('.dropdown-menu');
1845
+ avatarContainer.addEventListener('click', function (event) {
 
1846
  event.stopPropagation();
1847
+ dropdownMenu.style.display = dropdownMenu.style.display === 'block' ? 'none' : 'block';
1848
  });
1849
  document.addEventListener('click', function (event) {
1850
+ if (!avatarContainer.contains(event.target)) {
1851
+ dropdownMenu.style.display = 'none';
1852
  }
1853
  });
1854
+ const dropdownItems = document.querySelectorAll('.dropdown-item');
1855
+ dropdownItems.forEach(item => {
1856
  item.addEventListener('click', function () {
1857
+ dropdownMenu.style.display = 'none';
1858
  });
1859
  });
 
1860
  const searchBar = document.getElementById('searchBar');
1861
  searchBar.addEventListener('click', function () {
1862
  window.location.href = '/search';
 
1922
  }
1923
  });
1924
  card.addEventListener('touchstart', () => {
1925
+ isTouching = true;
1926
  video.classList.add('active');
1927
  image.classList.add('hidden');
1928
  video.play().catch(err => {
 
1947
  const itemDetails = card.querySelector('.item-details');
1948
  if (toggleDetails && itemDetails) {
1949
  toggleDetails.addEventListener('click', () => {
1950
+ const isVisible = itemDetails.classList.contains('show');
1951
  itemDetails.classList.toggle('show');
1952
+ toggleDetails.textContent = isVisible ? 'Show Details' : 'Hide Details';
1953
  });
1954
  }
1955
  });
1956
  const quantityInput = document.getElementById('quantityInput');
1957
+ const decreaseButton = document.getElementById('decreaseQuantity');
1958
+ const increaseButton = document.getElementById('increaseQuantity');
1959
+ decreaseButton.addEventListener('click', () => {
1960
+ let currentValue = parseInt(quantityInput.value) || 1;
1961
+ if (currentValue > 1) {
1962
+ quantityInput.value = currentValue - 1;
1963
+ updateModalPrice();
1964
+ }
1965
+ });
1966
+ increaseButton.addEventListener('click', () => {
1967
+ let currentValue = parseInt(quantityInput.value) || 1;
1968
+ quantityInput.value = currentValue + 1;
1969
+ updateModalPrice();
1970
+ });
1971
+ const micIcon = document.getElementById('micIcon');
1972
+ micIcon.addEventListener('click', () => {
1973
+ if (!('webkitSpeechRecognition' in window) && !('SpeechRecognition' in window)) {
1974
+ alert('Speech recognition is not supported in this browser.');
1975
+ return;
1976
+ }
1977
+ const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
1978
+ recognition = new SpeechRecognition();
1979
+ recognition.lang = 'en-US';
1980
+ recognition.interimResults = false;
1981
+ recognition.maxAlternatives = 1;
1982
+ recognition.start();
1983
+ micIcon.classList.add('active');
1984
+ const micModal = new bootstrap.Modal(document.getElementById('micModal'));
1985
+ micModal.show();
1986
+ document.getElementById('mic-status').textContent = 'Listening...';
1987
+ recognition.onresult = function (event) {
1988
+ const transcript = event.results[0][0].transcript.trim();
1989
+ console.log('Recognized speech:', transcript);
1990
+ const matchedItem = menuItems.find(item =>
1991
+ item.name.toLowerCase().includes(transcript.toLowerCase())
1992
+ );
1993
+ if (matchedItem) {
1994
+ document.getElementById('mic-status').style.display = 'none';
1995
+ document.getElementById('mic-item-details').style.display = 'block';
1996
+ document.getElementById('mic-item-name').textContent = matchedItem.name;
1997
+ document.getElementById('mic-item-image').src = matchedItem.image;
1998
+ setTimeout(() => {
1999
+ const menuCards = document.querySelectorAll('.menu-card');
2000
+ let targetCard = null;
2001
+ let buttonContainer = null;
2002
+ menuCards.forEach(card => {
2003
+ const itemName = card.getAttribute('data-item-name');
2004
+ const itemSection = card.getAttribute('data-item-section');
2005
+ if (itemName === matchedItem.name && itemSection === matchedItem.section) {
2006
+ targetCard = card;
2007
+ buttonContainer = card.querySelector('.button-container');
2008
+ }
2009
+ });
2010
+ if (targetCard && buttonContainer) {
2011
+ targetCard.classList.add('highlighted');
2012
+ setTimeout(() => {
2013
+ targetCard.classList.remove('highlighted');
2014
+ }, 3000);
2015
+ const addButton = buttonContainer.querySelector('.btn-primary');
2016
+ if (addButton) {
2017
+ if (matchedItem.section === 'Soft Drinks') {
2018
+ showSoftDrinkModal(addButton);
2019
+ } else {
2020
+ addButton.click();
2021
+ }
2022
+ micModal.hide();
2023
+ }
2024
  }
2025
+ }, 1000);
2026
+ } else {
2027
+ document.getElementById('mic-status').textContent = 'Item not found. Try again.';
2028
+ setTimeout(() => {
2029
+ document.getElementById('mic-status').textContent = 'Say the name of a menu item...';
2030
+ }, 2000);
2031
  }
2032
+ };
2033
+ recognition.onend = function () {
2034
+ micIcon.classList.remove('active');
2035
+ if (document.getElementById('micModal').classList.contains('show')) {
2036
+ recognition.start();
2037
+ }
2038
+ };
2039
+ recognition.onerror = function (event) {
2040
+ console.error('Speech recognition error:', event.error);
2041
+ document.getElementById('mic-status').textContent = 'Error occurred. Please try again.';
2042
+ micIcon.classList.remove('active');
2043
+ setTimeout(() => {
2044
+ document.getElementById('mic-status').textContent = 'Say the name of a menu item...';
2045
+ }, 2000);
2046
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2047
  });
2048
+ const stopMicBtn = document.getElementById('stopMicBtn');
2049
+ stopMicBtn.addEventListener('click', stopSpeechRecognition);
2050
+ document.getElementById('micModal').addEventListener('hidden.bs.modal', stopSpeechRecognition);
2051
+ const cart = getCartLocalStorage();
2052
+ updateCartUI(cart);
2053
+ const descriptionInput = document.getElementById('custom-dish-description');
2054
+ const suggestionsDiv = document.getElementById('descriptionSuggestions');
2055
+ if (descriptionInput && suggestionsDiv) {
2056
+ const updateSuggestions = debounce(function () {
2057
+ const query = descriptionInput.value.toLowerCase();
2058
+ if (query.length < 2) {
2059
+ suggestionsDiv.innerHTML = '';
2060
+ suggestionsDiv.style.display = 'none';
2061
+ return;
2062
+ }
2063
+ const matchedIngredients = ingredientsList.filter(ingredient =>
2064
+ ingredient.toLowerCase().includes(query)
2065
+ );
2066
+ suggestionsDiv.innerHTML = '';
2067
+ if (matchedIngredients.length === 0) {
2068
+ suggestionsDiv.style.display = 'none';
2069
+ return;
2070
+ }
2071
+ matchedIngredients.forEach(ingredient => {
2072
+ const suggestionItem = document.createElement('div');
2073
+ suggestionItem.classList.add('suggestion-item');
2074
+ suggestionItem.textContent = ingredient;
2075
+ suggestionItem.style.padding = '8px';
2076
+ suggestionItem.style.cursor = 'pointer';
2077
+ suggestionItem.style.borderBottom = '1px solid #eee';
2078
+ suggestionItem.style.backgroundColor = '#fff';
2079
+ suggestionItem.style.transition = 'background-color 0.2s ease';
2080
+ suggestionItem.addEventListener('mouseover', () => {
2081
+ suggestionItem.style.backgroundColor = '#f0f0f0';
2082
+ });
2083
+ suggestionItem.addEventListener('mouseout', () => {
2084
+ suggestionItem.style.backgroundColor = '#fff';
2085
+ });
2086
+ suggestionItem.addEventListener('click', () => {
2087
+ const currentValue = descriptionInput.value;
2088
+ const lastSpaceIndex = currentValue.lastIndexOf(' ');
2089
+ const newValue = lastSpaceIndex === -1
2090
+ ? ingredient
2091
+ : currentValue.substring(0, lastSpaceIndex + 1) + ingredient;
2092
+ descriptionInput.value = newValue;
2093
+ suggestionsDiv.innerHTML = '';
2094
+ suggestionsDiv.style.display = 'none';
2095
+ descriptionInput.focus();
2096
+ });
2097
+ suggestionsDiv.appendChild(suggestionItem);
2098
+ });
2099
+ suggestionsDiv.style.display = 'block';
2100
+ suggestionsDiv.style.position = 'absolute';
2101
+ suggestionsDiv.style.zIndex = '1000';
2102
+ suggestionsDiv.style.backgroundColor = '#fff';
2103
+ suggestionsDiv.style.border = '1px solid #ccc';
2104
+ suggestionsDiv.style.borderRadius = '4px';
2105
+ suggestionsDiv.style.maxHeight = '150px';
2106
+ suggestionsDiv.style.overflowY = 'auto';
2107
+ suggestionsDiv.style.width = descriptionInput.offsetWidth + 'px';
2108
+ suggestionsDiv.style.boxShadow = '0 2px 4px rgba(0,0,0,0.1)';
2109
+ }, 300);
2110
+ descriptionInput.addEventListener('input', updateSuggestions);
2111
+ descriptionInput.addEventListener('blur', () => {
2112
+ setTimeout(() => {
2113
+ suggestionsDiv.innerHTML = '';
2114
+ suggestionsDiv.style.display = 'none';
2115
+ }, 200);
2116
+ });
2117
+ descriptionInput.addEventListener('focus', updateSuggestions);
2118
+ document.addEventListener('click', (event) => {
2119
+ if (!descriptionInput.contains(event.target) && !suggestionsDiv.contains(event.target)) {
2120
+ suggestionsDiv.innerHTML = '';
2121
+ suggestionsDiv.style.display = 'none';
2122
+ }
2123
+ });
2124
+ }
2125
+ });
2126
+ </script>
2127
  </body>
2128
+ </html>
2129
+
2130
+
2131
+
2132
+
2133
+
2134
+
2135
+
2136
+
2137
+
2138
+
2139
+