Spaces:
Build error
Build error
Update templates/index.html
Browse files- templates/index.html +145 -51
templates/index.html
CHANGED
|
@@ -3,64 +3,158 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
| 7 |
-
<
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
method: "POST",
|
| 13 |
-
headers: { "Content-Type": "application/json" },
|
| 14 |
-
body: JSON.stringify({ dish_name: dishName }),
|
| 15 |
-
})
|
| 16 |
-
.then(response => response.json())
|
| 17 |
-
.then(data => {
|
| 18 |
-
if (data.error) {
|
| 19 |
-
alert(data.error);
|
| 20 |
-
} else {
|
| 21 |
-
const popup = document.getElementById("popup");
|
| 22 |
-
popup.innerHTML = `
|
| 23 |
-
<h2>${data["Dish Name"]}</h2>
|
| 24 |
-
<img src="${data["Image URL"]}" alt="${data["Dish Name"]}">
|
| 25 |
-
<p><strong>Description:</strong> ${data["Description"]}</p>
|
| 26 |
-
<p><strong>Ingredients:</strong> ${data["Ingredients"]}</p>
|
| 27 |
-
<p><strong>Allergen Info:</strong> ${data["Allergen Info"]}</p>
|
| 28 |
-
<p><strong>Recommended Items:</strong> ${data["Recommended Items"]}</p>
|
| 29 |
-
<p><strong>Spice Levels:</strong> ${data["Spice Levels"]}</p>
|
| 30 |
-
<button onclick="closePopup()">Close</button>
|
| 31 |
-
`;
|
| 32 |
-
popup.style.display = "block";
|
| 33 |
-
}
|
| 34 |
-
});
|
| 35 |
}
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
}
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
</head>
|
| 43 |
<body>
|
| 44 |
-
<
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
<
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
<img src="{{ item['Image URL'] }}" alt="{{ item['Dish Name'] }}">
|
| 53 |
-
<h3>{{ item['Dish Name'] }}</h3>
|
| 54 |
-
<p>${{ item['Price'] }}</p>
|
| 55 |
-
<button onclick="openPopup('{{ item['Dish Name'] }}')">Add</button>
|
| 56 |
-
</div>
|
| 57 |
-
{% endfor %}
|
| 58 |
-
</div>
|
| 59 |
-
</div>
|
| 60 |
-
{% endfor %}
|
| 61 |
</div>
|
| 62 |
|
| 63 |
<!-- Pop-Up Modal -->
|
| 64 |
-
<div
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
</body>
|
| 66 |
</html>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Food Menu Pop-Up</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
font-family: Arial, sans-serif;
|
| 10 |
+
margin: 0;
|
| 11 |
+
padding: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
}
|
| 13 |
|
| 14 |
+
.menu-item {
|
| 15 |
+
display: flex;
|
| 16 |
+
justify-content: space-between;
|
| 17 |
+
align-items: center;
|
| 18 |
+
padding: 15px;
|
| 19 |
+
border: 1px solid #ddd;
|
| 20 |
+
border-radius: 8px;
|
| 21 |
+
margin: 10px;
|
| 22 |
}
|
| 23 |
+
|
| 24 |
+
.menu-item img {
|
| 25 |
+
width: 100px;
|
| 26 |
+
height: 80px;
|
| 27 |
+
object-fit: cover;
|
| 28 |
+
cursor: pointer;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
.menu-item button {
|
| 32 |
+
background-color: green;
|
| 33 |
+
color: white;
|
| 34 |
+
border: none;
|
| 35 |
+
padding: 10px;
|
| 36 |
+
border-radius: 5px;
|
| 37 |
+
cursor: pointer;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
.menu-item button:hover {
|
| 41 |
+
background-color: darkgreen;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/* Pop-Up Modal */
|
| 45 |
+
.popup {
|
| 46 |
+
position: fixed;
|
| 47 |
+
top: 0;
|
| 48 |
+
left: 0;
|
| 49 |
+
width: 100%;
|
| 50 |
+
height: 100%;
|
| 51 |
+
background-color: rgba(0, 0, 0, 0.6);
|
| 52 |
+
display: flex;
|
| 53 |
+
justify-content: center;
|
| 54 |
+
align-items: center;
|
| 55 |
+
visibility: hidden;
|
| 56 |
+
opacity: 0;
|
| 57 |
+
transition: visibility 0s, opacity 0.3s ease-in-out;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
.popup.active {
|
| 61 |
+
visibility: visible;
|
| 62 |
+
opacity: 1;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.popup-content {
|
| 66 |
+
background: white;
|
| 67 |
+
padding: 20px;
|
| 68 |
+
border-radius: 8px;
|
| 69 |
+
text-align: center;
|
| 70 |
+
width: 50%;
|
| 71 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.popup-content img {
|
| 75 |
+
width: 100%;
|
| 76 |
+
height: auto;
|
| 77 |
+
border-radius: 8px;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.popup-content h2 {
|
| 81 |
+
margin: 15px 0;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.popup-content p {
|
| 85 |
+
margin: 10px 0;
|
| 86 |
+
font-size: 16px;
|
| 87 |
+
color: #555;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.close-btn {
|
| 91 |
+
background: red;
|
| 92 |
+
color: white;
|
| 93 |
+
border: none;
|
| 94 |
+
padding: 10px 20px;
|
| 95 |
+
border-radius: 5px;
|
| 96 |
+
cursor: pointer;
|
| 97 |
+
margin-top: 15px;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
.close-btn:hover {
|
| 101 |
+
background: darkred;
|
| 102 |
+
}
|
| 103 |
+
</style>
|
| 104 |
</head>
|
| 105 |
<body>
|
| 106 |
+
<div class="menu-item">
|
| 107 |
+
<div>
|
| 108 |
+
<h3>Samosa</h3>
|
| 109 |
+
<p>$0.6</p>
|
| 110 |
+
<p>Crispy fried pastry filled with spiced potatoes and peas.</p>
|
| 111 |
+
</div>
|
| 112 |
+
<img src="/mnt/data/image.png" alt="Samosa" class="menu-image" data-name="Samosa" data-price="$0.6" data-description="Crispy fried pastry filled with spiced potatoes and peas. Serves 1. [Energy: 200 kcal, Protein: 5g, Carbohydrates: 25g, Fiber: 3g, Fat: 10g, Sugar: 1g]">
|
| 113 |
+
<button class="add-btn" data-name="Samosa" data-price="$0.6" data-description="Crispy fried pastry filled with spiced potatoes and peas. Serves 1. [Energy: 200 kcal, Protein: 5g, Carbohydrates: 25g, Fiber: 3g, Fat: 10g, Sugar: 1g]">Add</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
</div>
|
| 115 |
|
| 116 |
<!-- Pop-Up Modal -->
|
| 117 |
+
<div class="popup" id="popup">
|
| 118 |
+
<div class="popup-content">
|
| 119 |
+
<img id="popup-image" src="" alt="Food Image">
|
| 120 |
+
<h2 id="popup-name"></h2>
|
| 121 |
+
<p id="popup-price"></p>
|
| 122 |
+
<p id="popup-description"></p>
|
| 123 |
+
<button class="close-btn" onclick="closePopup()">Close</button>
|
| 124 |
+
</div>
|
| 125 |
+
</div>
|
| 126 |
+
|
| 127 |
+
<script>
|
| 128 |
+
const popup = document.getElementById("popup");
|
| 129 |
+
const popupImage = document.getElementById("popup-image");
|
| 130 |
+
const popupName = document.getElementById("popup-name");
|
| 131 |
+
const popupPrice = document.getElementById("popup-price");
|
| 132 |
+
const popupDescription = document.getElementById("popup-description");
|
| 133 |
+
|
| 134 |
+
function openPopup(event) {
|
| 135 |
+
const target = event.target;
|
| 136 |
+
const name = target.dataset.name;
|
| 137 |
+
const price = target.dataset.price;
|
| 138 |
+
const description = target.dataset.description;
|
| 139 |
+
const image = target.src || target.parentNode.querySelector('img').src;
|
| 140 |
+
|
| 141 |
+
popupName.textContent = name;
|
| 142 |
+
popupPrice.textContent = price;
|
| 143 |
+
popupDescription.textContent = description;
|
| 144 |
+
popupImage.src = image;
|
| 145 |
+
|
| 146 |
+
popup.classList.add("active");
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
function closePopup() {
|
| 150 |
+
popup.classList.remove("active");
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
const addButtons = document.querySelectorAll(".add-btn");
|
| 154 |
+
const menuImages = document.querySelectorAll(".menu-image");
|
| 155 |
+
|
| 156 |
+
addButtons.forEach(button => button.addEventListener("click", openPopup));
|
| 157 |
+
menuImages.forEach(image => image.addEventListener("click", openPopup));
|
| 158 |
+
</script>
|
| 159 |
</body>
|
| 160 |
</html>
|