Update templates/menu.html
Browse files- templates/menu.html +375 -373
templates/menu.html
CHANGED
@@ -1097,7 +1097,7 @@
|
|
1097 |
justify-content: center;
|
1098 |
font-size: 12px;
|
1099 |
margin-left: 8px;
|
1100 |
-
box-shadow: 0 1px
|
1101 |
}
|
1102 |
/* Mobile-Specific Styles */
|
1103 |
@media (max-width: 576px) {
|
@@ -1516,7 +1516,7 @@
|
|
1516 |
data-item-section="{{ item.Section__c | default(section) }}"
|
1517 |
data-item-category="{{ selected_category }}"
|
1518 |
data-item-description="{{ item.Description__c | default('No description') }}"
|
1519 |
-
data-item-image2="{{ item.Image2__c | default(item.Image1__c) }}">
|
1520 |
{% if item.Section__c == 'Soft Drinks' %}
|
1521 |
<button class="btn btn-primary add-to-cart-btn" onclick="showSoftDrinkModal(this)">ADD</button>
|
1522 |
{% else %}
|
@@ -1825,7 +1825,9 @@
|
|
1825 |
modalSectionEl.setAttribute('data-section', section);
|
1826 |
modalSectionEl.setAttribute('data-category', selectedCategory);
|
1827 |
document.getElementById('quantityInput').value = 1;
|
1828 |
-
|
|
|
|
|
1829 |
.then(response => response.json())
|
1830 |
.then(data => {
|
1831 |
const addonsList = document.getElementById('addons-list');
|
@@ -1849,400 +1851,400 @@
|
|
1849 |
addonSection.appendChild(addonHeader);
|
1850 |
const addonCollapse = document.createElement('div');
|
1851 |
addonCollapse.id = `addon-collapse-${addon.section.replace(/\s+/g, '-')}`;
|
1852 |
-
|
1853 |
addon.items.forEach(item => {
|
1854 |
const addonItem = document.createElement('div');
|
1855 |
addonItem.className = 'form-check';
|
1856 |
const input = document.createElement('input');
|
1857 |
input.type = 'checkbox';
|
1858 |
input.className = 'form-check-input';
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1881 |
}
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
const addonsList = document.getElementById('addons-list');
|
1886 |
-
addonsList.classList.remove('addon-loading');
|
1887 |
-
addonsList.innerHTML = '<p class="text-muted">Failed to load add-ons.</p>';
|
1888 |
-
});
|
1889 |
-
}
|
1890 |
-
function addToCartFromModal() {
|
1891 |
-
if (isProcessingRequest) return;
|
1892 |
-
isProcessingRequest = true;
|
1893 |
-
const itemName = document.getElementById('modal-name').innerText;
|
1894 |
-
const quantity = parseInt(document.getElementById('quantityInput').value) || 1;
|
1895 |
-
const instructions = document.getElementById('modal-instructions').value;
|
1896 |
-
const selectedAddOns = Array.from(
|
1897 |
-
document.querySelectorAll('#addons-list input[type="checkbox"]:checked')
|
1898 |
-
).map(addon => ({
|
1899 |
-
section: addon.getAttribute('data-section'),
|
1900 |
-
name: addon.getAttribute('data-name'),
|
1901 |
-
price: parseFloat(addon.getAttribute('data-price')) || 0
|
1902 |
-
}));
|
1903 |
-
const modalSectionEl = document.getElementById('modal-section');
|
1904 |
-
const section = modalSectionEl.getAttribute('data-section');
|
1905 |
-
const selectedCategory = modalSectionEl.getAttribute('data-category');
|
1906 |
-
const totalAddOnPrice = selectedAddOns.reduce((sum, addon) => sum + addon.price, 0);
|
1907 |
-
const totalPrice = (baseItemPrice + totalAddOnPrice);
|
1908 |
-
const modalImg = document.getElementById('modal-img').src;
|
1909 |
-
const cartPayload = {
|
1910 |
-
itemName: itemName,
|
1911 |
-
itemPrice: totalPrice,
|
1912 |
-
itemImage: modalImg,
|
1913 |
-
section: section,
|
1914 |
-
category: selectedCategory,
|
1915 |
-
addons: selectedAddOns,
|
1916 |
-
instructions: instructions,
|
1917 |
-
quantity: quantity
|
1918 |
-
};
|
1919 |
-
fetch('/cart/add', {
|
1920 |
-
method: 'POST',
|
1921 |
-
headers: {
|
1922 |
-
'Content-Type': 'application/json',
|
1923 |
-
},
|
1924 |
-
body: JSON.stringify(cartPayload)
|
1925 |
-
})
|
1926 |
-
.then(response => response.json())
|
1927 |
-
.then(data => {
|
1928 |
-
isProcessingRequest = false;
|
1929 |
-
if (data.success) {
|
1930 |
-
updateCartUI(data.cart);
|
1931 |
-
const modal = bootstrap.Modal.getInstance(document.getElementById('itemModal'));
|
1932 |
-
modal.hide();
|
1933 |
-
} else {
|
1934 |
-
console.error('Failed to add item to cart:', data.error);
|
1935 |
-
const cart = addToCartLocalStorage(cartPayload);
|
1936 |
-
updateCartUI(cart);
|
1937 |
-
const modal = bootstrap.Modal.getInstance(document.getElementById('itemModal'));
|
1938 |
-
modal.hide();
|
1939 |
}
|
1940 |
-
})
|
1941 |
-
.catch(err => {
|
1942 |
-
isProcessingRequest = false;
|
1943 |
-
console.error('Error adding item to cart:', err);
|
1944 |
-
const cart = addToCartLocalStorage(cartPayload);
|
1945 |
-
updateCartUI(cart);
|
1946 |
-
const modal = bootstrap.Modal.getInstance(document.getElementById('itemModal'));
|
1947 |
-
modal.hide();
|
1948 |
});
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
if (
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1968 |
}
|
1969 |
}
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
document.addEventListener('DOMContentLoaded', function () {
|
1987 |
-
const avatarIcon = document.querySelector('.avatar-icon');
|
1988 |
-
const dropdownMenu = document.querySelector('.dropdown-menu');
|
1989 |
-
avatarIcon.addEventListener('click', function () {
|
1990 |
-
dropdownMenu.classList.toggle('show');
|
1991 |
});
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996 |
});
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2031 |
showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
|
2032 |
} else {
|
2033 |
showItemDetails(
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
);
|
2041 |
const modal = new bootstrap.Modal(document.getElementById('itemModal'));
|
2042 |
modal.show();
|
2043 |
}
|
2044 |
-
searchBar.value = '';
|
2045 |
-
searchSuggestions.innerHTML = '';
|
2046 |
-
searchSuggestions.style.display = 'none';
|
2047 |
}
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
}, 300));
|
2053 |
-
document.addEventListener('click', function (event) {
|
2054 |
-
if (!searchBar.contains(event.target) && !searchSuggestions.contains(event.target)) {
|
2055 |
-
searchSuggestions.style.display = 'none';
|
2056 |
-
}
|
2057 |
-
});
|
2058 |
-
if (localStorage.getItem('selectedItem')) {
|
2059 |
-
try {
|
2060 |
-
const selectedItem = JSON.parse(localStorage.getItem('selectedItem'));
|
2061 |
-
const card = document.querySelector(`.menu-card[data-item-name="${selectedItem.name}"]`);
|
2062 |
-
if (card) {
|
2063 |
-
card.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
2064 |
-
card.classList.add('highlighted');
|
2065 |
-
setTimeout(() => card.classList.remove('highlighted'), 2000);
|
2066 |
-
const buttonContainer = card.querySelector('.button-container');
|
2067 |
-
if (selectedItem.section === 'Soft Drinks') {
|
2068 |
-
showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
|
2069 |
-
} else {
|
2070 |
-
showItemDetails(
|
2071 |
-
selectedItem.name,
|
2072 |
-
selectedItem.price,
|
2073 |
-
selectedItem.image2 || selectedItem.image,
|
2074 |
-
selectedItem.description,
|
2075 |
-
selectedItem.section,
|
2076 |
-
selectedItem.category
|
2077 |
-
);
|
2078 |
-
const modal = new bootstrap.Modal(document.getElementById('itemModal'));
|
2079 |
-
modal.show();
|
2080 |
}
|
2081 |
}
|
2082 |
-
|
2083 |
-
} catch (err) {
|
2084 |
-
console.error('Error processing selected item:', err);
|
2085 |
-
localStorage.removeItem('selectedItem');
|
2086 |
-
}
|
2087 |
-
}
|
2088 |
-
document.querySelectorAll('.media-wrapper').forEach(wrapper => {
|
2089 |
-
const video = wrapper.querySelector('.menu-video');
|
2090 |
-
const image = wrapper.querySelector('.menu-image');
|
2091 |
-
wrapper.addEventListener('mouseenter', () => {
|
2092 |
-
image.classList.add('hidden');
|
2093 |
-
video.classList.add('active');
|
2094 |
-
video.play().catch(err => {
|
2095 |
-
console.error('Video playback failed:', err);
|
2096 |
-
image.classList.remove('hidden');
|
2097 |
-
video.classList.remove('active');
|
2098 |
-
});
|
2099 |
-
});
|
2100 |
-
wrapper.addEventListener('mouseleave', () => {
|
2101 |
-
video.classList.remove('active');
|
2102 |
-
video.pause();
|
2103 |
-
video.currentTime = 0;
|
2104 |
-
image.classList.remove('hidden');
|
2105 |
-
});
|
2106 |
-
let touchTimeout;
|
2107 |
-
wrapper.addEventListener('touchstart', (e) => {
|
2108 |
-
e.preventDefault();
|
2109 |
-
clearTimeout(touchTimeout);
|
2110 |
-
wrapper.classList.add('touched');
|
2111 |
-
image.classList.add('hidden');
|
2112 |
-
video.classList.add('active');
|
2113 |
-
video.play().catch(err => {
|
2114 |
-
console.error('Video playback failed:', err);
|
2115 |
-
image.classList.remove('hidden');
|
2116 |
-
video.classList.remove('active');
|
2117 |
-
wrapper.classList.remove('touched');
|
2118 |
-
});
|
2119 |
-
});
|
2120 |
-
wrapper.addEventListener('touchend', () => {
|
2121 |
-
touchTimeout = setTimeout(() => {
|
2122 |
-
video.pause();
|
2123 |
-
video.classList.remove('active');
|
2124 |
-
image.classList.remove('hidden');
|
2125 |
-
wrapper.classList.remove('touched');
|
2126 |
-
}, 500);
|
2127 |
-
});
|
2128 |
-
});
|
2129 |
-
const decreaseBtn = document.getElementById('decreaseQuantity');
|
2130 |
-
const increaseBtn = document.getElementById('increaseQuantity');
|
2131 |
-
const quantityInput = document.getElementById('quantityInput');
|
2132 |
-
decreaseBtn.addEventListener('click', () => {
|
2133 |
-
let value = parseInt(quantityInput.value) || 1;
|
2134 |
-
if (value > 1) {
|
2135 |
-
quantityInput.value = value - 1;
|
2136 |
-
}
|
2137 |
-
});
|
2138 |
-
increaseBtn.addEventListener('click', () => {
|
2139 |
-
let value = parseInt(quantityInput.value) || 1;
|
2140 |
-
quantityInput.value = value + 1;
|
2141 |
-
});
|
2142 |
-
document.querySelectorAll('.toggle-details').forEach(link => {
|
2143 |
-
link.addEventListener('click', () => {
|
2144 |
-
const details = link.nextElementSibling;
|
2145 |
-
if (details.classList.contains('show')) {
|
2146 |
-
details.classList.remove('show');
|
2147 |
-
link.textContent = 'Show Details';
|
2148 |
-
} else {
|
2149 |
-
details.classList.add('show');
|
2150 |
-
link.textContent = 'Hide Details';
|
2151 |
-
}
|
2152 |
-
});
|
2153 |
-
});
|
2154 |
-
fetch('/cart')
|
2155 |
-
.then(response => response.json())
|
2156 |
-
.then(data => {
|
2157 |
-
if (data.success) {
|
2158 |
-
updateCartUI(data.cart);
|
2159 |
-
} else {
|
2160 |
-
updateCartUI(getCartLocalStorage());
|
2161 |
-
}
|
2162 |
-
})
|
2163 |
-
.catch(err => {
|
2164 |
-
console.error('Error fetching cart:', err);
|
2165 |
-
updateCartUI(getCartLocalStorage());
|
2166 |
-
});
|
2167 |
-
if ('webkitSpeechRecognition' in window) {
|
2168 |
-
recognition = new webkitSpeechRecognition();
|
2169 |
-
recognition.continuous = false;
|
2170 |
-
recognition.interimResults = false;
|
2171 |
-
recognition.lang = 'en-US';
|
2172 |
-
recognition.onstart = () => {
|
2173 |
-
document.getElementById('mic-icon-animation').classList.add('active');
|
2174 |
-
document.getElementById('mic-status').textContent = 'Listening...';
|
2175 |
-
};
|
2176 |
-
recognition.onresult = (event) => {
|
2177 |
-
const transcript = event.results[0][0].transcript.trim().toLowerCase();
|
2178 |
-
console.log('Recognized speech:', transcript);
|
2179 |
-
const matchedItem = menuItems.find(item =>
|
2180 |
-
item.name.toLowerCase().includes(transcript)
|
2181 |
-
);
|
2182 |
-
if (matchedItem) {
|
2183 |
-
const micStatus = document.getElementById('mic-status');
|
2184 |
-
const micItemDetails = document.getElementById('mic-item-details');
|
2185 |
-
const micItemName = document.getElementById('mic-item-name');
|
2186 |
-
const micItemImage = document.getElementById('mic-item-image');
|
2187 |
-
micStatus.style.display = 'none';
|
2188 |
-
micItemDetails.style.display = 'block';
|
2189 |
-
micItemName.textContent = matchedItem.name;
|
2190 |
-
micItemImage.src = matchedItem.image || '/static/placeholder.jpg';
|
2191 |
-
setTimeout(() => {
|
2192 |
-
recognition.stop();
|
2193 |
-
const card = document.querySelector(`.menu-card[data-item-name="${matchedItem.name}"]`);
|
2194 |
-
if (card) {
|
2195 |
-
card.classList.add('highlighted');
|
2196 |
-
card.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
2197 |
-
setTimeout(() => card.classList.remove('highlighted'), 2000);
|
2198 |
-
const buttonContainer = card.querySelector('.button-container');
|
2199 |
-
if (buttonContainer) {
|
2200 |
-
if (matchedItem.section === 'Soft Drinks') {
|
2201 |
-
showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
|
2202 |
-
} else {
|
2203 |
-
showItemDetails(
|
2204 |
-
matchedItem.name,
|
2205 |
-
matchedItem.price,
|
2206 |
-
matchedItem.image2 || matchedItem.image,
|
2207 |
-
matchedItem.description,
|
2208 |
-
matchedItem.section,
|
2209 |
-
matchedItem.category
|
2210 |
-
);
|
2211 |
-
const modal = new bootstrap.Modal(document.getElementById('itemModal'));
|
2212 |
-
modal.show();
|
2213 |
-
}
|
2214 |
-
}
|
2215 |
-
const micModal = bootstrap.Modal.getInstance(document.getElementById('micModal'));
|
2216 |
-
if (micModal) {
|
2217 |
-
micModal.hide();
|
2218 |
-
resetMicModal();
|
2219 |
-
}
|
2220 |
-
}
|
2221 |
-
}, 2000);
|
2222 |
-
} else {
|
2223 |
-
document.getElementById('mic-status').textContent = 'Item not found. Try again.';
|
2224 |
-
}
|
2225 |
-
};
|
2226 |
-
recognition.onerror = (event) => {
|
2227 |
-
console.error('Speech recognition error:', event.error);
|
2228 |
-
document.getElementById('mic-status').textContent = 'Error occurred. Please try again.';
|
2229 |
-
document.getElementById('mic-icon-animation').classList.remove('active');
|
2230 |
-
};
|
2231 |
-
recognition.onend = () => {
|
2232 |
-
document.getElementById('mic-icon-animation').classList.remove('active');
|
2233 |
-
};
|
2234 |
-
document.getElementById('micIcon').addEventListener('click', () => {
|
2235 |
-
if (!recognition) return;
|
2236 |
-
const micModal = new bootstrap.Modal(document.getElementById('micModal'));
|
2237 |
-
micModal.show();
|
2238 |
-
resetMicModal();
|
2239 |
-
recognition.start();
|
2240 |
-
});
|
2241 |
-
document.getElementById('stopMicBtn').addEventListener('click', stopSpeechRecognition);
|
2242 |
} else {
|
2243 |
-
document.getElementById('
|
2244 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2245 |
});
|
2246 |
-
|
|
|
|
|
|
|
|
|
|
|
2247 |
</body>
|
2248 |
</html>
|
|
|
1097 |
justify-content: center;
|
1098 |
font-size: 12px;
|
1099 |
margin-left: 8px;
|
1100 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
1101 |
}
|
1102 |
/* Mobile-Specific Styles */
|
1103 |
@media (max-width: 576px) {
|
|
|
1516 |
data-item-section="{{ item.Section__c | default(section) }}"
|
1517 |
data-item-category="{{ selected_category }}"
|
1518 |
data-item-description="{{ item.Description__c | default('No description') }}"
|
1519 |
+
data-item-image2="{{ item.Image2__c | default(item.Image1__c) | default('/static/placeholder.jpg') }}">
|
1520 |
{% if item.Section__c == 'Soft Drinks' %}
|
1521 |
<button class="btn btn-primary add-to-cart-btn" onclick="showSoftDrinkModal(this)">ADD</button>
|
1522 |
{% else %}
|
|
|
1825 |
modalSectionEl.setAttribute('data-section', section);
|
1826 |
modalSectionEl.setAttribute('data-category', selectedCategory);
|
1827 |
document.getElementById('quantityInput').value = 1;
|
1828 |
+
const isVegFilter = document.getElementById('veg-toggle').checked;
|
1829 |
+
const vegParam = isVegFilter ? '&veg=Veg' : '';
|
1830 |
+
fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}${vegParam}`)
|
1831 |
.then(response => response.json())
|
1832 |
.then(data => {
|
1833 |
const addonsList = document.getElementById('addons-list');
|
|
|
1851 |
addonSection.appendChild(addonHeader);
|
1852 |
const addonCollapse = document.createElement('div');
|
1853 |
addonCollapse.id = `addon-collapse-${addon.section.replace(/\s+/g, '-')}`;
|
1854 |
+
addonCollapse.className = 'addon-options collapse show';
|
1855 |
addon.items.forEach(item => {
|
1856 |
const addonItem = document.createElement('div');
|
1857 |
addonItem.className = 'form-check';
|
1858 |
const input = document.createElement('input');
|
1859 |
input.type = 'checkbox';
|
1860 |
input.className = 'form-check-input';
|
1861 |
+
input.id = `addon-${item.name.replace(/\s+/g, '-')}`;
|
1862 |
+
input.setAttribute('data-price', item.price || 0);
|
1863 |
+
input.setAttribute('data-name', item.name);
|
1864 |
+
input.setAttribute('data-section', addon.section);
|
1865 |
+
input.addEventListener('change', updateModalPrice);
|
1866 |
+
const label = document.createElement('label');
|
1867 |
+
label.className = 'form-check-label';
|
1868 |
+
label.htmlFor = `addon-${item.name.replace(/\s+/g, '-')}`;
|
1869 |
+
label.textContent = item.name;
|
1870 |
+
if (item.price > 0) {
|
1871 |
+
const priceSpan = document.createElement('span');
|
1872 |
+
priceSpan.className = 'extra-charge';
|
1873 |
+
priceSpan.textContent = `+$${parseFloat(item.price).toFixed(2)}`;
|
1874 |
+
label.appendChild(priceSpan);
|
1875 |
+
}
|
1876 |
+
addonItem.appendChild(input);
|
1877 |
+
addonItem.appendChild(label);
|
1878 |
+
addonCollapse.appendChild(addonItem);
|
1879 |
+
});
|
1880 |
+
addonSection.appendChild(addonCollapse);
|
1881 |
+
addonsList.appendChild(addonSection);
|
1882 |
+
});
|
1883 |
+
}
|
1884 |
+
})
|
1885 |
+
.catch(err => {
|
1886 |
+
console.error('Error fetching addons:', err);
|
1887 |
+
const addonsList = document.getElementById('addons-list');
|
1888 |
+
addonsList.classList.remove('addon-loading');
|
1889 |
+
addonsList.innerHTML = '<p class="text-muted">Failed to load add-ons.</p>';
|
1890 |
+
});
|
1891 |
+
}
|
1892 |
+
function addToCartFromModal() {
|
1893 |
+
if (isProcessingRequest) return;
|
1894 |
+
isProcessingRequest = true;
|
1895 |
+
const itemName = document.getElementById('modal-name').innerText;
|
1896 |
+
const quantity = parseInt(document.getElementById('quantityInput').value) || 1;
|
1897 |
+
const instructions = document.getElementById('modal-instructions').value;
|
1898 |
+
const selectedAddOns = Array.from(
|
1899 |
+
document.querySelectorAll('#addons-list input[type="checkbox"]:checked')
|
1900 |
+
).map(addon => ({
|
1901 |
+
section: addon.getAttribute('data-section'),
|
1902 |
+
name: addon.getAttribute('data-name'),
|
1903 |
+
price: parseFloat(addon.getAttribute('data-price')) || 0
|
1904 |
+
}));
|
1905 |
+
const modalSectionEl = document.getElementById('modal-section');
|
1906 |
+
const section = modalSectionEl.getAttribute('data-section');
|
1907 |
+
const selectedCategory = modalSectionEl.getAttribute('data-category');
|
1908 |
+
const totalAddOnPrice = selectedAddOns.reduce((sum, addon) => sum + addon.price, 0);
|
1909 |
+
const totalPrice = (baseItemPrice + totalAddOnPrice);
|
1910 |
+
const modalImg = document.getElementById('modal-img').src;
|
1911 |
+
const cartPayload = {
|
1912 |
+
itemName: itemName,
|
1913 |
+
itemPrice: totalPrice,
|
1914 |
+
itemImage: modalImg,
|
1915 |
+
section: section,
|
1916 |
+
category: selectedCategory,
|
1917 |
+
addons: selectedAddOns,
|
1918 |
+
instructions: instructions,
|
1919 |
+
quantity: quantity
|
1920 |
+
};
|
1921 |
+
fetch('/cart/add', {
|
1922 |
+
method: 'POST',
|
1923 |
+
headers: {
|
1924 |
+
'Content-Type': 'application/json',
|
1925 |
+
},
|
1926 |
+
body: JSON.stringify(cartPayload)
|
1927 |
+
})
|
1928 |
+
.then(response => response.json())
|
1929 |
+
.then(data => {
|
1930 |
+
isProcessingRequest = false;
|
1931 |
+
if (data.success) {
|
1932 |
+
updateCartUI(data.cart);
|
1933 |
+
const modal = bootstrap.Modal.getInstance(document.getElementById('itemModal'));
|
1934 |
+
modal.hide();
|
1935 |
+
} else {
|
1936 |
+
console.error('Failed to add item to cart:', data.error);
|
1937 |
+
const cart = addToCartLocalStorage(cartPayload);
|
1938 |
+
updateCartUI(cart);
|
1939 |
+
const modal = bootstrap.Modal.getInstance(document.getElementById('itemModal'));
|
1940 |
+
modal.hide();
|
1941 |
+
}
|
1942 |
+
})
|
1943 |
+
.catch(err => {
|
1944 |
+
isProcessingRequest = false;
|
1945 |
+
console.error('Error adding item to cart:', err);
|
1946 |
+
const cart = addToCartLocalStorage(cartPayload);
|
1947 |
+
updateCartUI(cart);
|
1948 |
+
const modal = bootstrap.Modal.getInstance(document.getElementById('itemModal'));
|
1949 |
+
modal.hide();
|
1950 |
+
});
|
1951 |
+
}
|
1952 |
+
function resetMicModal() {
|
1953 |
+
const micStatus = document.getElementById('mic-status');
|
1954 |
+
const micItemDetails = document.getElementById('mic-item-details');
|
1955 |
+
const micItemName = document.getElementById('mic-item-name');
|
1956 |
+
const micItemImage = document.getElementById('mic-item-image');
|
1957 |
+
micStatus.textContent = 'Say the name of a menu item...';
|
1958 |
+
micStatus.style.display = 'block';
|
1959 |
+
micItemDetails.style.display = 'none';
|
1960 |
+
micItemName.textContent = '';
|
1961 |
+
micItemImage.src = '/static/placeholder.jpg';
|
1962 |
+
}
|
1963 |
+
function stopSpeechRecognition() {
|
1964 |
+
if (recognition) {
|
1965 |
+
recognition.stop();
|
1966 |
+
const micModal = bootstrap.Modal.getInstance(document.getElementById('micModal'));
|
1967 |
+
if (micModal) {
|
1968 |
+
micModal.hide();
|
1969 |
+
resetMicModal();
|
1970 |
+
}
|
1971 |
+
}
|
1972 |
+
}
|
1973 |
+
function handleToggle(toggleType) {
|
1974 |
+
const vegToggle = document.getElementById('veg-toggle');
|
1975 |
+
const customToggle = document.getElementById('category-CustomizedDish');
|
1976 |
+
let url = '/menu?';
|
1977 |
+
const params = [];
|
1978 |
+
if (toggleType === 'veg' && vegToggle.checked) {
|
1979 |
+
params.push('veg=Veg');
|
1980 |
+
customToggle.checked = false;
|
1981 |
+
} else if (toggleType === 'custom' && customToggle.checked) {
|
1982 |
+
params.push('category=Customized+Dish');
|
1983 |
+
vegToggle.checked = false;
|
1984 |
+
}
|
1985 |
+
url += params.join('&');
|
1986 |
+
window.location.href = url;
|
1987 |
+
}
|
1988 |
+
document.addEventListener('DOMContentLoaded', function () {
|
1989 |
+
const avatarIcon = document.querySelector('.avatar-icon');
|
1990 |
+
const dropdownMenu = document.querySelector('.dropdown-menu');
|
1991 |
+
avatarIcon.addEventListener('click', function () {
|
1992 |
+
dropdownMenu.classList.toggle('show');
|
1993 |
+
});
|
1994 |
+
document.addEventListener('click', function (event) {
|
1995 |
+
if (!avatarIcon.contains(event.target) && !dropdownMenu.contains(event.target)) {
|
1996 |
+
dropdownMenu.classList.remove('show');
|
1997 |
+
}
|
1998 |
+
});
|
1999 |
+
const searchBar = document.getElementById('searchBar');
|
2000 |
+
const searchSuggestions = document.getElementById('searchSuggestions');
|
2001 |
+
searchBar.addEventListener('input', debounce(function () {
|
2002 |
+
const query = searchBar.value.trim().toLowerCase();
|
2003 |
+
searchSuggestions.innerHTML = '';
|
2004 |
+
if (query.length < 2) {
|
2005 |
+
searchSuggestions.style.display = 'none';
|
2006 |
+
return;
|
2007 |
+
}
|
2008 |
+
const filteredItems = menuItems.filter(item =>
|
2009 |
+
item.name.toLowerCase().includes(query) || item.section.toLowerCase().includes(query)
|
2010 |
+
);
|
2011 |
+
if (filteredItems.length === 0) {
|
2012 |
+
searchSuggestions.style.display = 'none';
|
2013 |
+
return;
|
2014 |
+
}
|
2015 |
+
filteredItems.forEach(item => {
|
2016 |
+
const suggestion = document.createElement('div');
|
2017 |
+
suggestion.classList.add('autocomplete-suggestion');
|
2018 |
+
const img = document.createElement('img');
|
2019 |
+
img.src = item.image || '/static/placeholder.jpg';
|
2020 |
+
img.alt = item.name;
|
2021 |
+
suggestion.appendChild(img);
|
2022 |
+
const text = document.createElement('span');
|
2023 |
+
text.textContent = item.name;
|
2024 |
+
suggestion.appendChild(text);
|
2025 |
+
suggestion.addEventListener('click', () => {
|
2026 |
+
const card = document.querySelector(`.menu-card[data-item-name="${item.name}"]`);
|
2027 |
+
if (card) {
|
2028 |
+
card.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
2029 |
+
card.classList.add('highlighted');
|
2030 |
+
setTimeout(() => card.classList.remove('highlighted'), 2000);
|
2031 |
+
const buttonContainer = card.querySelector('.button-container');
|
2032 |
+
if (item.section === 'Soft Drinks') {
|
2033 |
+
showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
|
2034 |
+
} else {
|
2035 |
+
showItemDetails(
|
2036 |
+
item.name,
|
2037 |
+
item.price,
|
2038 |
+
item.image2 || item.image,
|
2039 |
+
item.description,
|
2040 |
+
item.section,
|
2041 |
+
item.category
|
2042 |
+
);
|
2043 |
+
const modal = new bootstrap.Modal(document.getElementById('itemModal'));
|
2044 |
+
modal.show();
|
2045 |
}
|
2046 |
+
searchBar.value = '';
|
2047 |
+
searchSuggestions.innerHTML = '';
|
2048 |
+
searchSuggestions.style.display = 'none';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2049 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2050 |
});
|
2051 |
+
searchSuggestions.appendChild(suggestion);
|
2052 |
+
});
|
2053 |
+
searchSuggestions.style.display = 'block';
|
2054 |
+
}, 300));
|
2055 |
+
document.addEventListener('click', function (event) {
|
2056 |
+
if (!searchBar.contains(event.target) && !searchSuggestions.contains(event.target)) {
|
2057 |
+
searchSuggestions.style.display = 'none';
|
2058 |
+
}
|
2059 |
+
});
|
2060 |
+
if (localStorage.getItem('selectedItem')) {
|
2061 |
+
try {
|
2062 |
+
const selectedItem = JSON.parse(localStorage.getItem('selectedItem'));
|
2063 |
+
const card = document.querySelector(`.menu-card[data-item-name="${selectedItem.name}"]`);
|
2064 |
+
if (card) {
|
2065 |
+
card.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
2066 |
+
card.classList.add('highlighted');
|
2067 |
+
setTimeout(() => card.classList.remove('highlighted'), 2000);
|
2068 |
+
const buttonContainer = card.querySelector('.button-container');
|
2069 |
+
if (selectedItem.section === 'Soft Drinks') {
|
2070 |
+
showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
|
2071 |
+
} else {
|
2072 |
+
showItemDetails(
|
2073 |
+
selectedItem.name,
|
2074 |
+
selectedItem.price,
|
2075 |
+
selectedItem.image2 || selectedItem.image,
|
2076 |
+
selectedItem.description,
|
2077 |
+
selectedItem.section,
|
2078 |
+
selectedItem.category
|
2079 |
+
);
|
2080 |
+
const modal = new bootstrap.Modal(document.getElementById('itemModal'));
|
2081 |
+
modal.show();
|
2082 |
}
|
2083 |
}
|
2084 |
+
localStorage.removeItem('selectedItem');
|
2085 |
+
} catch (err) {
|
2086 |
+
console.error('Error processing selected item:', err);
|
2087 |
+
localStorage.removeItem('selectedItem');
|
2088 |
+
}
|
2089 |
+
}
|
2090 |
+
document.querySelectorAll('.media-wrapper').forEach(wrapper => {
|
2091 |
+
const video = wrapper.querySelector('.menu-video');
|
2092 |
+
const image = wrapper.querySelector('.menu-image');
|
2093 |
+
wrapper.addEventListener('mouseenter', () => {
|
2094 |
+
image.classList.add('hidden');
|
2095 |
+
video.classList.add('active');
|
2096 |
+
video.play().catch(err => {
|
2097 |
+
console.error('Video playback failed:', err);
|
2098 |
+
image.classList.remove('hidden');
|
2099 |
+
video.classList.remove('active');
|
|
|
|
|
|
|
|
|
|
|
2100 |
});
|
2101 |
+
});
|
2102 |
+
wrapper.addEventListener('mouseleave', () => {
|
2103 |
+
video.classList.remove('active');
|
2104 |
+
video.pause();
|
2105 |
+
video.currentTime = 0;
|
2106 |
+
image.classList.remove('hidden');
|
2107 |
+
});
|
2108 |
+
let touchTimeout;
|
2109 |
+
wrapper.addEventListener('touchstart', (e) => {
|
2110 |
+
e.preventDefault();
|
2111 |
+
clearTimeout(touchTimeout);
|
2112 |
+
wrapper.classList.add('touched');
|
2113 |
+
image.classList.add('hidden');
|
2114 |
+
video.classList.add('active');
|
2115 |
+
video.play().catch(err => {
|
2116 |
+
console.error('Video playback failed:', err);
|
2117 |
+
image.classList.remove('hidden');
|
2118 |
+
video.classList.remove('active');
|
2119 |
+
wrapper.classList.remove('touched');
|
2120 |
});
|
2121 |
+
});
|
2122 |
+
wrapper.addEventListener('touchend', () => {
|
2123 |
+
touchTimeout = setTimeout(() => {
|
2124 |
+
video.pause();
|
2125 |
+
video.classList.remove('active');
|
2126 |
+
image.classList.remove('hidden');
|
2127 |
+
wrapper.classList.remove('touched');
|
2128 |
+
}, 500);
|
2129 |
+
});
|
2130 |
+
});
|
2131 |
+
const decreaseBtn = document.getElementById('decreaseQuantity');
|
2132 |
+
const increaseBtn = document.getElementById('increaseQuantity');
|
2133 |
+
const quantityInput = document.getElementById('quantityInput');
|
2134 |
+
decreaseBtn.addEventListener('click', () => {
|
2135 |
+
let value = parseInt(quantityInput.value) || 1;
|
2136 |
+
if (value > 1) {
|
2137 |
+
quantityInput.value = value - 1;
|
2138 |
+
}
|
2139 |
+
});
|
2140 |
+
increaseBtn.addEventListener('click', () => {
|
2141 |
+
let value = parseInt(quantityInput.value) || 1;
|
2142 |
+
quantityInput.value = value + 1;
|
2143 |
+
});
|
2144 |
+
document.querySelectorAll('.toggle-details').forEach(link => {
|
2145 |
+
link.addEventListener('click', () => {
|
2146 |
+
const details = link.nextElementSibling;
|
2147 |
+
if (details.classList.contains('show')) {
|
2148 |
+
details.classList.remove('show');
|
2149 |
+
link.textContent = 'Show Details';
|
2150 |
+
} else {
|
2151 |
+
details.classList.add('show');
|
2152 |
+
link.textContent = 'Hide Details';
|
2153 |
+
}
|
2154 |
+
});
|
2155 |
+
});
|
2156 |
+
fetch('/cart')
|
2157 |
+
.then(response => response.json())
|
2158 |
+
.then(data => {
|
2159 |
+
if (data.success) {
|
2160 |
+
updateCartUI(data.cart);
|
2161 |
+
} else {
|
2162 |
+
updateCartUI(getCartLocalStorage());
|
2163 |
+
}
|
2164 |
+
})
|
2165 |
+
.catch(err => {
|
2166 |
+
console.error('Error fetching cart:', err);
|
2167 |
+
updateCartUI(getCartLocalStorage());
|
2168 |
+
});
|
2169 |
+
if ('webkitSpeechRecognition' in window) {
|
2170 |
+
recognition = new webkitSpeechRecognition();
|
2171 |
+
recognition.continuous = false;
|
2172 |
+
recognition.interimResults = false;
|
2173 |
+
recognition.lang = 'en-US';
|
2174 |
+
recognition.onstart = () => {
|
2175 |
+
document.getElementById('mic-icon-animation').classList.add('active');
|
2176 |
+
document.getElementById('mic-status').textContent = 'Listening...';
|
2177 |
+
};
|
2178 |
+
recognition.onresult = (event) => {
|
2179 |
+
const transcript = event.results[0][0].transcript.trim().toLowerCase();
|
2180 |
+
console.log('Recognized speech:', transcript);
|
2181 |
+
const matchedItem = menuItems.find(item =>
|
2182 |
+
item.name.toLowerCase().includes(transcript)
|
2183 |
+
);
|
2184 |
+
if (matchedItem) {
|
2185 |
+
const micStatus = document.getElementById('mic-status');
|
2186 |
+
const micItemDetails = document.getElementById('mic-item-details');
|
2187 |
+
const micItemName = document.getElementById('mic-item-name');
|
2188 |
+
const micItemImage = document.getElementById('mic-item-image');
|
2189 |
+
micStatus.style.display = 'none';
|
2190 |
+
micItemDetails.style.display = 'block';
|
2191 |
+
micItemName.textContent = matchedItem.name;
|
2192 |
+
micItemImage.src = matchedItem.image || '/static/placeholder.jpg';
|
2193 |
+
setTimeout(() => {
|
2194 |
+
recognition.stop();
|
2195 |
+
const card = document.querySelector(`.menu-card[data-item-name="${matchedItem.name}"]`);
|
2196 |
+
if (card) {
|
2197 |
+
card.classList.add('highlighted');
|
2198 |
+
card.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
2199 |
+
setTimeout(() => card.classList.remove('highlighted'), 2000);
|
2200 |
+
const buttonContainer = card.querySelector('.button-container');
|
2201 |
+
if (buttonContainer) {
|
2202 |
+
if (matchedItem.section === 'Soft Drinks') {
|
2203 |
showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
|
2204 |
} else {
|
2205 |
showItemDetails(
|
2206 |
+
matchedItem.name,
|
2207 |
+
matchedItem.price,
|
2208 |
+
matchedItem.image2 || matchedItem.image,
|
2209 |
+
matchedItem.description,
|
2210 |
+
matchedItem.section,
|
2211 |
+
matchedItem.category
|
2212 |
);
|
2213 |
const modal = new bootstrap.Modal(document.getElementById('itemModal'));
|
2214 |
modal.show();
|
2215 |
}
|
|
|
|
|
|
|
2216 |
}
|
2217 |
+
const micModal = bootstrap.Modal.getInstance(document.getElementById('micModal'));
|
2218 |
+
if (micModal) {
|
2219 |
+
micModal.hide();
|
2220 |
+
resetMicModal();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2221 |
}
|
2222 |
}
|
2223 |
+
}, 2000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2224 |
} else {
|
2225 |
+
document.getElementById('mic-status').textContent = 'Item not found. Try again.';
|
2226 |
+
}
|
2227 |
+
};
|
2228 |
+
recognition.onerror = (event) => {
|
2229 |
+
console.error('Speech recognition error:', event.error);
|
2230 |
+
document.getElementById('mic-status').textContent = 'Error occurred. Please try again.';
|
2231 |
+
document.getElementById('mic-icon-animation').classList.remove('active');
|
2232 |
+
};
|
2233 |
+
recognition.onend = () => {
|
2234 |
+
document.getElementById('mic-icon-animation').classList.remove('active');
|
2235 |
+
};
|
2236 |
+
document.getElementById('micIcon').addEventListener('click', () => {
|
2237 |
+
if (!recognition) return;
|
2238 |
+
const micModal = new bootstrap.Modal(document.getElementById('micModal'));
|
2239 |
+
micModal.show();
|
2240 |
+
resetMicModal();
|
2241 |
+
recognition.start();
|
2242 |
});
|
2243 |
+
document.getElementById('stopMicBtn').addEventListener('click', stopSpeechRecognition);
|
2244 |
+
} else {
|
2245 |
+
document.getElementById('micIcon').style.display = 'none';
|
2246 |
+
}
|
2247 |
+
});
|
2248 |
+
</script>
|
2249 |
</body>
|
2250 |
</html>
|