Update templates/menu.html
Browse files- templates/menu.html +88 -38
templates/menu.html
CHANGED
@@ -1295,6 +1295,7 @@
|
|
1295 |
<input type="text" id="searchBar" class="form-control" placeholder="Search items or sections..." autocomplete="off">
|
1296 |
<i class="bi bi-search search-icon"></i>
|
1297 |
<i class="bi bi-mic mic-icon" id="micIcon"></i>
|
|
|
1298 |
</div>
|
1299 |
</div>
|
1300 |
|
@@ -1333,7 +1334,7 @@
|
|
1333 |
<div id="descriptionSuggestions" class="autocomplete-suggestions"></div>
|
1334 |
</div>
|
1335 |
<button type="submit" class="btn btn-primary">Submit Custom Dish</button>
|
1336 |
-
|
1337 |
</div>
|
1338 |
{% else %}
|
1339 |
{% if ordered_menu.items()|length == 0 %}
|
@@ -1527,7 +1528,11 @@
|
|
1527 |
{
|
1528 |
name: "{{ item.Name | default('Unnamed Item') }}",
|
1529 |
section: "{{ item.Section__c | default(section) }}",
|
1530 |
-
image: "{{ item.Image1__c | default('/static/placeholder.jpg') }}"
|
|
|
|
|
|
|
|
|
1531 |
},
|
1532 |
{% endfor %}
|
1533 |
{% endfor %}
|
@@ -1903,36 +1908,79 @@
|
|
1903 |
document.getElementById('mic-item-name').textContent = '';
|
1904 |
}
|
1905 |
document.addEventListener('DOMContentLoaded', function () {
|
1906 |
-
const
|
1907 |
const dropdownMenu = document.querySelector('.dropdown-menu');
|
1908 |
-
|
1909 |
-
|
1910 |
dropdownMenu.classList.toggle('show');
|
1911 |
});
|
|
|
1912 |
document.addEventListener('click', function (event) {
|
1913 |
-
if (!
|
1914 |
dropdownMenu.classList.remove('show');
|
1915 |
}
|
1916 |
});
|
1917 |
-
const dropdownItems = document.querySelectorAll('.dropdown-item');
|
1918 |
-
dropdownItems.forEach(item => {
|
1919 |
-
item.addEventListener('click', function () {
|
1920 |
-
dropdownMenu.classList.remove('show');
|
1921 |
-
});
|
1922 |
-
});
|
1923 |
|
1924 |
const searchBar = document.getElementById('searchBar');
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1935 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1936 |
});
|
1937 |
|
1938 |
if (localStorage.getItem('selectedItem')) {
|
@@ -1944,15 +1992,17 @@
|
|
1944 |
card.classList.add('highlighted');
|
1945 |
setTimeout(() => card.classList.remove('highlighted'), 2000);
|
1946 |
const buttonContainer = card.querySelector('.button-container');
|
1947 |
-
|
1948 |
-
const price = buttonContainer.getAttribute('data-item-price');
|
1949 |
-
const image = buttonContainer.getAttribute('data-item-image2') || buttonContainer.getAttribute('data-item-image');
|
1950 |
-
const description = buttonContainer.getAttribute('data-item-description');
|
1951 |
-
const category = buttonContainer.getAttribute('data-item-category');
|
1952 |
-
if (section === 'Soft Drinks') {
|
1953 |
showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
|
1954 |
} else {
|
1955 |
-
showItemDetails(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1956 |
const modal = new bootstrap.Modal(document.getElementById('itemModal'));
|
1957 |
modal.show();
|
1958 |
}
|
@@ -2070,12 +2120,11 @@
|
|
2070 |
);
|
2071 |
|
2072 |
if (matchedItem) {
|
2073 |
-
// Stop recognition immediately after finding a match
|
2074 |
recognition.stop();
|
2075 |
document.getElementById('mic-status').style.display = 'none';
|
2076 |
document.getElementById('mic-item-details').style.display = 'block';
|
2077 |
document.getElementById('mic-item-name').textContent = matchedItem.name;
|
2078 |
-
document.getElementById('mic-item-image').src = matchedItem.image;
|
2079 |
|
2080 |
const card = document.querySelector(`.menu-card[data-item-name="${matchedItem.name}"]`);
|
2081 |
if (card) {
|
@@ -2087,18 +2136,17 @@
|
|
2087 |
showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
|
2088 |
} else {
|
2089 |
showItemDetails(
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
matchedItem.section,
|
2095 |
-
|
2096 |
);
|
2097 |
const modal = new bootstrap.Modal(document.getElementById('itemModal'));
|
2098 |
modal.show();
|
2099 |
}
|
2100 |
}
|
2101 |
-
// Hide the mic modal after showing item details
|
2102 |
const micModal = bootstrap.Modal.getInstance(document.getElementById('micModal'));
|
2103 |
if (micModal) {
|
2104 |
micModal.hide();
|
@@ -2127,6 +2175,8 @@
|
|
2127 |
resetMicModal();
|
2128 |
recognition.start();
|
2129 |
});
|
|
|
|
|
2130 |
} else {
|
2131 |
document.getElementById('micIcon').style.display = 'none';
|
2132 |
}
|
@@ -2181,4 +2231,4 @@
|
|
2181 |
});
|
2182 |
</script>
|
2183 |
</body>
|
2184 |
-
</html>
|
|
|
1295 |
<input type="text" id="searchBar" class="form-control" placeholder="Search items or sections..." autocomplete="off">
|
1296 |
<i class="bi bi-search search-icon"></i>
|
1297 |
<i class="bi bi-mic mic-icon" id="micIcon"></i>
|
1298 |
+
<div id="searchSuggestions" class="autocomplete-suggestions"></div>
|
1299 |
</div>
|
1300 |
</div>
|
1301 |
|
|
|
1334 |
<div id="descriptionSuggestions" class="autocomplete-suggestions"></div>
|
1335 |
</div>
|
1336 |
<button type="submit" class="btn btn-primary">Submit Custom Dish</button>
|
1337 |
+
</form>
|
1338 |
</div>
|
1339 |
{% else %}
|
1340 |
{% if ordered_menu.items()|length == 0 %}
|
|
|
1528 |
{
|
1529 |
name: "{{ item.Name | default('Unnamed Item') }}",
|
1530 |
section: "{{ item.Section__c | default(section) }}",
|
1531 |
+
image: "{{ item.Image1__c | default('/static/placeholder.jpg') }}",
|
1532 |
+
price: "{{ item.Price__c | default('0.00') }}",
|
1533 |
+
image2: "{{ item.Image2__c | default(item.Image1__c) }}",
|
1534 |
+
description: "{{ item.Description__c | default('No description') }}",
|
1535 |
+
category: "{{ selected_category }}"
|
1536 |
},
|
1537 |
{% endfor %}
|
1538 |
{% endfor %}
|
|
|
1908 |
document.getElementById('mic-item-name').textContent = '';
|
1909 |
}
|
1910 |
document.addEventListener('DOMContentLoaded', function () {
|
1911 |
+
const avatarIcon = document.querySelector('.avatar-icon');
|
1912 |
const dropdownMenu = document.querySelector('.dropdown-menu');
|
1913 |
+
|
1914 |
+
avatarIcon.addEventListener('click', function () {
|
1915 |
dropdownMenu.classList.toggle('show');
|
1916 |
});
|
1917 |
+
|
1918 |
document.addEventListener('click', function (event) {
|
1919 |
+
if (!avatarIcon.contains(event.target) && !dropdownMenu.contains(event.target)) {
|
1920 |
dropdownMenu.classList.remove('show');
|
1921 |
}
|
1922 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
1923 |
|
1924 |
const searchBar = document.getElementById('searchBar');
|
1925 |
+
const searchSuggestions = document.getElementById('searchSuggestions');
|
1926 |
+
|
1927 |
+
searchBar.addEventListener('input', debounce(function () {
|
1928 |
+
const query = searchBar.value.trim().toLowerCase();
|
1929 |
+
searchSuggestions.innerHTML = '';
|
1930 |
+
if (query.length < 2) {
|
1931 |
+
searchSuggestions.style.display = 'none';
|
1932 |
+
return;
|
1933 |
+
}
|
1934 |
+
|
1935 |
+
const filteredItems = menuItems.filter(item =>
|
1936 |
+
item.name.toLowerCase().includes(query) || item.section.toLowerCase().includes(query)
|
1937 |
+
);
|
1938 |
+
|
1939 |
+
if (filteredItems.length === 0) {
|
1940 |
+
searchSuggestions.style.display = 'none';
|
1941 |
+
return;
|
1942 |
+
}
|
1943 |
+
|
1944 |
+
filteredItems.forEach(item => {
|
1945 |
+
const suggestion = document.createElement('div');
|
1946 |
+
suggestion.classList.add('autocomplete-suggestion');
|
1947 |
+
suggestion.textContent = item.name;
|
1948 |
+
suggestion.addEventListener('click', () => {
|
1949 |
+
const card = document.querySelector(`.menu-card[data-item-name="${item.name}"]`);
|
1950 |
+
if (card) {
|
1951 |
+
card.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
1952 |
+
card.classList.add('highlighted');
|
1953 |
+
setTimeout(() => card.classList.remove('highlighted'), 2000);
|
1954 |
+
const buttonContainer = card.querySelector('.button-container');
|
1955 |
+
if (item.section === 'Soft Drinks') {
|
1956 |
+
showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
|
1957 |
+
} else {
|
1958 |
+
showItemDetails(
|
1959 |
+
item.name,
|
1960 |
+
item.price,
|
1961 |
+
item.image2 || item.image,
|
1962 |
+
item.description,
|
1963 |
+
item.section,
|
1964 |
+
item.category
|
1965 |
+
);
|
1966 |
+
const modal = new bootstrap.Modal(document.getElementById('itemModal'));
|
1967 |
+
modal.show();
|
1968 |
+
}
|
1969 |
+
searchBar.value = '';
|
1970 |
+
searchSuggestions.innerHTML = '';
|
1971 |
+
searchSuggestions.style.display = 'none';
|
1972 |
+
}
|
1973 |
+
});
|
1974 |
+
searchSuggestions.appendChild(suggestion);
|
1975 |
});
|
1976 |
+
|
1977 |
+
searchSuggestions.style.display = 'block';
|
1978 |
+
}, 300));
|
1979 |
+
|
1980 |
+
document.addEventListener('click', function (event) {
|
1981 |
+
if (!searchBar.contains(event.target) && !searchSuggestions.contains(event.target)) {
|
1982 |
+
searchSuggestions.style.display = 'none';
|
1983 |
+
}
|
1984 |
});
|
1985 |
|
1986 |
if (localStorage.getItem('selectedItem')) {
|
|
|
1992 |
card.classList.add('highlighted');
|
1993 |
setTimeout(() => card.classList.remove('highlighted'), 2000);
|
1994 |
const buttonContainer = card.querySelector('.button-container');
|
1995 |
+
if (selectedItem.section === 'Soft Drinks') {
|
|
|
|
|
|
|
|
|
|
|
1996 |
showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
|
1997 |
} else {
|
1998 |
+
showItemDetails(
|
1999 |
+
selectedItem.name,
|
2000 |
+
selectedItem.price,
|
2001 |
+
selectedItem.image2 || selectedItem.image,
|
2002 |
+
selectedItem.description,
|
2003 |
+
selectedItem.section,
|
2004 |
+
selectedItem.category
|
2005 |
+
);
|
2006 |
const modal = new bootstrap.Modal(document.getElementById('itemModal'));
|
2007 |
modal.show();
|
2008 |
}
|
|
|
2120 |
);
|
2121 |
|
2122 |
if (matchedItem) {
|
|
|
2123 |
recognition.stop();
|
2124 |
document.getElementById('mic-status').style.display = 'none';
|
2125 |
document.getElementById('mic-item-details').style.display = 'block';
|
2126 |
document.getElementById('mic-item-name').textContent = matchedItem.name;
|
2127 |
+
document.getElementById('mic-item-image').src = matchedItem.image || '/static/placeholder.jpg';
|
2128 |
|
2129 |
const card = document.querySelector(`.menu-card[data-item-name="${matchedItem.name}"]`);
|
2130 |
if (card) {
|
|
|
2136 |
showSoftDrinkModal(buttonContainer.querySelector('.add-to-cart-btn'));
|
2137 |
} else {
|
2138 |
showItemDetails(
|
2139 |
+
matchedItem.name,
|
2140 |
+
matchedItem.price,
|
2141 |
+
matchedItem.image2 || matchedItem.image,
|
2142 |
+
matchedItem.description,
|
2143 |
matchedItem.section,
|
2144 |
+
matchedItem.category
|
2145 |
);
|
2146 |
const modal = new bootstrap.Modal(document.getElementById('itemModal'));
|
2147 |
modal.show();
|
2148 |
}
|
2149 |
}
|
|
|
2150 |
const micModal = bootstrap.Modal.getInstance(document.getElementById('micModal'));
|
2151 |
if (micModal) {
|
2152 |
micModal.hide();
|
|
|
2175 |
resetMicModal();
|
2176 |
recognition.start();
|
2177 |
});
|
2178 |
+
|
2179 |
+
document.getElementById('stopMicBtn').addEventListener('click', stopSpeechRecognition);
|
2180 |
} else {
|
2181 |
document.getElementById('micIcon').style.display = 'none';
|
2182 |
}
|
|
|
2231 |
});
|
2232 |
</script>
|
2233 |
</body>
|
2234 |
+
</html>
|