Update templates/menu.html
Browse files- templates/menu.html +133 -133
templates/menu.html
CHANGED
@@ -154,7 +154,7 @@
|
|
154 |
width: 38px;
|
155 |
height: 38px;
|
156 |
border-radius: 50%;
|
157 |
-
background: linear-gradient(135deg, #
|
158 |
display: flex;
|
159 |
align-items: center;
|
160 |
justify-content: center;
|
@@ -1938,154 +1938,154 @@
|
|
1938 |
const toggleDetails = card.querySelector('.toggle-details');
|
1939 |
const itemDetails = card.querySelector('.item-details');
|
1940 |
if (toggleDetails && itemDetails) {
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
}
|
1947 |
-
});
|
1948 |
-
const quantityInput = document.getElementById('quantityInput');
|
1949 |
-
const increaseBtn = document.getElementById('increaseQuantity');
|
1950 |
-
const
|
1951 |
if (increaseBtn && decreaseBtn && quantityInput) {
|
1952 |
-
increaseBtn.addEventListener('click', () => {
|
1953 |
-
|
1954 |
-
|
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 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
});
|
1976 |
}
|
1977 |
function startSpeechRecognition() {
|
1978 |
-
if ('webkitSpeechRecognition' in window || 'SpeechRecognition' in window) {
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
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 |
-
|
2032 |
-
|
2033 |
-
}
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
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 |
-
|
2047 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2048 |
suggestionsContainer.innerHTML = '';
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
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.
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
}
|
2088 |
-
});
|
2089 |
}
|
2090 |
});
|
2091 |
</script>
|
|
|
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;
|
|
|
1938 |
const toggleDetails = card.querySelector('.toggle-details');
|
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>
|