-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogress.html
More file actions
240 lines (212 loc) · 6.44 KB
/
progress.html
File metadata and controls
240 lines (212 loc) · 6.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Progress Tracker - CoreFit</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body {
background: linear-gradient(135deg, #1e1e2f, #3b3b58);
color: white;
font-family: 'Segoe UI', sans-serif;
margin: 0;
padding: 20px;
}
h1 {
text-align: center;
font-size: 3rem;
color: #ffcc70;
margin-bottom: 30px;
text-shadow: 0 0 10px #ffcc70;
}
.container {
max-width: 1100px;
margin: 0 auto;
background: rgba(255, 255, 255, 0.05);
padding: 30px;
border-radius: 20px;
box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
backdrop-filter: blur(8px);
}
.form-group {
margin-bottom: 20px;
}
label {
font-weight: bold;
font-size: 18px;
display: block;
margin-bottom: 8px;
}
input {
width: 100%;
padding: 10px;
font-size: 16px;
border-radius: 10px;
border: none;
}
.btn {
padding: 12px 25px;
background: linear-gradient(135deg, #ffcc70, #ffaa00);
border: none;
color: black;
font-weight: bold;
font-size: 18px;
border-radius: 10px;
cursor: pointer;
margin-top: 10px;
}
.chart-container {
margin: 40px 0;
}
.summary {
display: flex;
justify-content: space-between;
margin-top: 20px;
flex-wrap: wrap;
}
.summary div {
flex: 1 1 45%;
background: rgba(255, 255, 255, 0.08);
padding: 20px;
border-radius: 12px;
margin: 10px;
text-align: center;
font-size: 18px;
}
.progress-bar-container {
margin-top: 30px;
}
.progress-label {
margin-bottom: 10px;
font-size: 18px;
font-weight: bold;
}
.progress-bar {
width: 100%;
height: 25px;
background-color: #555;
border-radius: 20px;
overflow: hidden;
}
.progress-fill {
height: 100%;
background: linear-gradient(to right, #ffcc70, #ffaa00);
width: 0;
text-align: center;
color: black;
font-weight: bold;
border-radius: 20px;
line-height: 25px;
}
</style>
</head>
<body>
<h1>📈 Progress Tracker</h1>
<div class="container">
<div class="form-group">
<label for="currentWeight">Current Weight (kg)</label>
<input type="number" id="currentWeight" required>
</div>
<div class="form-group">
<label for="height">Height (cm)</label>
<input type="number" id="height" required>
</div>
<button class="btn" onclick="updateProgress()">Update Progress</button>
<div class="summary">
<div><strong>BMI:</strong> <span id="bmi">--</span></div>
<div><strong>Last Week:</strong> <span id="lastWeek">--</span> kg</div>
<div><strong>This Week:</strong> <span id="thisWeek">--</span> kg</div>
<div><strong>Change:</strong> <span id="weightChange">--</span></div>
</div>
<div class="progress-bar-container">
<div class="progress-label">🎯 Goal Progress</div>
<div class="progress-bar">
<div class="progress-fill" id="progressFill">0%</div>
</div>
</div>
<div class="chart-container">
<canvas id="weightChart"></canvas>
</div>
</div>
<script>
let weightHistory = JSON.parse(localStorage.getItem('weightHistory')) || [];
function calculateBMI(weight, height) {
height = height / 100;
return (weight / (height * height)).toFixed(1);
}
function updateProgress() {
const weight = parseFloat(document.getElementById('currentWeight').value);
const height = parseFloat(document.getElementById('height').value);
const goalWeight = 56; // Set your target weight here or pull from user profile
if (!weight || !height) {
alert("Please enter both weight and height");
return;
}
const bmi = calculateBMI(weight, height);
document.getElementById('bmi').innerText = bmi;
// Update weight history
weightHistory.push(weight);
if (weightHistory.length > 7) weightHistory.shift(); // Keep only last 7 entries
localStorage.setItem('weightHistory', JSON.stringify(weightHistory));
// Update Summary
const lastWeek = weightHistory.length >= 2 ? weightHistory[weightHistory.length - 2] : "--";
const thisWeek = weightHistory[weightHistory.length - 1];
const change = (thisWeek && lastWeek !== "--") ? (thisWeek - lastWeek).toFixed(1) + " kg" : "--";
document.getElementById('lastWeek').innerText = lastWeek;
document.getElementById('thisWeek').innerText = thisWeek;
document.getElementById('weightChange').innerText = change;
// Update Goal progress
const progress = Math.min(100, ((weight / goalWeight) * 100).toFixed(0));
const progressFill = document.getElementById('progressFill');
progressFill.style.width = progress + "%";
progressFill.innerText = progress + "%";
// Update Chart
renderChart();
}
function renderChart() {
const ctx = document.getElementById('weightChart').getContext('2d');
if (window.myChart) window.myChart.destroy();
window.myChart = new Chart(ctx, {
type: 'line',
data: {
labels: weightHistory.map((_, i) => "Week " + (i + 1)),
datasets: [{
label: 'Weight (kg)',
data: weightHistory,
borderColor: '#ffaa00',
backgroundColor: 'rgba(255, 204, 112, 0.2)',
borderWidth: 3,
pointBackgroundColor: '#fff',
tension: 0.3,
}]
},
options: {
responsive: true,
plugins: {
legend: {
labels: {
color: 'white'
}
}
},
scales: {
x: {
ticks: {
color: 'white'
}
},
y: {
ticks: {
color: 'white'
},
beginAtZero: false
}
}
}
});
}
window.onload = renderChart;
</script>
</body>
</html>