Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const waterInput = document.getElementById('water-input');
+ const addButton = document.getElementById('add-button');
+ const currentIntake = document.getElementById('current-intake');
+ const progressFill = document.querySelector('.progress-fill');
+ const dailyGoal = 2000;
+ let totalIntake = 0;
+
+ addButton.addEventListener('click', () => {
+ const amount = parseInt(waterInput.value, 10);
+ if (!isNaN(amount) && amount > 0) {
+ totalIntake += amount;
+ updateProgress();
+ checkMilestones();
+ waterInput.value = '';
+ }
+ });
+
+ function updateProgress() {
+ currentIntake.textContent = totalIntake;
+ const progressPercentage = (totalIntake / dailyGoal) * 100;
+ progressFill.style.width = `${progressPercentage}%`;
+ }
+
+ function checkMilestones() {
+ const milestones = [
+ { amount: 500, element: document.getElementById('milestone-500') },
+ { amount: 1000, element: document.getElementById('milestone-1000') },
+ { amount: 1500, element: document.getElementById('milestone-1500') },
+ { amount: 2000, element: document.getElementById('milestone-2000') }
+ ];
+
+ milestones.forEach(milestone => {
+ if (totalIntake >= milestone.amount) {
+ milestone.element.classList.add('achieved');
+ }
+ });
+ }
+ });