Update templates/menu.html
Browse files- templates/menu.html +108 -79
templates/menu.html
CHANGED
@@ -149,7 +149,9 @@
|
|
149 |
right: 10px;
|
150 |
top: 50%;
|
151 |
transform: translateY(-50%);
|
152 |
-
|
|
|
|
|
153 |
}
|
154 |
.avatar-icon {
|
155 |
width: 40px;
|
@@ -163,50 +165,33 @@
|
|
163 |
color: white;
|
164 |
font-size: 20px;
|
165 |
font-weight: bold;
|
166 |
-
transition: transform 0.2s ease;
|
167 |
-
}
|
168 |
-
.avatar-icon:hover {
|
169 |
-
transform: scale(1.1);
|
170 |
}
|
171 |
.dropdown-menu {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
display: none;
|
173 |
-
|
174 |
-
top: 0;
|
175 |
-
left: 0;
|
176 |
-
width: 100%;
|
177 |
-
height: 100%;
|
178 |
-
background: rgba(0, 0, 0, 0.5);
|
179 |
-
z-index: 1050;
|
180 |
-
justify-content: center;
|
181 |
-
align-items: center;
|
182 |
-
}
|
183 |
-
.dropdown-menu.show {
|
184 |
-
display: flex;
|
185 |
-
}
|
186 |
-
.dropdown-content {
|
187 |
-
background-color: #fff;
|
188 |
-
border-radius: 10px;
|
189 |
-
width: 90%;
|
190 |
-
max-width: 300px;
|
191 |
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
192 |
-
padding: 10px 0;
|
193 |
}
|
194 |
-
.dropdown-item {
|
195 |
-
|
196 |
-
align-items: center;
|
197 |
-
padding: 12px 20px;
|
198 |
text-decoration: none;
|
199 |
color: #333;
|
200 |
-
|
|
|
|
|
201 |
transition: background-color 0.2s ease;
|
202 |
}
|
203 |
-
.dropdown-item:
|
204 |
-
|
205 |
}
|
206 |
-
.dropdown-item
|
207 |
-
|
208 |
-
|
209 |
-
color: #0FAA39;
|
210 |
}
|
211 |
.fixed-top-bar {
|
212 |
position: relative;
|
@@ -878,6 +863,7 @@
|
|
878 |
border-radius: 8px;
|
879 |
font-weight: bold;
|
880 |
font-size: 16px;
|
|
|
881 |
display: flex;
|
882 |
align-items: center;
|
883 |
justify-content: center;
|
@@ -886,19 +872,18 @@
|
|
886 |
white-space: nowrap;
|
887 |
}
|
888 |
.bottom-action-bar .btn-order-history {
|
889 |
-
background
|
890 |
-
border-color:
|
891 |
-
color: #
|
892 |
}
|
893 |
.bottom-action-bar .btn-order-history:hover {
|
894 |
-
background
|
895 |
-
border-color:
|
896 |
-
color: #
|
897 |
}
|
898 |
.bottom-action-bar .btn-view-cart {
|
899 |
background-color: #0FAA39;
|
900 |
border-color: #0FAA39;
|
901 |
-
color: #ffffff;
|
902 |
}
|
903 |
.bottom-action-bar .btn-view-cart:hover {
|
904 |
background-color: #0D9232;
|
@@ -950,16 +935,12 @@
|
|
950 |
height: 40px;
|
951 |
font-size: 20px;
|
952 |
}
|
953 |
-
.dropdown-
|
954 |
-
width:
|
955 |
-
max-width: 280px;
|
956 |
}
|
957 |
-
.dropdown-item {
|
958 |
-
padding:
|
959 |
-
font-size:
|
960 |
-
}
|
961 |
-
.dropdown-item i {
|
962 |
-
font-size: 16px;
|
963 |
}
|
964 |
.modal-dialog {
|
965 |
max-width: 90%;
|
@@ -1223,12 +1204,10 @@
|
|
1223 |
<span>{{ first_letter }}</span>
|
1224 |
</div>
|
1225 |
<div class="dropdown-menu">
|
1226 |
-
<
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
<a href="{{ url_for('logout') }}" class="dropdown-item"><i class="bi bi-box-arrow-right"></i>Logout</a>
|
1231 |
-
</div>
|
1232 |
</div>
|
1233 |
</div>
|
1234 |
<div class="search-bar-container">
|
@@ -1847,17 +1826,17 @@
|
|
1847 |
const dropdownMenu = document.querySelector('.dropdown-menu');
|
1848 |
avatarContainer.addEventListener('click', function (event) {
|
1849 |
event.stopPropagation();
|
1850 |
-
dropdownMenu.
|
1851 |
});
|
1852 |
document.addEventListener('click', function (event) {
|
1853 |
-
if (!avatarContainer.contains(event.target)
|
1854 |
-
dropdownMenu.
|
1855 |
}
|
1856 |
});
|
1857 |
const dropdownItems = document.querySelectorAll('.dropdown-item');
|
1858 |
dropdownItems.forEach(item => {
|
1859 |
item.addEventListener('click', function () {
|
1860 |
-
dropdownMenu.
|
1861 |
});
|
1862 |
});
|
1863 |
const searchBar = document.getElementById('searchBar');
|
@@ -1907,51 +1886,76 @@
|
|
1907 |
localStorage.removeItem('selectedItem');
|
1908 |
}
|
1909 |
}
|
|
|
|
|
1910 |
const mediaWrappers = document.querySelectorAll('.media-wrapper');
|
1911 |
mediaWrappers.forEach(wrapper => {
|
1912 |
const video = wrapper.querySelector('.menu-video');
|
1913 |
const image = wrapper.querySelector('.menu-image');
|
|
|
|
|
1914 |
wrapper.addEventListener('mouseenter', () => {
|
1915 |
image.classList.add('hidden');
|
1916 |
video.classList.add('active');
|
1917 |
video.play().catch(err => console.error('Video play error:', err));
|
1918 |
});
|
|
|
1919 |
wrapper.addEventListener('mouseleave', () => {
|
1920 |
video.classList.remove('active');
|
1921 |
-
image.classList.remove('
|
1922 |
video.pause();
|
1923 |
video.currentTime = 0;
|
1924 |
});
|
1925 |
-
|
|
|
|
|
|
|
1926 |
wrapper.classList.add('touched');
|
1927 |
image.classList.add('hidden');
|
1928 |
video.classList.add('active');
|
1929 |
video.play().catch(err => console.error('Video play error:', err));
|
1930 |
});
|
|
|
1931 |
wrapper.addEventListener('touchend', () => {
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
video.currentTime = 0;
|
1938 |
-
}, 500);
|
1939 |
});
|
1940 |
});
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1949 |
}
|
1950 |
});
|
1951 |
});
|
|
|
|
|
1952 |
const decreaseBtn = document.getElementById('decreaseQuantity');
|
1953 |
const increaseBtn = document.getElementById('increaseQuantity');
|
1954 |
const quantityInput = document.getElementById('quantityInput');
|
|
|
1955 |
decreaseBtn.addEventListener('click', () => {
|
1956 |
let value = parseInt(quantityInput.value) || 1;
|
1957 |
if (value > 1) {
|
@@ -1959,26 +1963,34 @@
|
|
1959 |
updateModalPrice();
|
1960 |
}
|
1961 |
});
|
|
|
1962 |
increaseBtn.addEventListener('click', () => {
|
1963 |
let value = parseInt(quantityInput.value) || 1;
|
1964 |
quantityInput.value = value + 1;
|
1965 |
updateModalPrice();
|
1966 |
});
|
|
|
|
|
1967 |
updateCartUI(getCartLocalStorage());
|
|
|
|
|
1968 |
if ('webkitSpeechRecognition' in window || 'SpeechRecognition' in window) {
|
1969 |
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
1970 |
recognition = new SpeechRecognition();
|
1971 |
recognition.continuous = false;
|
1972 |
recognition.interimResults = true;
|
1973 |
recognition.lang = 'en-US';
|
|
|
1974 |
recognition.onstart = () => {
|
1975 |
document.getElementById('mic-status').textContent = 'Listening...';
|
1976 |
document.getElementById('mic-icon-animation').classList.add('bi-mic-fill');
|
1977 |
document.getElementById('mic-icon-animation').classList.remove('bi-mic');
|
1978 |
};
|
|
|
1979 |
recognition.onresult = (event) => {
|
1980 |
let interimTranscript = '';
|
1981 |
let finalTranscript = '';
|
|
|
1982 |
for (let i = event.resultIndex; i < event.results.length; i++) {
|
1983 |
const transcript = event.results[i][0].transcript;
|
1984 |
if (event.results[i].isFinal) {
|
@@ -1987,16 +1999,20 @@
|
|
1987 |
interimTranscript += transcript;
|
1988 |
}
|
1989 |
}
|
|
|
1990 |
document.getElementById('mic-status').textContent = interimTranscript || finalTranscript;
|
|
|
1991 |
if (finalTranscript) {
|
1992 |
const spokenItem = menuItems.find(item =>
|
1993 |
item.name.toLowerCase().includes(finalTranscript.toLowerCase())
|
1994 |
);
|
|
|
1995 |
if (spokenItem) {
|
1996 |
document.getElementById('mic-status').style.display = 'none';
|
1997 |
document.getElementById('mic-item-details').style.display = 'block';
|
1998 |
document.getElementById('mic-item-name').textContent = spokenItem.name;
|
1999 |
document.getElementById('mic-item-image').src = spokenItem.image || '/static/placeholder.jpg';
|
|
|
2000 |
const menuCards = document.querySelectorAll('.menu-card');
|
2001 |
let targetButton = null;
|
2002 |
menuCards.forEach(card => {
|
@@ -2005,6 +2021,7 @@
|
|
2005 |
targetButton = card.querySelector('.button-container');
|
2006 |
}
|
2007 |
});
|
|
|
2008 |
if (targetButton) {
|
2009 |
const name = targetButton.getAttribute('data-item-name');
|
2010 |
const price = targetButton.getAttribute('data-item-price');
|
@@ -2012,10 +2029,12 @@
|
|
2012 |
const description = targetButton.getAttribute('data-item-description');
|
2013 |
const section = targetButton.getAttribute('data-item-section');
|
2014 |
const category = targetButton.getAttribute('data-item-category');
|
|
|
2015 |
setTimeout(() => {
|
2016 |
recognition.stop();
|
2017 |
const micModal = bootstrap.Modal.getInstance(document.getElementById('micModal'));
|
2018 |
micModal.hide();
|
|
|
2019 |
if (section === 'Soft Drinks') {
|
2020 |
showSoftDrinkModal(targetButton.querySelector('.add-to-cart-btn'));
|
2021 |
} else {
|
@@ -2028,11 +2047,13 @@
|
|
2028 |
}
|
2029 |
}
|
2030 |
};
|
|
|
2031 |
recognition.onend = () => {
|
2032 |
document.getElementById('mic-icon-animation').classList.remove('bi-mic-fill');
|
2033 |
document.getElementById('mic-icon-animation').classList.add('bi-mic');
|
2034 |
document.getElementById('micIcon').classList.remove('active');
|
2035 |
};
|
|
|
2036 |
recognition.onerror = (event) => {
|
2037 |
console.error('Speech recognition error:', event.error);
|
2038 |
document.getElementById('mic-status').textContent = 'Error occurred. Please try again.';
|
@@ -2040,8 +2061,10 @@
|
|
2040 |
stopSpeechRecognition();
|
2041 |
}, 2000);
|
2042 |
};
|
|
|
2043 |
document.getElementById('micIcon').addEventListener('click', () => {
|
2044 |
if (!recognition) return;
|
|
|
2045 |
document.getElementById('micIcon').classList.add('active');
|
2046 |
const micModal = new bootstrap.Modal(document.getElementById('micModal'));
|
2047 |
micModal.show();
|
@@ -2052,8 +2075,11 @@
|
|
2052 |
document.getElementById('micIcon').style.display = 'none';
|
2053 |
console.warn('Speech recognition not supported in this browser.');
|
2054 |
}
|
|
|
|
|
2055 |
const descriptionInput = document.getElementById('custom-dish-description');
|
2056 |
const suggestionsContainer = document.getElementById('descriptionSuggestions');
|
|
|
2057 |
if (descriptionInput && suggestionsContainer) {
|
2058 |
const showSuggestions = (suggestions) => {
|
2059 |
suggestionsContainer.innerHTML = '';
|
@@ -2073,6 +2099,7 @@
|
|
2073 |
});
|
2074 |
suggestionsContainer.style.display = 'block';
|
2075 |
};
|
|
|
2076 |
const filterSuggestions = (input) => {
|
2077 |
const inputWords = input.toLowerCase().split(/\s+/);
|
2078 |
return ingredientsList.filter(ingredient =>
|
@@ -2081,6 +2108,7 @@
|
|
2081 |
)
|
2082 |
).slice(0, 5);
|
2083 |
};
|
|
|
2084 |
descriptionInput.addEventListener('input', debounce(() => {
|
2085 |
const input = descriptionInput.value.trim();
|
2086 |
if (input) {
|
@@ -2090,6 +2118,7 @@
|
|
2090 |
suggestionsContainer.style.display = 'none';
|
2091 |
}
|
2092 |
}, 300));
|
|
|
2093 |
document.addEventListener('click', (event) => {
|
2094 |
if (!descriptionInput.contains(event.target) && !suggestionsContainer.contains(event.target)) {
|
2095 |
suggestionsContainer.style.display = 'none';
|
|
|
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;
|
|
|
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 |
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;
|
|
|
872 |
white-space: nowrap;
|
873 |
}
|
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;
|
|
|
935 |
height: 40px;
|
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 |
<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 |
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');
|
|
|
1886 |
localStorage.removeItem('selectedItem');
|
1887 |
}
|
1888 |
}
|
1889 |
+
|
1890 |
+
// Image-to-Video hover/touch functionality
|
1891 |
const mediaWrappers = document.querySelectorAll('.media-wrapper');
|
1892 |
mediaWrappers.forEach(wrapper => {
|
1893 |
const video = wrapper.querySelector('.menu-video');
|
1894 |
const image = wrapper.querySelector('.menu-image');
|
1895 |
+
|
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 |
+
|
1954 |
+
// Quantity controls for item modal
|
1955 |
const decreaseBtn = document.getElementById('decreaseQuantity');
|
1956 |
const increaseBtn = document.getElementById('increaseQuantity');
|
1957 |
const quantityInput = document.getElementById('quantityInput');
|
1958 |
+
|
1959 |
decreaseBtn.addEventListener('click', () => {
|
1960 |
let value = parseInt(quantityInput.value) || 1;
|
1961 |
if (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) {
|
|
|
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 => {
|
|
|
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');
|
|
|
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 {
|
|
|
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.';
|
|
|
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();
|
|
|
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
|
2080 |
const descriptionInput = document.getElementById('custom-dish-description');
|
2081 |
const suggestionsContainer = document.getElementById('descriptionSuggestions');
|
2082 |
+
|
2083 |
if (descriptionInput && suggestionsContainer) {
|
2084 |
const showSuggestions = (suggestions) => {
|
2085 |
suggestionsContainer.innerHTML = '';
|
|
|
2099 |
});
|
2100 |
suggestionsContainer.style.display = 'block';
|
2101 |
};
|
2102 |
+
|
2103 |
const filterSuggestions = (input) => {
|
2104 |
const inputWords = input.toLowerCase().split(/\s+/);
|
2105 |
return ingredientsList.filter(ingredient =>
|
|
|
2108 |
)
|
2109 |
).slice(0, 5);
|
2110 |
};
|
2111 |
+
|
2112 |
descriptionInput.addEventListener('input', debounce(() => {
|
2113 |
const input = descriptionInput.value.trim();
|
2114 |
if (input) {
|
|
|
2118 |
suggestionsContainer.style.display = 'none';
|
2119 |
}
|
2120 |
}, 300));
|
2121 |
+
|
2122 |
document.addEventListener('click', (event) => {
|
2123 |
if (!descriptionInput.contains(event.target) && !suggestionsContainer.contains(event.target)) {
|
2124 |
suggestionsContainer.style.display = 'none';
|