Update templates/reward_status.html
Browse files- templates/reward_status.html +27 -23
templates/reward_status.html
CHANGED
@@ -138,13 +138,20 @@
|
|
138 |
<!-- Ingredients -->
|
139 |
<div class="ingredient-card">
|
140 |
{% for ingredient in item.ingredients %}
|
141 |
-
<div class="ingredient"
|
142 |
-
onclick="showIngredientDetails({{ loop.index0 }}, {{ loop.index0 }})">
|
143 |
<img src="{{ ingredient.image }}" alt="{{ ingredient.name }}" onerror="this.src='/static/placeholder.jpg';">
|
144 |
<p>{{ ingredient.name }}</p>
|
145 |
</div>
|
146 |
{% endfor %}
|
147 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
{% endfor %}
|
149 |
</div>
|
150 |
</div>
|
@@ -169,45 +176,42 @@
|
|
169 |
|
170 |
<script>
|
171 |
// JavaScript for showing ingredient details in modal
|
172 |
-
function showIngredientDetails(
|
173 |
-
//
|
174 |
-
const
|
175 |
-
const
|
176 |
-
|
177 |
-
|
178 |
-
document.getElementById("ingredientName").textContent = ingredient.name;
|
179 |
-
|
180 |
-
// Set the ingredient image
|
181 |
-
document.getElementById("ingredientImage").src = ingredient.image;
|
182 |
-
|
183 |
-
// Set health benefits
|
184 |
-
const healthBenefitsList = ingredient.health_benefits.split(',');
|
185 |
-
const funFactsList = ingredient.fun_facts.split(',');
|
186 |
-
|
187 |
document.getElementById("healthBenefits").innerHTML = '';
|
188 |
document.getElementById("funFacts").innerHTML = '';
|
189 |
-
|
190 |
-
// Display health benefits in the modal
|
191 |
healthBenefitsList.forEach(function(item) {
|
192 |
const li = document.createElement("li");
|
193 |
li.textContent = item.trim();
|
194 |
document.getElementById("healthBenefits").appendChild(li);
|
195 |
});
|
196 |
-
|
197 |
-
// Display fun facts in the modal
|
198 |
funFactsList.forEach(function(item) {
|
199 |
const li = document.createElement("li");
|
200 |
li.textContent = item.trim();
|
201 |
document.getElementById("funFacts").appendChild(li);
|
202 |
});
|
203 |
-
|
204 |
-
// Show the modal
|
205 |
document.getElementById("ingredientModal").style.display = "block";
|
206 |
}
|
207 |
|
208 |
function closeModal() {
|
209 |
document.getElementById("ingredientModal").style.display = "none";
|
210 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
</script>
|
212 |
|
213 |
</body>
|
|
|
138 |
<!-- Ingredients -->
|
139 |
<div class="ingredient-card">
|
140 |
{% for ingredient in item.ingredients %}
|
141 |
+
<div class="ingredient" onclick="showIngredientDetails('{{ ingredient.name }}', '{{ ingredient.image }}', '{{ ingredient.health_benefits }}', '{{ ingredient.fun_facts }}')">
|
|
|
142 |
<img src="{{ ingredient.image }}" alt="{{ ingredient.name }}" onerror="this.src='/static/placeholder.jpg';">
|
143 |
<p>{{ ingredient.name }}</p>
|
144 |
</div>
|
145 |
{% endfor %}
|
146 |
</div>
|
147 |
+
|
148 |
+
<!-- Debugging the items and ingredients in console -->
|
149 |
+
<script>
|
150 |
+
console.log("Rendering item: {{ item.name }}");
|
151 |
+
{% for ingredient in item.ingredients %}
|
152 |
+
console.log("Ingredient: {{ ingredient.name }} - Image: {{ ingredient.image }}");
|
153 |
+
{% endfor %}
|
154 |
+
</script>
|
155 |
{% endfor %}
|
156 |
</div>
|
157 |
</div>
|
|
|
176 |
|
177 |
<script>
|
178 |
// JavaScript for showing ingredient details in modal
|
179 |
+
function showIngredientDetails(name, image, healthBenefits, funFacts) {
|
180 |
+
console.log("Ingredient clicked:", name); // Debugging to check if the correct ingredient is clicked
|
181 |
+
const healthBenefitsList = healthBenefits.split(',');
|
182 |
+
const funFactsList = funFacts.split(',');
|
183 |
+
document.getElementById("ingredientName").textContent = name;
|
184 |
+
document.getElementById("ingredientImage").src = image;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
document.getElementById("healthBenefits").innerHTML = '';
|
186 |
document.getElementById("funFacts").innerHTML = '';
|
|
|
|
|
187 |
healthBenefitsList.forEach(function(item) {
|
188 |
const li = document.createElement("li");
|
189 |
li.textContent = item.trim();
|
190 |
document.getElementById("healthBenefits").appendChild(li);
|
191 |
});
|
|
|
|
|
192 |
funFactsList.forEach(function(item) {
|
193 |
const li = document.createElement("li");
|
194 |
li.textContent = item.trim();
|
195 |
document.getElementById("funFacts").appendChild(li);
|
196 |
});
|
|
|
|
|
197 |
document.getElementById("ingredientModal").style.display = "block";
|
198 |
}
|
199 |
|
200 |
function closeModal() {
|
201 |
document.getElementById("ingredientModal").style.display = "none";
|
202 |
}
|
203 |
+
|
204 |
+
// Debugging: Check if items and ingredients exist on page load
|
205 |
+
window.onload = function() {
|
206 |
+
const items = document.querySelectorAll('.item-info');
|
207 |
+
items.forEach(item => {
|
208 |
+
console.log("Item:", item.querySelector('h3').innerText);
|
209 |
+
const ingredients = item.nextElementSibling.querySelectorAll('.ingredient');
|
210 |
+
ingredients.forEach(ingredient => {
|
211 |
+
console.log("Ingredient Name:", ingredient.querySelector('p').innerText);
|
212 |
+
});
|
213 |
+
});
|
214 |
+
}
|
215 |
</script>
|
216 |
|
217 |
</body>
|