lokeshloki143 commited on
Commit
6da7947
·
verified ·
1 Parent(s): 852ddfd

Update templates/menu.html

Browse files
Files changed (1) hide show
  1. templates/menu.html +76 -211
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 3px rgba(0, 0, 0, 0.2);
1101
  }
1102
  /* Mobile-Specific Styles */
1103
  @media (max-width: 576px) {
@@ -1438,8 +1438,8 @@
1438
  <label class="form-label fw-bold">Filters:</label>
1439
  <div class="toggle-container">
1440
  <!-- Veg Only Toggle -->
1441
- <input type="checkbox" id="veg-toggle" name="veg" value="Veg"
1442
- {% if selected_category == "Veg" %}checked{% endif %}
1443
  class="custom-toggle" onchange="handleToggle('veg')"
1444
  aria-label="Toggle Vegetarian filter">
1445
  <label for="veg-toggle">Veg</label>
@@ -1463,10 +1463,9 @@
1463
  <label for="custom-dish-name" class="form-label">Dish Name</label>
1464
  <input type="text" class="form-control" id="custom-dish-name" name="name" required>
1465
  </div>
1466
- <div class="mb-3 position-relative">
1467
  <label for="custom-dish-description" class="form-label">Dish Description</label>
1468
  <textarea class="form-control" id="custom-dish-description" name="description" required></textarea>
1469
- <div id="descriptionSuggestions" class="autocomplete-suggestions"></div>
1470
  </div>
1471
  <button type="submit" class="btn btn-primary">Submit Custom Dish</button>
1472
  </form>
@@ -1672,38 +1671,6 @@
1672
  {% endfor %}
1673
  {% endfor %}
1674
  ];
