Spaces:
Sleeping
Sleeping
Update templates/menu.html
Browse files- templates/menu.html +127 -55
templates/menu.html
CHANGED
@@ -773,67 +773,139 @@ form-check-input addon-option{
|
|
773 |
<!-- JavaScript -->
|
774 |
<script>
|
775 |
// Show item details and fetch customization options
|
776 |
-
function showItemDetails(name, price, image, description, section, selectedCategory) {
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
830 |
});
|
831 |
-
|
832 |
-
|
833 |
-
console.error('Error fetching add-ons:', err);
|
834 |
-
document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
|
835 |
});
|
836 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
837 |
|
838 |
// Handle single-select/deselect logic for checkbox groups in all modals
|
839 |
document.addEventListener('click', function(event) {
|
|
|
773 |
<!-- JavaScript -->
|
774 |
<script>
|
775 |
// Show item details and fetch customization options
|
776 |
+
// function showItemDetails(name, price, image, description, section, selectedCategory) {
|
777 |
+
// document.getElementById('modal-name').innerText = name;
|
778 |
+
// document.getElementById('modal-price').innerText = `$${price}`;
|
779 |
+
// document.getElementById('modal-img').src = image || '/static/placeholder.jpg';
|
780 |
+
// document.getElementById('modal-description').innerText = description || 'No description available.';
|
781 |
+
// document.getElementById('addons-list').innerHTML = 'Loading customization options...';
|
782 |
+
// document.getElementById('modal-instructions').value = '';
|
783 |
+
|
784 |
+
// const modalSectionEl = document.getElementById('modal-section');
|
785 |
+
// modalSectionEl.setAttribute('data-section', section);
|
786 |
+
// modalSectionEl.setAttribute('data-category', selectedCategory);
|
787 |
+
|
788 |
+
// // Set the default quantity to 1
|
789 |
+
// document.getElementById('quantityInput').value = 1;
|
790 |
|
791 |
+
// // Fetch customization options based on the section
|
792 |
+
// fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
|
793 |
+
// .then(response => response.json())
|
794 |
+
// .then(data => {
|
795 |
+
// const addonsList = document.getElementById('addons-list');
|
796 |
+
// addonsList.innerHTML = ''; // Clear previous content
|
797 |
+
|
798 |
+
// if (!data.success || !data.addons || data.addons.length === 0) {
|
799 |
+
// addonsList.innerHTML = '<p>No customization options available.</p>';
|
800 |
+
// return;
|
801 |
+
// }
|
802 |
|
803 |
+
// // Display customization options inside styled divs
|
804 |
+
// data.addons.forEach(addon => {
|
805 |
+
// const sectionDiv = document.createElement('div');
|
806 |
+
// sectionDiv.classList.add('addon-section'); // Add styling class
|
807 |
|
808 |
+
// // Add section title
|
809 |
+
// const title = document.createElement('h6');
|
810 |
+
// title.innerText = addon.name;
|
811 |
+
// sectionDiv.appendChild(title);
|
812 |
|
813 |
+
// // Create options list
|
814 |
+
// const optionsContainer = document.createElement('div');
|
815 |
+
// addon.options.forEach((option, index) => {
|
816 |
+
// const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
|
817 |
+
// const listItem = document.createElement('div');
|
818 |
+
// listItem.classList.add('form-check');
|
819 |
+
// listItem.innerHTML = `
|
820 |
+
// <input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
|
821 |
+
// data-name="${option}" data-group="${addon.name}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
|
822 |
+
// <label class="form-check-label" for="${optionId}">
|
823 |
+
// ${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
|
824 |
+
// </label>
|
825 |
+
// `;
|
826 |
+
// optionsContainer.appendChild(listItem);
|
827 |
+
// });
|
828 |
+
// sectionDiv.appendChild(optionsContainer);
|
829 |
+
// addonsList.appendChild(sectionDiv);
|
830 |
+
// });
|
831 |
+
// })
|
832 |
+
// .catch(err => {
|
833 |
+
// console.error('Error fetching add-ons:', err);
|
834 |
+
// document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
|
835 |
+
// });
|
836 |
+
// }
|
837 |
+
|
838 |
+
|
839 |
+
function showItemDetails(name, price, image, description, section, selectedCategory) {
|
840 |
+
// Set the modal details
|
841 |
+
document.getElementById('modal-name').innerText = name || 'Unnamed Item';
|
842 |
+
document.getElementById('modal-price').innerText = price ? `$${price}` : 'Price not available';
|
843 |
+
document.getElementById('modal-img').src = image || '/static/placeholder.jpg'; // Placeholder image if no image is available
|
844 |
+
document.getElementById('modal-description').innerText = description || 'No description available.';
|
845 |
+
document.getElementById('addons-list').innerHTML = 'Loading customization options...';
|
846 |
+
document.getElementById('modal-instructions').value = ''; // Clear any previous custom request
|
847 |
+
|
848 |
+
// Set hidden data attributes for section and category
|
849 |
+
const modalSectionEl = document.getElementById('modal-section');
|
850 |
+
modalSectionEl.setAttribute('data-section', section || 'default-section');
|
851 |
+
modalSectionEl.setAttribute('data-category', selectedCategory || 'default-category');
|
852 |
+
|
853 |
+
// Set the default quantity to 1
|
854 |
+
document.getElementById('quantityInput').value = 1;
|
855 |
+
|
856 |
+
// Fetch customization options based on the section
|
857 |
+
fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
|
858 |
+
.then(response => response.json())
|
859 |
+
.then(data => {
|
860 |
+
const addonsList = document.getElementById('addons-list');
|
861 |
+
addonsList.innerHTML = ''; // Clear previous content
|
862 |
+
|
863 |
+
if (!data.success || !data.addons || data.addons.length === 0) {
|
864 |
+
addonsList.innerHTML = '<p>No customization options available.</p>';
|
865 |
+
return;
|
866 |
+
}
|
867 |
+
|
868 |
+
// Display customization options inside styled divs
|
869 |
+
data.addons.forEach(addon => {
|
870 |
+
const sectionDiv = document.createElement('div');
|
871 |
+
sectionDiv.classList.add('addon-section'); // Add styling class
|
872 |
+
|
873 |
+
// Add section title
|
874 |
+
const title = document.createElement('h6');
|
875 |
+
title.innerText = addon.name || 'Custom Add-ons';
|
876 |
+
sectionDiv.appendChild(title);
|
877 |
+
|
878 |
+
// Create options list
|
879 |
+
const optionsContainer = document.createElement('div');
|
880 |
+
addon.options.forEach((option, index) => {
|
881 |
+
const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
|
882 |
+
const listItem = document.createElement('div');
|
883 |
+
listItem.classList.add('form-check');
|
884 |
+
listItem.innerHTML = `
|
885 |
+
<input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
|
886 |
+
data-name="${option}" data-group="${addon.name}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
|
887 |
+
<label class="form-check-label" for="${optionId}">
|
888 |
+
${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
|
889 |
+
</label>
|
890 |
+
`;
|
891 |
+
optionsContainer.appendChild(listItem);
|
892 |
});
|
893 |
+
sectionDiv.appendChild(optionsContainer);
|
894 |
+
addonsList.appendChild(sectionDiv);
|
|
|
|
|
895 |
});
|
896 |
+
})
|
897 |
+
.catch(err => {
|
898 |
+
console.error('Error fetching add-ons:', err);
|
899 |
+
document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
|
900 |
+
});
|
901 |
+
}
|
902 |
+
|
903 |
+
|
904 |
+
|
905 |
+
|
906 |
+
|
907 |
+
|
908 |
+
|
909 |
|
910 |
// Handle single-select/deselect logic for checkbox groups in all modals
|
911 |
document.addEventListener('click', function(event) {
|