-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.html
More file actions
250 lines (231 loc) Β· 7.97 KB
/
dashboard.html
File metadata and controls
250 lines (231 loc) Β· 7.97 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
241
242
243
244
245
246
247
248
249
250
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>CoreFit Dashboard</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" />
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body {
margin: 0;
font-family: 'Segoe UI', sans-serif;
background: linear-gradient(to right, #0f2027, #203a43, #2c5364);
color: white;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
padding: 20px;
}
.dashboard {
background-color: rgba(255, 255, 255, 0.05);
padding: 40px;
border-radius: 20px;
box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
width: 100%;
max-width: 1000px;
text-align: center;
}
.dashboard h1 {
font-size: 36px;
margin-bottom: 10px;
color: #FFD700;
}
.dashboard p {
font-size: 18px;
margin: 8px 0;
}
.buttons {
margin-top: 30px;
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 20px;
}
.btn {
background-color: #FFD700;
color: #000;
font-weight: bold;
padding: 12px 20px;
border: none;
border-radius: 12px;
font-size: 16px;
cursor: pointer;
text-decoration: none;
transition: background-color 0.3s ease, transform 0.2s ease;
}
.btn:hover {
background-color: #e6c200;
transform: translateY(-2px);
}
.logout-btn {
background-color: transparent;
border: 2px solid #FFD700;
color: #FFD700;
margin-top: 30px;
}
.logout-btn:hover {
background-color: #FFD700;
color: #000;
}
.card {
background: rgba(255,255,255,0.08);
padding: 20px;
border-radius: 15px;
margin-top: 30px;
text-align: left;
}
canvas {
max-width: 100%;
margin-top: 15px;
}
#dark-toggle {
position: absolute;
top: 20px;
right: 30px;
background: #FFD700;
border: none;
padding: 10px 15px;
border-radius: 8px;
cursor: pointer;
font-weight: bold;
}
.light-mode {
background: linear-gradient(to right, #f9f9f9, #e2e2e2);
color: #000;
}
.light-mode .dashboard {
background-color: #fff;
color: #000;
}
.light-mode .logout-btn {
border-color: #000;
color: #000;
}
.light-mode .logout-btn:hover {
background-color: #000;
color: #fff;
}
</style>
</head>
<body>
<button id="dark-toggle" onclick="toggleMode()">π Dark</button>
<div class="dashboard">
<h1>Welcome, <span id="username">User</span>! πͺ</h1>
<p><i class="fas fa-envelope"></i> <strong>Email:</strong> <span id="email"></span></p>
<p><i class="fas fa-bullseye"></i> <strong>Goal:</strong> <span id="goal"></span></p>
<p><i class="fas fa-dumbbell"></i> <strong>Program Domain:</strong> <span id="domain"></span></p>
<p><i class="fas fa-weight"></i> <strong>Current BMI:</strong> <span id="bmi">--</span></p>
<div class="buttons">
<a href="calorie.html" class="btn"><i class="fas fa-fire"></i> Calorie Calculator</a>
<a href="diet-plan.html" class="btn"><i class="fas fa-utensils"></i> Diet Plan</a>
<a href="progress.html" class="btn"><i class="fas fa-chart-line"></i> Track Progress</a>
<a href="home.html" class="btn"><i class="fas fa-home"></i> Return to Home</a>
</div>
<div class="card">
<h3>π Weight Progress (Weekly)</h3>
<canvas id="weightChart" height="100"></canvas>
</div>
<div class="card">
<h3>π§ Daily Water Tracker</h3>
<p><strong>Drank:</strong> <span id="waterAmount">0 ml</span> / 2000 ml</p>
<div style="background:#555; border-radius:20px; overflow:hidden; height:25px;">
<div id="waterFill" style="height:100%; background:linear-gradient(to right, #00c6ff, #0072ff); width:0%; text-align:center; color:white; font-weight:bold; line-height:25px;">
0%
</div>
</div>
<button class="btn" style="margin-top:15px;" onclick="addWater()">+ Add Glass (250ml)</button>
</div>
<button class="btn logout-btn" onclick="logout()">πͺ Logout</button>
</div>
<script>
// β
Load user details from sessionStorage
const name = sessionStorage.getItem("name");
const email = sessionStorage.getItem("email");
const goal = sessionStorage.getItem("goal");
const domain = sessionStorage.getItem("domain");
if (!name || !email) {
window.location.href = 'login.html';
} else {
document.getElementById('username').textContent = name;
document.getElementById('email').textContent = email;
document.getElementById('goal').textContent = goal || "--";
document.getElementById('domain').textContent = domain || "--";
}
// β
Get latest weight/height from localStorage
const latestWeight = parseFloat(localStorage.getItem('latestWeight')) || parseFloat(sessionStorage.getItem("weight")) || 0;
const latestHeight = parseFloat(localStorage.getItem('latestHeight')) || parseFloat(sessionStorage.getItem("height")) || 0;
// β
Calculate BMI
if (latestWeight && latestHeight) {
const bmi = (latestWeight / ((latestHeight / 100) ** 2)).toFixed(1);
document.getElementById('bmi').textContent = bmi;
} else {
document.getElementById('bmi').textContent = "--";
}
// β
Load weight history from localStorage
let weightHistory = JSON.parse(localStorage.getItem('weightHistory')) || [];
// β
Render Weight Chart
const ctx = document.getElementById('weightChart').getContext('2d');
const chart = new Chart(ctx, {
type: 'line',
data: {
labels: weightHistory.map((_, i) => "Week " + (i + 1)),
datasets: [{
label: 'Weight (kg)',
data: weightHistory,
borderColor: '#FFD700',
backgroundColor: 'rgba(255, 215, 0, 0.2)',
fill: true,
tension: 0.3,
pointRadius: 5
}]
},
options: {
scales: {
y: { beginAtZero: false, ticks: { color: '#fff' } },
x: { ticks: { color: '#fff' } }
},
plugins: {
legend: { labels: { color: '#fff' } }
}
}
});
// ================= WATER TRACKER =================
const dailyGoal = 2000; // ml
const glassSize = 250; // ml per click
let today = new Date().toLocaleDateString();
let storedDate = localStorage.getItem("waterDate");
let waterDrank = parseInt(localStorage.getItem("waterDrank")) || 0;
if (storedDate !== today) {
waterDrank = 0;
localStorage.setItem("waterDate", today);
localStorage.setItem("waterDrank", waterDrank);
}
function updateWaterUI() {
document.getElementById("waterAmount").textContent = waterDrank + " ml";
const percent = Math.min(100, (waterDrank / dailyGoal) * 100);
const fill = document.getElementById("waterFill");
fill.style.width = percent + "%";
fill.textContent = Math.round(percent) + "%";
}
function addWater() {
waterDrank += glassSize;
if (waterDrank > dailyGoal) waterDrank = dailyGoal;
localStorage.setItem("waterDrank", waterDrank);
updateWaterUI();
}
updateWaterUI();
// β
Other functions
function logout() {
sessionStorage.clear();
window.location.href = 'login.html';
}
function toggleMode() {
document.body.classList.toggle("light-mode");
const toggleBtn = document.getElementById("dark-toggle");
toggleBtn.textContent = document.body.classList.contains("light-mode") ? "βοΈ Light" : "π Dark";
}
</script>
</body>
</html>