Update templates/menu.html
Browse files- templates/menu.html +102 -126
templates/menu.html
CHANGED
@@ -152,6 +152,7 @@
|
|
152 |
display: flex;
|
153 |
align-items: center;
|
154 |
justify-content: center;
|
|
|
155 |
}
|
156 |
.avatar-icon {
|
157 |
width: 40px;
|
@@ -165,27 +166,48 @@
|
|
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:
|
175 |
-
width:
|
176 |
-
box-shadow: 0px 4px
|
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:
|
|
|
186 |
font-size: 15px;
|
187 |
transition: background-color 0.2s ease;
|
188 |
}
|
|
|
|
|
|
|
|
|
|
|
189 |
.dropdown-menu .dropdown-item:last-child {
|
190 |
border-bottom: none;
|
191 |
}
|
@@ -863,7 +885,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,16 +895,17 @@
|
|
874 |
.bottom-action-bar .btn-order-history {
|
875 |
background: linear-gradient(45deg, #FF8C00, #32CD32);
|
876 |
border-color: transparent;
|
877 |
-
color: #
|
878 |
}
|
879 |
.bottom-action-bar .btn-order-history:hover {
|
880 |
background: linear-gradient(45deg, #FF4500, #228B22);
|
881 |
border-color: transparent;
|
882 |
-
color: #
|
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;
|
@@ -937,10 +959,16 @@
|
|
937 |
}
|
938 |
.dropdown-menu {
|
939 |
width: 220px;
|
|
|
|
|
940 |
}
|
941 |
.dropdown-menu .dropdown-item {
|
942 |
-
padding:
|
943 |
-
font-size:
|
|
|
|
|
|
|
|
|
944 |
}
|
945 |
.modal-dialog {
|
946 |
max-width: 90%;
|
@@ -1204,10 +1232,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 +1854,17 @@
|
|
1826 |
const dropdownMenu = document.querySelector('.dropdown-menu');
|
1827 |
avatarContainer.addEventListener('click', function (event) {
|
1828 |
event.stopPropagation();
|
1829 |
-
dropdownMenu.
|
1830 |
});
|
1831 |
document.addEventListener('click', function (event) {
|
1832 |
if (!avatarContainer.contains(event.target)) {
|
1833 |
-
dropdownMenu.
|
1834 |
}
|
1835 |
});
|
1836 |
const dropdownItems = document.querySelectorAll('.dropdown-item');
|
1837 |
dropdownItems.forEach(item => {
|
1838 |
item.addEventListener('click', function () {
|
1839 |
-
dropdownMenu.
|
1840 |
});
|
1841 |
});
|
1842 |
const searchBar = document.getElementById('searchBar');
|
@@ -1848,114 +1876,88 @@
|
|
1848 |
try {
|
1849 |
const { name, section } = JSON.parse(selectedItem);
|
1850 |
const menuCards = document.querySelectorAll('.menu-card');
|
1851 |
-
let
|
1852 |
-
let buttonContainer = null;
|
1853 |
menuCards.forEach(card => {
|
1854 |
-
|
1855 |
-
|
1856 |
-
if (itemName === name && itemSection === section) {
|
1857 |
-
targetCard = card;
|
1858 |
-
buttonContainer = card.querySelector('.button-container');
|
1859 |
-
card.classList.add('highlighted');
|
1860 |
-
card.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
1861 |
-
const toggleLink = card.querySelector('.toggle-details');
|
1862 |
-
if (toggleLink) {
|
1863 |
-
toggleLink.click();
|
1864 |
-
}
|
1865 |
}
|
1866 |
});
|
1867 |
-
if (
|
1868 |
-
const
|
1869 |
-
const
|
1870 |
-
const
|
1871 |
-
const
|
1872 |
-
const
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
}, 1000);
|
1882 |
}
|
|
|
1883 |
} catch (e) {
|
1884 |
console.error('Error parsing selectedItem:', e);
|
1885 |
-
} finally {
|
1886 |
localStorage.removeItem('selectedItem');
|
1887 |
}
|
1888 |
}
|
1889 |
-
|
1890 |
-
|
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.
|
1901 |
});
|
1902 |
-
|
1903 |
-
wrapper.addEventListener('mouseleave', () => {
|
1904 |
video.classList.remove('active');
|
1905 |
-
|
1906 |
-
video.pause();
|
1907 |
-
video.currentTime = 0;
|
1908 |
});
|
1909 |
-
|
1910 |
-
|
1911 |
-
wrapper.addEventListener('
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
video.play().catch(err => console.error('Video play error:', err));
|
1917 |
});
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
video.currentTime = 0;
|
1925 |
});
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
if (entry.isIntersecting) {
|
1932 |
-
const video = entry.target;
|
1933 |
-
video.load();
|
1934 |
-
observer.unobserve(video);
|
1935 |
}
|
1936 |
});
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1941 |
});
|
1942 |
-
|
1943 |
-
// Toggle item details
|
1944 |
document.querySelectorAll('.toggle-details').forEach(toggle => {
|
1945 |
-
toggle.addEventListener('click',
|
1946 |
-
const
|
|
|
1947 |
if (details) {
|
1948 |
details.classList.toggle('show');
|
1949 |
-
|
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,34 +1965,26 @@
|
|
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,20 +1993,16 @@
|
|
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,7 +2011,6 @@
|
|
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,12 +2018,10 @@
|
|
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,13 +2034,11 @@
|
|
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,10 +2046,8 @@
|
|
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,11 +2058,8 @@
|
|
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,7 +2079,6 @@
|
|
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,7 +2087,6 @@
|
|
2108 |
)
|
2109 |
).slice(0, 5);
|
2110 |
};
|
2111 |
-
|
2112 |
descriptionInput.addEventListener('input', debounce(() => {
|
2113 |
const input = descriptionInput.value.trim();
|
2114 |
if (input) {
|
@@ -2118,7 +2096,6 @@
|
|
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';
|
@@ -2128,5 +2105,4 @@
|
|
2128 |
});
|
2129 |
</script>
|
2130 |
</body>
|
2131 |
-
</html>
|
2132 |
-
</xaiArtifact>
|
|
|
152 |
display: flex;
|
153 |
align-items: center;
|
154 |
justify-content: center;
|
155 |
+
z-index: 1100; /* Ensure it’s above other elements */
|
156 |
}
|
157 |
.avatar-icon {
|
158 |
width: 40px;
|
|
|
166 |
color: white;
|
167 |
font-size: 20px;
|
168 |
font-weight: bold;
|
169 |
+
transition: transform 0.2s ease;
|
170 |
+
}
|
171 |
+
.avatar-icon:hover {
|
172 |
+
transform: scale(1.1);
|
173 |
}
|
174 |
.dropdown-menu {
|
175 |
position: absolute;
|
176 |
+
top: 100%; /* Position directly below the avatar */
|
177 |
right: 0;
|
|
|
178 |
background-color: #fff8f0;
|
179 |
+
border-radius: 8px;
|
180 |
+
width: 240px; /* Slightly wider for better readability */
|
181 |
+
box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.15);
|
|
|
182 |
border: 1px solid #ffd8b1;
|
183 |
+
display: none;
|
184 |
+
opacity: 0;
|
185 |
+
transform: translateY(-10px);
|
186 |
+
transition: opacity 0.2s ease, transform 0.2s ease;
|
187 |
+
z-index: 1050; /* Ensure it’s above other content */
|
188 |
+
max-height: 300px; /* Prevent overflow on small screens */
|
189 |
+
overflow-y: auto;
|
190 |
+
}
|
191 |
+
.dropdown-menu.show {
|
192 |
+
display: block;
|
193 |
+
opacity: 1;
|
194 |
+
transform: translateY(0);
|
195 |
}
|
196 |
.dropdown-menu .dropdown-item {
|
197 |
padding: 12px 16px;
|
198 |
text-decoration: none;
|
199 |
color: #333;
|
200 |
border-bottom: 1px solid #ffd8b1;
|
201 |
+
display: flex;
|
202 |
+
align-items: center;
|
203 |
font-size: 15px;
|
204 |
transition: background-color 0.2s ease;
|
205 |
}
|
206 |
+
.dropdown-menu .dropdown-item i {
|
207 |
+
margin-right: 10px; /* Space between icon and text */
|
208 |
+
font-size: 16px;
|
209 |
+
color: #007bff; /* Match avatar icon color */
|
210 |
+
}
|
211 |
.dropdown-menu .dropdown-item:last-child {
|
212 |
border-bottom: none;
|
213 |
}
|
|
|
885 |
border-radius: 8px;
|
886 |
font-weight: bold;
|
887 |
font-size: 16px;
|
|
|
888 |
display: flex;
|
889 |
align-items: center;
|
890 |
justify-content: center;
|
|
|
895 |
.bottom-action-bar .btn-order-history {
|
896 |
background: linear-gradient(45deg, #FF8C00, #32CD32);
|
897 |
border-color: transparent;
|
898 |
+
color: #000000; /* Black text */
|
899 |
}
|
900 |
.bottom-action-bar .btn-order-history:hover {
|
901 |
background: linear-gradient(45deg, #FF4500, #228B22);
|
902 |
border-color: transparent;
|
903 |
+
color: #000000; /* Black text on hover */
|
904 |
}
|
905 |
.bottom-action-bar .btn-view-cart {
|
906 |
background-color: #0FAA39;
|
907 |
border-color: #0FAA39;
|
908 |
+
color: white;
|
909 |
}
|
910 |
.bottom-action-bar .btn-view-cart:hover {
|
911 |
background-color: #0D9232;
|
|
|
959 |
}
|
960 |
.dropdown-menu {
|
961 |
width: 220px;
|
962 |
+
max-height: 250px; /* Adjusted for smaller screens */
|
963 |
+
border-radius: 6px;
|
964 |
}
|
965 |
.dropdown-menu .dropdown-item {
|
966 |
+
padding: 10px 14px;
|
967 |
+
font-size: 14px;
|
968 |
+
}
|
969 |
+
.dropdown-menu .dropdown-item i {
|
970 |
+
font-size: 14px;
|
971 |
+
margin-right: 8px;
|
972 |
}
|
973 |
.modal-dialog {
|
974 |
max-width: 90%;
|
|
|
1232 |
<span>{{ first_letter }}</span>
|
1233 |
</div>
|
1234 |
<div class="dropdown-menu">
|
1235 |
+
<a href="{{ url_for('user_details.customer_details') }}" class="dropdown-item"><i class="bi bi-person"></i> View Profile</a>
|
1236 |
+
<a href="{{ url_for('orderhistory.order_history') }}" class="dropdown-item"><i class="bi bi-clock-history"></i> Order History</a>
|
1237 |
+
<a href="{{ url_for('combined_summary.combined_summary') }}" class="dropdown-item"><i class="bi bi-bar-chart"></i> MY Summary</a>
|
1238 |
+
<a href="{{ url_for('logout') }}" class="dropdown-item"><i class="bi bi-box-arrow-right"></i> Logout</a>
|
1239 |
</div>
|
1240 |
</div>
|
1241 |
<div class="search-bar-container">
|
|
|
1854 |
const dropdownMenu = document.querySelector('.dropdown-menu');
|
1855 |
avatarContainer.addEventListener('click', function (event) {
|
1856 |
event.stopPropagation();
|
1857 |
+
dropdownMenu.classList.toggle('show');
|
1858 |
});
|
1859 |
document.addEventListener('click', function (event) {
|
1860 |
if (!avatarContainer.contains(event.target)) {
|
1861 |
+
dropdownMenu.classList.remove('show');
|
1862 |
}
|
1863 |
});
|
1864 |
const dropdownItems = document.querySelectorAll('.dropdown-item');
|
1865 |
dropdownItems.forEach(item => {
|
1866 |
item.addEventListener('click', function () {
|
1867 |
+
dropdownMenu.classList.remove('show');
|
1868 |
});
|
1869 |
});
|
1870 |
const searchBar = document.getElementById('searchBar');
|
|
|
1876 |
try {
|
1877 |
const { name, section } = JSON.parse(selectedItem);
|
1878 |
const menuCards = document.querySelectorAll('.menu-card');
|
1879 |
+
let targetButton = null;
|
|
|
1880 |
menuCards.forEach(card => {
|
1881 |
+
if (card.getAttribute('data-item-name') === name && card.getAttribute('data-item-section') === section) {
|
1882 |
+
targetButton = card.querySelector('.button-container');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1883 |
}
|
1884 |
});
|
1885 |
+
if (targetButton) {
|
1886 |
+
const itemName = targetButton.getAttribute('data-item-name');
|
1887 |
+
const itemPrice = targetButton.getAttribute('data-item-price');
|
1888 |
+
const itemImage = targetButton.getAttribute('data-item-image2');
|
1889 |
+
const itemDescription = targetButton.getAttribute('data-item-description');
|
1890 |
+
const itemSection = targetButton.getAttribute('data-item-section');
|
1891 |
+
const itemCategory = targetButton.getAttribute('data-item-category');
|
1892 |
+
if (itemSection === 'Soft Drinks') {
|
1893 |
+
showSoftDrinkModal(targetButton.querySelector('.add-to-cart-btn'));
|
1894 |
+
} else {
|
1895 |
+
showItemDetails(itemName, itemPrice, itemImage, itemDescription, itemSection, itemCategory);
|
1896 |
+
const modal = new bootstrap.Modal(document.getElementById('itemModal'));
|
1897 |
+
modal.show();
|
1898 |
+
}
|
|
|
1899 |
}
|
1900 |
+
localStorage.removeItem('selectedItem');
|
1901 |
} catch (e) {
|
1902 |
console.error('Error parsing selectedItem:', e);
|
|
|
1903 |
localStorage.removeItem('selectedItem');
|
1904 |
}
|
1905 |
}
|
1906 |
+
document.querySelectorAll('.menu-video').forEach(video => {
|
1907 |
+
video.addEventListener('loadeddata', () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1908 |
video.classList.add('active');
|
1909 |
+
video.previousElementSibling.classList.add('hidden');
|
1910 |
});
|
1911 |
+
video.addEventListener('error', () => {
|
|
|
1912 |
video.classList.remove('active');
|
1913 |
+
video.previousElementSibling.classList.remove('hidden');
|
|
|
|
|
1914 |
});
|
1915 |
+
});
|
1916 |
+
document.querySelectorAll('.media-wrapper').forEach(wrapper => {
|
1917 |
+
wrapper.addEventListener('mouseenter', () => {
|
1918 |
+
const video = wrapper.querySelector('.menu-video');
|
1919 |
+
if (video) {
|
1920 |
+
video.play().catch(err => console.warn('Video play failed:', err));
|
1921 |
+
}
|
|
|
1922 |
});
|
1923 |
+
wrapper.addEventListener('mouseleave', () => {
|
1924 |
+
const video = wrapper.querySelector('.menu-video');
|
1925 |
+
if (video) {
|
1926 |
+
video.pause();
|
1927 |
+
video.currentTime = 0;
|
1928 |
+
}
|
|
|
1929 |
});
|
1930 |
+
wrapper.addEventListener('touchstart', () => {
|
1931 |
+
wrapper.classList.add('touched');
|
1932 |
+
const video = wrapper.querySelector('.menu-video');
|
1933 |
+
if (video) {
|
1934 |
+
video.play().catch(err => console.warn('Video play failed:', err));
|
|
|
|
|
|
|
|
|
1935 |
}
|
1936 |
});
|
1937 |
+
wrapper.addEventListener('touchend', () => {
|
1938 |
+
setTimeout(() => {
|
1939 |
+
wrapper.classList.remove('touched');
|
1940 |
+
const video = wrapper.querySelector('.menu-video');
|
1941 |
+
if (video) {
|
1942 |
+
video.pause();
|
1943 |
+
video.currentTime = 0;
|
1944 |
+
}
|
1945 |
+
}, 1000);
|
1946 |
+
});
|
1947 |
});
|
|
|
|
|
1948 |
document.querySelectorAll('.toggle-details').forEach(toggle => {
|
1949 |
+
toggle.addEventListener('click', () => {
|
1950 |
+
const itemName = toggle.getAttribute('data-item-name').replace(/ /g, '-');
|
1951 |
+
const details = document.getElementById(`details-${itemName}`);
|
1952 |
if (details) {
|
1953 |
details.classList.toggle('show');
|
1954 |
+
toggle.textContent = details.classList.contains('show') ? 'Hide Details' : 'Show Details';
|
1955 |
}
|
1956 |
});
|
1957 |
});
|
|
|
|
|
1958 |
const decreaseBtn = document.getElementById('decreaseQuantity');
|
1959 |
const increaseBtn = document.getElementById('increaseQuantity');
|
1960 |
const quantityInput = document.getElementById('quantityInput');
|
|
|
1961 |
decreaseBtn.addEventListener('click', () => {
|
1962 |
let value = parseInt(quantityInput.value) || 1;
|
1963 |
if (value > 1) {
|
|
|
1965 |
updateModalPrice();
|
1966 |
}
|
1967 |
});
|
|
|
1968 |
increaseBtn.addEventListener('click', () => {
|
1969 |
let value = parseInt(quantityInput.value) || 1;
|
1970 |
quantityInput.value = value + 1;
|
1971 |
updateModalPrice();
|
1972 |
});
|
|
|
|
|
1973 |
updateCartUI(getCartLocalStorage());
|
|
|
|
|
1974 |
if ('webkitSpeechRecognition' in window || 'SpeechRecognition' in window) {
|
1975 |
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
1976 |
recognition = new SpeechRecognition();
|
1977 |
recognition.continuous = false;
|
1978 |
recognition.interimResults = true;
|
1979 |
recognition.lang = 'en-US';
|
|
|
1980 |
recognition.onstart = () => {
|
1981 |
document.getElementById('mic-status').textContent = 'Listening...';
|
1982 |
document.getElementById('mic-icon-animation').classList.add('bi-mic-fill');
|
1983 |
document.getElementById('mic-icon-animation').classList.remove('bi-mic');
|
1984 |
};
|
|
|
1985 |
recognition.onresult = (event) => {
|
1986 |
let interimTranscript = '';
|
1987 |
let finalTranscript = '';
|
|
|
1988 |
for (let i = event.resultIndex; i < event.results.length; i++) {
|
1989 |
const transcript = event.results[i][0].transcript;
|
1990 |
if (event.results[i].isFinal) {
|
|
|
1993 |
interimTranscript += transcript;
|
1994 |
}
|
1995 |
}
|
|
|
1996 |
document.getElementById('mic-status').textContent = interimTranscript || finalTranscript;
|
|
|
1997 |
if (finalTranscript) {
|
1998 |
const spokenItem = menuItems.find(item =>
|
1999 |
item.name.toLowerCase().includes(finalTranscript.toLowerCase())
|
2000 |
);
|
|
|
2001 |
if (spokenItem) {
|
2002 |
document.getElementById('mic-status').style.display = 'none';
|
2003 |
document.getElementById('mic-item-details').style.display = 'block';
|
2004 |
document.getElementById('mic-item-name').textContent = spokenItem.name;
|
2005 |
document.getElementById('mic-item-image').src = spokenItem.image || '/static/placeholder.jpg';
|
|
|
2006 |
const menuCards = document.querySelectorAll('.menu-card');
|
2007 |
let targetButton = null;
|
2008 |
menuCards.forEach(card => {
|
|
|
2011 |
targetButton = card.querySelector('.button-container');
|
2012 |
}
|
2013 |
});
|
|
|
2014 |
if (targetButton) {
|
2015 |
const name = targetButton.getAttribute('data-item-name');
|
2016 |
const price = targetButton.getAttribute('data-item-price');
|
|
|
2018 |
const description = targetButton.getAttribute('data-item-description');
|
2019 |
const section = targetButton.getAttribute('data-item-section');
|
2020 |
const category = targetButton.getAttribute('data-item-category');
|
|
|
2021 |
setTimeout(() => {
|
2022 |
recognition.stop();
|
2023 |
const micModal = bootstrap.Modal.getInstance(document.getElementById('micModal'));
|
2024 |
micModal.hide();
|
|
|
2025 |
if (section === 'Soft Drinks') {
|
2026 |
showSoftDrinkModal(targetButton.querySelector('.add-to-cart-btn'));
|
2027 |
} else {
|
|
|
2034 |
}
|
2035 |
}
|
2036 |
};
|
|
|
2037 |
recognition.onend = () => {
|
2038 |
document.getElementById('mic-icon-animation').classList.remove('bi-mic-fill');
|
2039 |
document.getElementById('mic-icon-animation').classList.add('bi-mic');
|
2040 |
document.getElementById('micIcon').classList.remove('active');
|
2041 |
};
|
|
|
2042 |
recognition.onerror = (event) => {
|
2043 |
console.error('Speech recognition error:', event.error);
|
2044 |
document.getElementById('mic-status').textContent = 'Error occurred. Please try again.';
|
|
|
2046 |
stopSpeechRecognition();
|
2047 |
}, 2000);
|
2048 |
};
|
|
|
2049 |
document.getElementById('micIcon').addEventListener('click', () => {
|
2050 |
if (!recognition) return;
|
|
|
2051 |
document.getElementById('micIcon').classList.add('active');
|
2052 |
const micModal = new bootstrap.Modal(document.getElementById('micModal'));
|
2053 |
micModal.show();
|
|
|
2058 |
document.getElementById('micIcon').style.display = 'none';
|
2059 |
console.warn('Speech recognition not supported in this browser.');
|
2060 |
}
|
|
|
|
|
2061 |
const descriptionInput = document.getElementById('custom-dish-description');
|
2062 |
const suggestionsContainer = document.getElementById('descriptionSuggestions');
|
|
|
2063 |
if (descriptionInput && suggestionsContainer) {
|
2064 |
const showSuggestions = (suggestions) => {
|
2065 |
suggestionsContainer.innerHTML = '';
|
|
|
2079 |
});
|
2080 |
suggestionsContainer.style.display = 'block';
|
2081 |
};
|
|
|
2082 |
const filterSuggestions = (input) => {
|
2083 |
const inputWords = input.toLowerCase().split(/\s+/);
|
2084 |
return ingredientsList.filter(ingredient =>
|
|
|
2087 |
)
|
2088 |
).slice(0, 5);
|
2089 |
};
|
|
|
2090 |
descriptionInput.addEventListener('input', debounce(() => {
|
2091 |
const input = descriptionInput.value.trim();
|
2092 |
if (input) {
|
|
|
2096 |
suggestionsContainer.style.display = 'none';
|
2097 |
}
|
2098 |
}, 300));
|
|
|
2099 |
document.addEventListener('click', (event) => {
|
2100 |
if (!descriptionInput.contains(event.target) && !suggestionsContainer.contains(event.target)) {
|
2101 |
suggestionsContainer.style.display = 'none';
|
|
|
2105 |
});
|
2106 |
</script>
|
2107 |
</body>
|
2108 |
+
</html>
|
|