Spaces:
Runtime error
Runtime error
Update templates/menu.html
Browse files- templates/menu.html +15 -2
templates/menu.html
CHANGED
|
@@ -120,7 +120,7 @@
|
|
| 120 |
</div>
|
| 121 |
|
| 122 |
<div>
|
| 123 |
-
<h6>Reward Points: <span id="reward-points">{{ reward_points }}</span></h6>
|
| 124 |
</div>
|
| 125 |
</div>
|
| 126 |
|
|
@@ -301,7 +301,20 @@
|
|
| 301 |
console.error('Error adding item to cart:', err);
|
| 302 |
alert('An error occurred while adding the item to the cart.');
|
| 303 |
});
|
| 304 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
|
| 306 |
</script>
|
| 307 |
|
|
|
|
| 120 |
</div>
|
| 121 |
|
| 122 |
<div>
|
| 123 |
+
<h6>Reward Points: <span id="reward-points">{{ reward_points | round(1) }}</span></h6>
|
| 124 |
</div>
|
| 125 |
</div>
|
| 126 |
|
|
|
|
| 301 |
console.error('Error adding item to cart:', err);
|
| 302 |
alert('An error occurred while adding the item to the cart.');
|
| 303 |
});
|
| 304 |
+
}
|
| 305 |
+
// Function to round reward points to a single digit
|
| 306 |
+
function roundRewardPoints() {
|
| 307 |
+
let rewardPointsElement = document.getElementById('reward-points');
|
| 308 |
+
let rewardPoints = parseFloat(rewardPointsElement.innerText);
|
| 309 |
+
|
| 310 |
+
if (!isNaN(rewardPoints)) {
|
| 311 |
+
rewardPointsElement.innerText = rewardPoints.toFixed(1); // Rounds to 1 decimal place
|
| 312 |
+
}
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
// Run the function when the page loads
|
| 316 |
+
window.onload = roundRewardPoints;
|
| 317 |
+
|
| 318 |
|
| 319 |
</script>
|
| 320 |
|