-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDashboard.html
More file actions
674 lines (574 loc) Β· 17.7 KB
/
Dashboard.html
File metadata and controls
674 lines (574 loc) Β· 17.7 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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GreenFarm - Farmer Dashboard</title>
<style>
*{
margin:0;
padding:0;
box-sizing:border-box;
font-family:Arial, Helvetica, sans-serif;
}
body{
background:#e3efe7;
min-height:100vh;
}
/* ---------- NAVBAR ---------- */
.navbar{
display:flex;
justify-content:space-between;
align-items:center;
padding:18px 60px;
background:#fff;
box-shadow:0 2px 5px rgba(0,0,0,0.05);
}
.logo{
font-weight:bold;
font-size:22px;
color:#1f3d2b;
}
.nav-links{
display:flex;
gap:30px;
align-items:center;
}
.nav-links a{
text-decoration:none;
color:#000000;
font-weight:500;
transition:0.3s;
}
.nav-links a:hover{
color:#2f8f57;
}
.logout-btn{
background:#2f8f57;
color:white;
padding:10px 18px;
border-radius:25px;
cursor:pointer;
transition:0.3s;
}
.logout-btn:hover{
background:#1f6b42;
}
/* ---------- DASHBOARD CONTAINER ---------- */
.dashboard{
padding:40px 60px;
max-width:1400px;
margin:auto;
}
/* ---------- PROFILE HEADER ---------- */
.profile-header{
background:#fff;
padding:30px;
border-radius:18px;
box-shadow:0 5px 15px rgba(0,0,0,0.08);
display:flex;
align-items:center;
gap:30px;
margin-bottom:30px;
}
.avatar{
width:100px;
height:100px;
border-radius:50%;
background:linear-gradient(135deg, #2f8f57, #1f6b42);
display:flex;
align-items:center;
justify-content:center;
font-size:42px;
color:white;
}
.profile-info{
flex:1;
}
.profile-name{
font-size:28px;
font-weight:bold;
color:#1a2e23;
margin-bottom:5px;
}
.profile-role{
color:#5a7b69;
font-size:16px;
margin-bottom:15px;
}
.profile-stats{
display:flex;
gap:30px;
}
.stat-item{
text-align:center;
}
.stat-number{
font-size:24px;
font-weight:bold;
color:#2f8f57;
}
.stat-label{
font-size:14px;
color:#5a7b69;
margin-top:5px;
}
.edit-profile-btn{
background:#2f8f57;
color:white;
padding:12px 24px;
border-radius:25px;
border:none;
cursor:pointer;
font-weight:bold;
transition:0.3s;
}
.edit-profile-btn:hover{
background:#1f6b42;
}
/* ---------- QUICK STATS ---------- */
.quick-stats{
display:grid;
grid-template-columns:repeat(4, 1fr);
gap:20px;
margin-bottom:30px;
}
.stat-card{
background:#fff;
padding:25px;
border-radius:18px;
box-shadow:0 5px 15px rgba(0,0,0,0.08);
text-align:center;
transition:0.3s;
}
.stat-card:hover{
transform:translateY(-5px);
box-shadow:0 10px 20px rgba(0,0,0,0.12);
}
.stat-icon{
width:60px;
height:60px;
margin:0 auto 15px;
border-radius:50%;
display:flex;
align-items:center;
justify-content:center;
font-size:28px;
}
.green-bg{background:#d7efe1;}
.blue-bg{background:#d6e8f4;}
.orange-bg{background:#f4e2cc;}
.purple-bg{background:#e8d7f4;}
.stat-value{
font-size:32px;
font-weight:bold;
color:#1a2e23;
margin-bottom:5px;
}
.stat-title{
font-size:14px;
color:#5a7b69;
}
/* ---------- BADGES SECTION ---------- */
.section-title{
font-size:24px;
font-weight:bold;
color:#1a2e23;
margin-bottom:20px;
}
.badges-container{
background:#fff;
padding:30px;
border-radius:18px;
box-shadow:0 5px 15px rgba(0,0,0,0.08);
margin-bottom:30px;
}
.badges-grid{
display:grid;
grid-template-columns:repeat(auto-fill, minmax(140px, 1fr));
gap:20px;
}
.badge{
background:#f3f6f4;
padding:20px;
border-radius:15px;
text-align:center;
border:2px solid #c9dbd0;
transition:0.3s;
}
.badge:hover{
transform:translateY(-3px);
border-color:#2f8f57;
}
.badge-icon{
font-size:40px;
margin-bottom:10px;
}
.badge-name{
font-size:14px;
font-weight:bold;
color:#1a2e23;
margin-bottom:5px;
}
.badge-date{
font-size:12px;
color:#5a7b69;
}
.badge.locked{
opacity:0.4;
}
/* ---------- NAVIGATION CARDS ---------- */
.nav-grid{
display:grid;
grid-template-columns:repeat(auto-fit, minmax(300px, 1fr));
gap:20px;
margin-bottom:30px;
}
.nav-card{
background:#fff;
padding:35px;
border-radius:18px;
box-shadow:0 5px 15px rgba(0,0,0,0.08);
cursor:pointer;
transition:0.3s;
text-decoration:none;
color:inherit;
display:block;
}
.nav-card:hover{
transform:translateY(-5px);
box-shadow:0 10px 25px rgba(0,0,0,0.12);
}
.nav-card-header{
display:flex;
align-items:center;
gap:20px;
margin-bottom:15px;
}
.nav-icon{
width:70px;
height:70px;
border-radius:15px;
display:flex;
align-items:center;
justify-content:center;
font-size:32px;
}
.nav-card-title{
font-size:22px;
font-weight:bold;
color:#1a2e23;
}
.nav-card-desc{
color:#5a7b69;
line-height:1.6;
}
/* ---------- RECENT ACTIVITY ---------- */
.activity-container{
background:#fff;
padding:30px;
border-radius:18px;
box-shadow:0 5px 15px rgba(0,0,0,0.08);
}
.activity-item{
display:flex;
align-items:center;
gap:20px;
padding:15px;
border-bottom:1px solid #e8ede8;
}
.activity-item:last-child{
border-bottom:none;
}
.activity-icon{
width:45px;
height:45px;
border-radius:50%;
display:flex;
align-items:center;
justify-content:center;
font-size:20px;
}
.activity-content{
flex:1;
}
.activity-title{
font-weight:bold;
color:#1a2e23;
margin-bottom:3px;
}
.activity-desc{
font-size:14px;
color:#5a7b69;
}
.activity-time{
font-size:13px;
color:#8a9a8f;
}
/* ---------- RESPONSIVE ---------- */
@media(max-width:768px){
.navbar{
padding:15px 20px;
}
.dashboard{
padding:20px;
}
.profile-header{
flex-direction:column;
text-align:center;
}
.quick-stats{
grid-template-columns:repeat(2, 1fr);
}
.nav-grid{
grid-template-columns:1fr;
}
}
</style>
</head>
<body>
<!-- NAVBAR -->
<div class="navbar">
<div class="logo">π± GreenFarm</div>
<div class="nav-links">
<a href="index.html">Home</a>
<a href="dashboard.html">Dashboard</a>
<a href="experts.html">Experts</a>
<a href="community.html">Community</a>
<a href="certificates.html">Certifications</a>
<span id="guestBadge" style="display:none; background:#f4e2cc; color:#b45309; padding:6px 12px; border-radius:15px; font-size:13px; font-weight:bold;">π€ Guest Mode</span>
<div class="logout-btn" onclick="logoutUser()">Logout</div>
</div>
</div>
<!-- DASHBOARD -->
<div class="dashboard">
<!-- PROFILE HEADER -->
<div class="profile-header">
<div class="avatar">π¨βπΎ</div>
<div class="profile-info">
<div class="profile-name" id="userName">Loading...</div>
<div class="profile-role" id="userRole">Loading...</div>
<div class="profile-stats">
<div class="stat-item">
<div class="stat-number" id="totalScore">0</div>
<div class="stat-label">Total Score</div>
</div>
<div class="stat-item">
<div class="stat-number" id="badgesCount">0</div>
<div class="stat-label">Badges Earned</div>
</div>
<div class="stat-item">
<div class="stat-number" id="quizzesCompleted">0</div>
<div class="stat-label">Quizzes Completed</div>
</div>
<div class="stat-item">
<div class="stat-number" id="globalRank">#--</div>
<div class="stat-label">Global Rank</div>
</div>
</div>
</div>
<button class="edit-profile-btn" onclick="editProfile()">Edit Profile</button>
</div>
<!-- QUICK STATS -->
<div class="quick-stats">
<div class="stat-card">
<div class="stat-icon green-bg">π―</div>
<div class="stat-value" id="accuracyRate">0%</div>
<div class="stat-title">Accuracy Rate</div>
</div>
<div class="stat-card">
<div class="stat-icon blue-bg">π</div>
<div class="stat-value" id="hoursLearned">0</div>
<div class="stat-title">Hours Learned</div>
</div>
<div class="stat-card">
<div class="stat-icon orange-bg">π₯</div>
<div class="stat-value" id="dayStreak">0</div>
<div class="stat-title">Day Streak</div>
</div>
<div class="stat-card">
<div class="stat-icon purple-bg">π¬</div>
<div class="stat-value" id="postsShared">0</div>
<div class="stat-title">Posts Shared</div>
</div>
</div>
<!-- BADGES SECTION -->
<div class="badges-container">
<div class="section-title">π
Achievements & Badges</div>
<div class="badges-grid" id="badgesGrid">
<!-- Badges will be loaded dynamically -->
</div>
</div>
<!-- NAVIGATION GRID -->
<div class="nav-grid">
<a href="certificates.html" class="nav-card" style="background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%); color: white;">
<div class="nav-card-header">
<div class="nav-icon" style="background: rgba(255,255,255,0.2);">π</div>
<div class="nav-card-title" style="color: white;">Professional Certifications</div>
</div>
<div class="nav-card-desc" style="color: rgba(255,255,255,0.9);">Explore industry-recognized certification programs from leading organizations. Boost your career with credentials from IFOAM, FAO, UNESCO, and more.</div>
</a>
<a href="QuizzSelector.html" class="nav-card">
<div class="nav-card-header">
<div class="nav-icon green-bg">π</div>
<div class="nav-card-title">Active Quizzes</div>
</div>
<div class="nav-card-desc">Continue your learning journey with interactive quizzes on farming techniques, crop management, and sustainable practices.</div>
</a>
<a href="experts.html" class="nav-card">
<div class="nav-card-header">
<div class="nav-icon purple-bg">π</div>
<div class="nav-card-title">Expert Network</div>
</div>
<div class="nav-card-desc">Connect with agriculture experts, learn from their experiences, and get personalized advice on sustainable farming practices.</div>
</a>
<a href="community.html" class="nav-card">
<div class="nav-card-header">
<div class="nav-icon blue-bg">π</div>
<div class="nav-card-title">Community Forum</div>
</div>
<div class="nav-card-desc">Share insights, ask questions, and engage with fellow farmers. Post updates, like content, comment, and follow other members.</div>
</a>
<a href="archives.html" class="nav-card">
<div class="nav-card-header">
<div class="nav-icon orange-bg">π</div>
<div class="nav-card-title">Knowledge Grove</div>
</div>
<div class="nav-card-desc">Browse curated study materials and resources. Access comprehensive articles on sustainable agriculture from trusted sources.</div>
</a>
<a href="leaderboard.html" class="nav-card">
<div class="nav-card-header">
<div class="nav-icon orange-bg">π</div>
<div class="nav-card-title">Leaderboard</div>
</div>
<div class="nav-card-desc">See where you rank among farmers worldwide. Compete with others and climb to the top of the global rankings.</div>
</a>
</div>
<!-- RECENT ACTIVITY -->
<div class="activity-container">
<div class="section-title">β‘ Recent Activity</div>
<div id="activityList">
<!-- Activities will be loaded dynamically -->
</div>
</div>
</div>
<script src="auth.js"></script>
<script>
// Protect this page - require authentication
requireAuth();
// Load user data when page loads
window.addEventListener('DOMContentLoaded', function() {
loadUserData();
});
function loadUserData() {
const user = getCurrentUser();
if (!user) {
window.location.href = 'signin.html';
return;
}
// Show guest badge if user is a guest
if (user.isGuest) {
document.getElementById('guestBadge').style.display = 'inline-block';
}
// Load profile info
document.getElementById('userName').textContent = user.fullName;
document.getElementById('userRole').textContent = `${user.role} β’ Member since ${formatDate(user.memberSince)}`;
// Load stats
document.getElementById('totalScore').textContent = user.stats.totalScore.toLocaleString();
document.getElementById('badgesCount').textContent = user.stats.badges;
document.getElementById('quizzesCompleted').textContent = user.stats.quizzesCompleted;
document.getElementById('globalRank').textContent = user.stats.globalRank ? `#${user.stats.globalRank}` : '#--';
document.getElementById('accuracyRate').textContent = user.stats.accuracyRate + '%';
document.getElementById('hoursLearned').textContent = user.stats.hoursLearned;
document.getElementById('dayStreak').textContent = user.stats.dayStreak;
document.getElementById('postsShared').textContent = user.stats.postsShared;
// Load badges
loadBadges(user.badges);
// Load recent activity
loadRecentActivity(user.recentActivity);
}
function loadBadges(earnedBadges) {
const badgesGrid = document.getElementById('badgesGrid');
badgesGrid.innerHTML = '';
// All available badges
const allBadges = [
{ name: 'First Steps', icon: 'π' },
{ name: 'Quiz Master', icon: 'π' },
{ name: 'Green Thumb', icon: 'π±' },
{ name: 'Water Wise', icon: 'π§' },
{ name: 'Soil Scientist', icon: 'π¬' },
{ name: 'Speed Demon', icon: 'β‘' },
{ name: 'Expert Level', icon: 'ποΈ' },
{ name: 'Champion', icon: 'π' }
];
allBadges.forEach(badge => {
const earned = earnedBadges.find(b => b.name === badge.name);
const badgeDiv = document.createElement('div');
badgeDiv.className = earned ? 'badge' : 'badge locked';
badgeDiv.innerHTML = `
<div class="badge-icon">${badge.icon}</div>
<div class="badge-name">${badge.name}</div>
<div class="badge-date">${earned ? formatDate(earned.earnedAt) : 'Locked'}</div>
`;
badgesGrid.appendChild(badgeDiv);
});
}
function loadRecentActivity(activities) {
const activityList = document.getElementById('activityList');
activityList.innerHTML = '';
if (!activities || activities.length === 0) {
activityList.innerHTML = '<p style="text-align:center; color:#5a7b69; padding:20px;">No recent activity yet. Start taking quizzes!</p>';
return;
}
activities.forEach(activity => {
const activityDiv = document.createElement('div');
activityDiv.className = 'activity-item';
const bgClass = getActivityBgClass(activity.type);
activityDiv.innerHTML = `
<div class="activity-icon ${bgClass}">${activity.icon}</div>
<div class="activity-content">
<div class="activity-title">${activity.title}</div>
<div class="activity-desc">${activity.description}</div>
</div>
<div class="activity-time">${getTimeAgo(activity.timestamp)}</div>
`;
activityList.appendChild(activityDiv);
});
}
function getActivityBgClass(type) {
switch(type) {
case 'quiz_completed': return 'green-bg';
case 'badge_earned': return 'orange-bg';
case 'community_post': return 'blue-bg';
case 'rank_update': return 'purple-bg';
default: return 'green-bg';
}
}
function formatDate(dateString) {
const date = new Date(dateString);
const options = { month: 'short', day: 'numeric', year: 'numeric' };
return date.toLocaleDateString('en-US', options);
}
function getTimeAgo(timestamp) {
const now = new Date();
const then = new Date(timestamp);
const diffMs = now - then;
const diffMins = Math.floor(diffMs / 60000);
const diffHours = Math.floor(diffMins / 60);
const diffDays = Math.floor(diffHours / 24);
if (diffMins < 60) return `${diffMins} ${diffMins === 1 ? 'minute' : 'minutes'} ago`;
if (diffHours < 24) return `${diffHours} ${diffHours === 1 ? 'hour' : 'hours'} ago`;
return `${diffDays} ${diffDays === 1 ? 'day' : 'days'} ago`;
}
function editProfile() {
const user = getCurrentUser();
const newName = prompt('Enter your new name:', user.fullName);
if (newName && newName.trim() !== '') {
updateUserProfile({ fullName: newName.trim() });
loadUserData();
alert('Profile updated successfully!');
}
}
</script>
</body>
</html>