1675
- const ingredientsList = [
1676
- "Basmati Rice", "Bell Pepper", "Biryani Masala", "Butter", "Capsicum", "Cauliflower",
1677
- "Chickpea Flour (Besan)", "Chickpea Flour (for batter)", "Chickpeas (Channa)", "Chili Powder",
1678
- "Chili Sauce", "Coconut Milk", "Coriander Powder", "Cornflour", "Cream", "Cumin Powder",
1679
- "Cumin Seeds", "Curd (Yogurt)", "Curry Leaves", "Fish (e.g., King Fish or Salmon)",
1680
- "Fresh Coriander Leaves", "Garam Masala", "Garlic", "Ghee (Clarified Butter)", "Ginger",
1681
- "Ginger-Garlic Paste", "Goat Meat (Mutton)", "Green Chilies", "Honey",
1682
- "Kasuri Methi (dried fenugreek leaves)", "Lemon Juice", "Mango Puree", "Mint Leaves",
1683
- "Mixed Vegetables (Carrot, Peas, Potato, Cauliflower)", "Mixed Vegetables (Carrot, Peas, Potato)",
1684
- "Mustard Seeds", "Mutton (Goat Meat)", "Oil", "Oil (for frying)", "Onion",
1685
- "Paneer (Indian Cottage Cheese)", "Peas", "Potatoes", "Prawns", "Red Chili Powder",
1686
- "Rice Flour", "Saffron", "Salt", "Soy Sauce", "Spring Onion", "Tamarind (for sourness)",
1687
- "Tomato Ketchup", "Tomatoes", "Turmeric Powder", "Vinegar", "Water", "Wheat Flour (for dough)",
1688
- "Whole Wheat Flour", "Yogurt (Curd)"
1689
- ];
1690
- const fallbackAddons = [
1691
- {
1692
- section: "Extras",
1693
- items: [
1694
- { name: "Extra Cheese", price: 1.50 },
1695
- { name: "Extra Sauce", price: 0.75 },
1696
- { name: "Spicy Seasoning", price: 0.50 }
1697
- ]
1698
- },
1699
- {
1700
- section: "Sides",
1701
- items: [
1702
- { name: "Naan Bread", price: 2.00 },
1703
- { name: "Raita", price: 1.00 }
1704
- ]
1705
- }
1706
- ];
1707
  function addToCartLocalStorage(payload) {
1708
  let cart = JSON.parse(localStorage.getItem('cart')) || [];
1709
  const existingItem = cart.find(item =>
@@ -1846,120 +1813,78 @@
1846
  console.log("Most common add-ons: ", window.most_common_addons);
1847
  function showItemDetails(name, price, image, description, section, selectedCategory) {
1848
  document.getElementById('modal-name').innerText = name;
1849
- baseItemPrice = parseFloat(price) || 0;
1850
  document.getElementById('modal-price').innerText = `$${baseItemPrice.toFixed(2)}`;
1851
- document.getElementById('modal-img').src = image || '/static/placeholder.jpg';
1852
- document.getElementById('modal-description').innerText = description || 'No description available';
1853
- document.getElementById('quantityInput').value = '1';
 
 
1854
  document.getElementById('modal-instructions').value = '';
1855
- document.getElementById('modal-section').setAttribute('data-section', section);
1856
- document.getElementById('modal-section').setAttribute('data-category', selectedCategory);
1857
- const addonsList = document.getElementById('addons-list');
1858
- addonsList.innerHTML = '';
1859
- addonsList.classList.add('addon-loading');
1860
  fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
1861
  .then(response => response.json())
1862
  .then(data => {
1863
- console.log('Addons API response:', data);
1864
  addonsList.classList.remove('addon-loading');
1865
- let addons = [];
1866
- if (data.success && Array.isArray(data.addons) && data.addons.length > 0) {
1867
- addons = data.addons;
1868
- } else if (window.most_common_addons && Array.isArray(window.most_common_addons) && window.most_common_addons.length > 0) {
1869
- console.log('Using most_common_addons as fallback');
1870
- addons = window.most_common_addons;
1871
  } else {
1872
- console.log('Using static fallback addons');
1873
- addons = fallbackAddons;
1874
- }
1875
- if (addons.length === 0) {
1876
- addonsList.innerHTML = '<p class="text-muted">No customization options available.</p>';
1877
- return;
1878
- }
1879
- addons.forEach(addon => {
1880
- const addonSection = document.createElement('div');
1881
- addonSection.className = 'addon-section';
1882
- const addonHeader = document.createElement('h6');
1883
- addonHeader.textContent = addon.section;
1884
- addonHeader.setAttribute('data-bs-toggle', 'collapse');
1885
- addonHeader.setAttribute('data-bs-target', `#collapse-${addon.section.replace(/\s+/g, '-')}`);
1886
- addonSection.appendChild(addonHeader);
1887
- const addonCollapse = document.createElement('div');
1888
- addonCollapse.id = `collapse-${addon.section.replace(/\s+/g, '-')}`;
1889
- addonCollapse.className = 'addon-options';
1890
- addon.items.forEach(item => {
1891
- const addonItem = document.createElement('div');
1892
- addonItem.className = 'form-check';
1893
- const input = document.createElement('input');
1894
- input.type = 'checkbox';
1895
- input.className = 'form-check-input';
1896
- input.id = `addon-${item.name.replace(/\s+/g, '-')}`;
1897
- input.setAttribute('data-price', item.price || 0);
1898
- input.setAttribute('data-name', item.name);
1899
- input.setAttribute('data-section', addon.section);
1900
- input.addEventListener('change', updateModalPrice);
1901
- const label = document.createElement('label');
1902
- label.className = 'form-check-label';
1903
- label.htmlFor = `addon-${item.name.replace(/\s+/g, '-')}`;
1904
- label.textContent = item.name;
1905
- if (item.price > 0) {
1906
- const priceSpan = document.createElement('span');
1907
- priceSpan.className = 'extra-charge';
1908
- priceSpan.textContent = `+$${parseFloat(item.price).toFixed(2)}`;
1909
- label.appendChild(priceSpan);
1910
- }
1911
- addonItem.appendChild(label);
1912
- addonItem.appendChild(input);
1913
- addonCollapse.appendChild(addonItem);
1914
  });
1915
- addonSection.appendChild(addonCollapse);
1916
- addonsList.appendChild(addonSection);
1917
- });
1918
  })
1919
  .catch(err => {
1920
  console.error('Error fetching addons:', err);
 
1921
  addonsList.classList.remove('addon-loading');
1922
- console.log('Using static fallback addons due to error');
1923
- addonsList.innerHTML = '';
1924
- fallbackAddons.forEach(addon => {
1925
- const addonSection = document.createElement('div');
1926
- addonSection.className = 'addon-section';
1927
- const addonHeader = document.createElement('h6');
1928
- addonHeader.textContent = addon.section;
1929
- addonHeader.setAttribute('data-bs-toggle', 'collapse');
1930
- addonHeader.setAttribute('data-bs-target', `#collapse-${addon.section.replace(/\s+/g, '-')}`);
1931
- addonSection.appendChild(addonHeader);
1932
- const addonCollapse = document.createElement('div');
1933
- addonCollapse.id = `collapse-${addon.section.replace(/\s+/g, '-')}`;
1934
- addonCollapse.className = 'addon-options';
1935
- addon.items.forEach(item => {
1936
- const addonItem = document.createElement('div');
1937
- addonItem.className = 'form-check';
1938
- const input = document.createElement('input');
1939
- input.type = 'checkbox';
1940
- input.className = 'form-check-input';
1941
- input.id = `addon-${item.name.replace(/\s+/g, '-')}`;
1942
- input.setAttribute('data-price', item.price || 0);
1943
- input.setAttribute('data-name', item.name);
1944
- input.setAttribute('data-section', addon.section);
1945
- input.addEventListener('change', updateModalPrice);
1946
- const label = document.createElement('label');
1947
- label.className = 'form-check-label';
1948
- label.htmlFor = `addon-${item.name.replace(/\s+/g, '-')}`;
1949
- label.textContent = item.name;
1950
- if (item.price > 0) {
1951
- const priceSpan = document.createElement('span');
1952
- priceSpan.className = 'extra-charge';
1953
- priceSpan.textContent = `+$${parseFloat(item.price).toFixed(2)}`;
1954
- label.appendChild(priceSpan);
1955
- }
1956
- addonItem.appendChild(label);
1957
- addonItem.appendChild(input);
1958
- addonCollapse.appendChild(addonItem);
1959
- });
1960
- addonSection.appendChild(addonCollapse);
1961
- addonsList.appendChild(addonSection);
1962
- });
1963
  });
1964
  }
1965
  function addToCartFromModal() {
@@ -2046,25 +1971,17 @@
2046
  function handleToggle(toggleType) {
2047
  const vegToggle = document.getElementById('veg-toggle');
2048
  const customToggle = document.getElementById('category-CustomizedDish');
2049
- const form = document.getElementById('filter-form');
2050
- if (toggleType === 'veg') {
2051
- if (vegToggle.checked) {
2052
- customToggle.checked = false;
2053
- vegToggle.value = 'Veg';
2054
- } else {
2055
- vegToggle.value = '';
2056
- }
2057
- } else if (toggleType === 'custom') {
2058
- if (customToggle.checked) {
2059
- vegToggle.checked = false;
2060
- vegToggle.value = '';
2061
- }
2062
- }
2063
- console.log('Filter state:', {
2064
- veg: vegToggle.checked ? 'Veg' : '',
2065
- category: customToggle.checked ? 'Customized Dish' : ''
2066
- });
2067
- form.submit();
2068
  }
2069
  document.addEventListener('DOMContentLoaded', function () {
2070
  const avatarIcon = document.querySelector('.avatar-icon');
@@ -2325,59 +2242,7 @@
2325
  } else {
2326
  document.getElementById('micIcon').style.display = 'none';
2327
  }
2328
- const descriptionInput = document.getElementById('custom-dish-description');
2329
- const suggestionsContainer = document.getElementById('descriptionSuggestions');
2330
- if (descriptionInput && suggestionsContainer) {
2331
- descriptionInput.addEventListener('input', debounce(() => {
2332
- const query = descriptionInput.value.toLowerCase();
2333
- suggestionsContainer.innerHTML = '';
2334
- if (query.length < 2) {
2335
- suggestionsContainer.style.display = 'none';
2336
- return;
2337
- }
2338
- const filteredIngredients = ingredientsList.filter(ingredient =>
2339
- ingredient.toLowerCase().includes(query)
2340
- );
2341
- if (filteredIngredients.length === 0) {
2342
- suggestionsContainer.style.display = 'none';
2343
- return;
2344
- }
2345
- filteredIngredients.forEach(ingredient => {
2346
- const suggestionItem = document.createElement('div');
2347
- suggestionItem.classList.add('autocomplete-suggestion');
2348
- suggestionItem.textContent = ingredient;
2349
- suggestionItem.addEventListener('click', () => {
2350
- const currentValue = descriptionInput.value;
2351
- const words = currentValue.split(' ');
2352
- words[words.length - 1] = ingredient;
2353
- descriptionInput.value = words.join(' ') + ' ';
2354
- suggestionsContainer.innerHTML = '';
2355
- suggestionsContainer.style.display = 'none';
2356
- descriptionInput.focus();
2357
- });
2358
- suggestionsContainer.appendChild(suggestionItem);
2359
- });
2360
- suggestionsContainer.style.display = 'block';
2361
- }, 300));
2362
- document.addEventListener('click', (event) => {
2363
- if (!descriptionInput.contains(event.target) && !suggestionsContainer.contains(event.target)) {
2364
- suggestionsContainer.style.display = 'none';
2365
- }
2366
- });
2367
- }
2368
  });
2369
  </script>
2370
  </body>
2371
- </html>
2372
-
2373
-
2374
-
2375
-
2376
-
2377
-
2378
-
2379
-
2380
-
2381
-
2382
-
2383
-
 
1097
  justify-content: center;
1098
  font-size: 12px;
1099
  margin-left: 8px;
1100
+ box-shadow: 0 1px 3風險
1101
  }
1102
  /* Mobile-Specific Styles */
1103
  @media (max-width: 576px) {
 
1438
  <label class="form-label fw-bold">Filters:</label>
1439
  <div class="toggle-container">
1440
  <!-- Veg Only Toggle -->
1441
+ <input type="checkbox" id="veg-toggle" name="veg"
1442
+ {% if veg == "Veg" %}checked{% endif %}
1443
  class="custom-toggle" onchange="handleToggle('veg')"
1444
  aria-label="Toggle Vegetarian filter">
1445
  <label for="veg-toggle">Veg</label>
 
1463
  <label for="custom-dish-name" class="form-label">Dish Name</label>
1464
  <input type="text" class="form-control" id="custom-dish-name" name="name" required>
1465
  </div>
1466
+ <div class="mb-3">
1467
  <label for="custom-dish-description" class="form-label">Dish Description</label>
1468
  <textarea class="form-control" id="custom-dish-description" name="description" required></textarea>
 
1469
  </div>
1470
  <button type="submit" class="btn btn-primary">Submit Custom Dish</button>
1471
  </form>
 
1671
  {% endfor %}
1672
  {% endfor %}
1673
  ];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1674
  function addToCartLocalStorage(payload) {
1675
  let cart = JSON.parse(localStorage.getItem('cart')) || [];
1676
  const existingItem = cart.find(item =>
 
1813
  console.log("Most common add-ons: ", window.most_common_addons);
1814
  function showItemDetails(name, price, image, description, section, selectedCategory) {
1815
  document.getElementById('modal-name').innerText = name;
1816
+ baseItemPrice = parseFloat(price) || 0;
1817
  document.getElementById('modal-price').innerText = `$${baseItemPrice.toFixed(2)}`;
1818
+ const modalImg = document.getElementById('modal-img');
1819
+ modalImg.src = image || '/static/placeholder.jpg';
1820
+ document.getElementById('modal-description').innerText = description || 'No description available.';
1821
+ document.getElementById('addons-list').innerHTML = '';
1822
+ document.getElementById('addons-list').classList.add('addon-loading');
1823
  document.getElementById('modal-instructions').value = '';
1824
+ const modalSectionEl = document.getElementById('modal-section');
1825
+ modalSectionEl.setAttribute('data-section', section);
1826
+ modalSectionEl.setAttribute('data-category', selectedCategory);
1827
+ document.getElementById('quantityInput').value = 1;
 
1828
  fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
1829
  .then(response => response.json())
1830
  .then(data => {
1831
+ const addonsList = document.getElementById('addons-list');
1832
  addonsList.classList.remove('addon-loading');
1833
+ addonsList.innerHTML = '';
1834
+ if (!data.success || !data.addons || data.addons.length === 0) {
1835
+ const noAddonsMessage = document.createElement('p');
1836
+ noAddonsMessage.textContent = 'No add-ons available for this item.';
1837
+ noAddonsMessage.className = 'text-muted';
1838
+ addonsList.appendChild(noAddonsMessage);
1839
  } else {
1840
+ data.addons.forEach(addon => {
1841
+ const addonSection = document.createElement('div');
1842
+ addonSection.className = 'addon-section';
1843
+ const addonHeader = document.createElement('h6');
1844
+ addonHeader.textContent = addon.section;
1845
+ addonHeader.setAttribute('data-bs-toggle', 'collapse');
1846
+ addonHeader.setAttribute('data-bs-target', `#addon-collapse-${addon.section.replace(/\s+/g, '-')}`);
1847
+ addonHeader.setAttribute('aria-expanded', 'true');
1848
+ addonHeader.setAttribute('aria-controls', `addon-collapse-${addon.section.replace(/\s+/g, '-')}`);
1849
+ addonSection.appendChild(addonHeader);
1850
+ const addonCollapse = document.createElement('div');
1851
+ addonCollapse.id = `addon-collapse-${addon.section.replace(/\s+/g, '-')}`;
1852
+ addonCollapse.className = 'addon-options collapse show';
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
+ input.id = `addon-${item.name.replace(/\s+/g, '-')}`;
1860
+ input.setAttribute('data-price', item.price || 0);
1861
+ input.setAttribute('data-name', item.name);
1862
+ input.setAttribute('data-section', addon.section);
1863
+ input.addEventListener('change', updateModalPrice);
1864
+ const label = document.createElement('label');
1865
+ label.className = 'form-check-label';
1866
+ label.htmlFor = `addon-${item.name.replace(/\s+/g, '-')}`;
1867
+ label.textContent = item.name;
1868
+ if (item.price > 0) {
1869
+ const priceSpan = document.createElement('span');
1870
+ priceSpan.className = 'extra-charge';
1871
+ priceSpan.textContent = `+$${parseFloat(item.price).toFixed(2)}`;
1872
+ label.appendChild(priceSpan);
1873
+ }
1874
+ addonItem.appendChild(label);
1875
+ addonItem.appendChild(input);
1876
+ addonCollapse.appendChild(addonItem);
1877
+ });
1878
+ addonSection.appendChild(addonCollapse);
1879
+ addonsList.appendChild(addonSection);
 
 
1880
  });
1881
+ }
 
 
1882
  })
1883
  .catch(err => {
1884
  console.error('Error fetching addons:', err);
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() {
 
1971
  function handleToggle(toggleType) {
1972
  const vegToggle = document.getElementById('veg-toggle');
1973
  const customToggle = document.getElementById('category-CustomizedDish');
1974
+ let url = '/menu?';
1975
+ const params = [];
1976
+ if (toggleType === 'veg' && vegToggle.checked) {
1977
+ params.push('veg=Veg');
1978
+ customToggle.checked = false;
1979
+ } else if (toggleType === 'custom' && customToggle.checked) {
1980
+ params.push('category=Customized+Dish');
1981
+ vegToggle.checked = false;
1982
+ }
1983
+ url += params.join('&');
1984
+ window.location.href = url;
 
 
 
 
 
 
 
 
1985
  }
1986
  document.addEventListener('DOMContentLoaded', function () {
1987
  const avatarIcon = document.querySelector('.avatar-icon');
 
2242
  } else {
2243
  document.getElementById('micIcon').style.display = 'none';
2244
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2245
  });
2246
  </script>
2247
  </body>
2248
+ </html>