-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
1533 lines (1338 loc) · 88.7 KB
/
script.js
File metadata and controls
1533 lines (1338 loc) · 88.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
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Global variables
let currentUser = null;
let allTasks = [];
// Helper: set the active nav link based on current location or SPA page id
function setActiveNavFromLocation() {
try {
const navLinks = document.querySelectorAll('.nav-links a');
navLinks.forEach(a => a.classList.remove('active'));
navLinks.forEach(a => {
const href = a.getAttribute('href') || '';
if (!href) return;
if (href === 'index.html' && (window.location.pathname === '/' || window.location.pathname.endsWith('index.html'))) {
a.classList.add('active');
return;
}
if (window.location.pathname.endsWith(href) || window.location.pathname === '/' + href) {
a.classList.add('active');
}
});
// click handlers to set active immediately for UX
navLinks.forEach(a => {
a.addEventListener('click', () => {
navLinks.forEach(x => x.classList.remove('active'));
a.classList.add('active');
});
});
} catch (e) {
// no-op
}
}
// Tasks data for classes 1-10 (define tasksData so later code can extend it for 11-50)
const tasksData = {
1: [
{ id: 1, title: "HTML Basics", description: "Learn HTML structure and elements.", requirements: ["Create semantic HTML", "Use headings and lists"], dueDate: "2024-01-20", difficulty: "Beginner" },
{ id: 101, title: "HTML Forms", description: "Build forms and handle input types.", requirements: ["Create form fields", "Use labels and validation"], dueDate: "2024-01-22", difficulty: "Beginner" }
],
2: [
{ id: 2, title: "CSS Fundamentals", description: "Styling with CSS selectors and layout.", requirements: ["Use Flexbox", "Apply responsive design"], dueDate: "2024-01-24", difficulty: "Beginner" },
{ id: 102, title: "Advanced CSS", description: "Learn transitions and animations.", requirements: ["Create animations", "Use transitions"], dueDate: "2024-01-26", difficulty: "Intermediate" }
],
3: [
{ id: 3, title: "JavaScript Variables & Functions", description: "Practice JavaScript fundamentals.", requirements: ["Create variables", "Write functions"], dueDate: "2024-01-28", difficulty: "Beginner" },
{ id: 203, title: "DOM Manipulation Basics", description: "Learn to manipulate HTML elements using JavaScript.", requirements: ["Select DOM elements", "Change content", "Add event listeners"], dueDate: "2024-01-30", difficulty: "Intermediate" }
],
4: [
{ id: 4, title: "Responsive Portfolio", description: "Build a responsive portfolio website.", requirements: ["Mobile-first design", "Use Grid or Flexbox"], dueDate: "2024-01-30", difficulty: "Intermediate" },
{ id: 104, title: "Bootstrap Framework", description: "Create a responsive website using Bootstrap.", requirements: ["Use Bootstrap components", "Customize theme"], dueDate: "2024-02-02", difficulty: "Intermediate" }
],
5: [
{ id: 5, title: "Interactive To-Do App", description: "Create a to-do application.", requirements: ["DOM manipulation", "Local storage"], dueDate: "2024-02-05", difficulty: "Intermediate" },
{ id: 105, title: "JavaScript Arrays & Objects", description: "Work with arrays and objects.", requirements: ["Manipulate arrays", "Use object methods"], dueDate: "2024-02-08", difficulty: "Intermediate" }
],
6: [
{ id: 106, title: "ES6+ Features", description: "Learn modern JavaScript features.", requirements: ["Arrow functions", "Destructuring"], dueDate: "2024-02-10", difficulty: "Intermediate" },
{ id: 206, title: "Async JavaScript", description: "Master promises and async/await.", requirements: ["Use promises", "Implement async/await"], dueDate: "2024-02-12", difficulty: "Advanced" }
],
7: [
{ id: 107, title: "API Integration", description: "Integrate external APIs.", requirements: ["Fetch data", "Handle responses"], dueDate: "2024-02-15", difficulty: "Advanced" },
{ id: 207, title: "Weather App Project", description: "Build a weather application.", requirements: ["Use weather API", "Display current weather"], dueDate: "2024-02-18", difficulty: "Advanced" }
],
8: [
{ id: 108, title: "React Introduction", description: "Get started with React.", requirements: ["Create components", "Use JSX"], dueDate: "2024-02-20", difficulty: "Advanced" },
{ id: 208, title: "React Props & State", description: "Master props and state.", requirements: ["Pass props", "Manage state"], dueDate: "2024-02-22", difficulty: "Advanced" }
],
9: [
{ id: 109, title: "React Hooks", description: "Learn React hooks.", requirements: ["useState", "useEffect"], dueDate: "2024-02-25", difficulty: "Advanced" },
{ id: 209, title: "React Router", description: "Implement client-side routing.", requirements: ["Set up routes", "Handle navigation"], dueDate: "2024-02-28", difficulty: "Advanced" }
],
10: [
{ id: 110, title: "Node.js Basics", description: "Intro to server-side JavaScript.", requirements: ["Set up Node", "Create server"], dueDate: "2024-03-02", difficulty: "Advanced" },
{ id: 210, title: "Express.js Framework", description: "Build apps with Express.", requirements: ["Create API routes", "Handle middleware"], dueDate: "2024-03-05", difficulty: "Advanced" }
]
};
// Initialize the application
window.addEventListener('load', function() {
setTimeout(() => {
const loadingEl = document.getElementById('loadingScreen');
if (loadingEl) loadingEl.classList.add('hidden');
checkAuthStatus();
// Only run page-specific initializers when their DOM exists
if (document.getElementById('taskList')) loadDefaultTasks();
if (document.getElementById('typewriterText')) startTypewriter();
// If we are on the SPA tasks/dashboard area (visible) or the standalone tasks.html,
// ensure tasks are rendered or redirect. This prevents forcing login when Home is active.
const dashboardListEl = document.getElementById('taskList');
const tasksListEl = document.getElementById('tasksList');
function isVisibleInSPA(el) {
if (!el) return false;
const page = el.closest('.page');
if (page) return page.classList.contains('active');
// if not inside a .page container, assume standalone page and visible
return true;
}
const onStandaloneTasksPage = window.location.pathname.endsWith('tasks.html') || window.location.pathname.endsWith('/tasks.html');
if ((dashboardListEl && isVisibleInSPA(dashboardListEl)) || (tasksListEl && isVisibleInSPA(tasksListEl)) || onStandaloneTasksPage) {
if (!currentUser) {
// redirect unauthenticated users to login and include next param
location.href = 'login.html?next=tasks.html';
} else {
renderAllTasks();
}
}
}, 3000);
});
// Typewriter effect
function startTypewriter() {
const messages = [
"Your homework submission and task management platform",
"Submit assignments and track your progress",
"Manage your learning journey with ease",
"Connect with instructors and classmates"
];
let messageIndex = 0;
let charIndex = 0;
let isDeleting = false;
const typewriterElement = document.getElementById('typewriterText');
if (!typewriterElement) return; // nothing to do on other pages
function type() {
const currentMessage = messages[messageIndex];
if (isDeleting) {
typewriterElement.textContent = currentMessage.substring(0, charIndex - 1);
charIndex--;
} else {
typewriterElement.textContent = currentMessage.substring(0, charIndex + 1);
charIndex++;
}
let typeSpeed = isDeleting ? 50 : 100;
if (!isDeleting && charIndex === currentMessage.length) {
typeSpeed = 2000;
isDeleting = true;
} else if (isDeleting && charIndex === 0) {
isDeleting = false;
messageIndex = (messageIndex + 1) % messages.length;
typeSpeed = 500;
}
setTimeout(type, typeSpeed);
}
type();
}
// Website reload function
function reloadWebsite() {
location.reload();
}
// Navigation functions
function showPage(pageId) {
// Try SPA behavior first (when all sections are present). If the requested
// page section is not in the DOM (because we're on a separate HTML file),
// navigate to the corresponding HTML file.
const sectionId = pageId + 'Page';
const sectionEl = document.getElementById(sectionId);
// Protect dashboard access
if (pageId === 'dashboard' && !currentUser) {
// if on SPA, show login; otherwise redirect to login page
if (document.getElementById('loginPage')) {
showMessage('loginMessage', 'Please login to access the student dashboard!', 'error');
showPage('login');
return;
} else {
location.href = 'login.html';
return;
}
}
if (sectionEl) {
// SPA: show/hide sections
const pages = document.querySelectorAll('.page');
pages.forEach(page => page.classList.remove('active'));
sectionEl.classList.add('active');
// Close mobile menu when navigating
const navLinks = document.getElementById('navLinks');
if (navLinks) navLinks.classList.remove('active');
// Update active nav link for SPA navigation
try {
const mapping = { home: 'index.html', about: 'about.html', team: 'team.html', tasks: 'tasks.html', contact: 'contact.html', dashboard: 'dashboard.html', login: 'login.html', signup: 'signup.html' };
const href = mapping[pageId] || (pageId + '.html');
const link = document.querySelector('.nav-links a[href="' + href + '"]');
if (link) {
document.querySelectorAll('.nav-links a').forEach(a => a.classList.remove('active'));
link.classList.add('active');
}
} catch (e) {}
return;
}
// Fallback: navigate to standalone HTML pages
const mapping = {
home: 'index.html',
about: 'about.html',
team: 'team.html',
tasks: 'tasks.html',
login: 'login.html',
signup: 'signup.html',
contact: 'contact.html',
dashboard: 'dashboard.html'
};
const target = mapping[pageId] || (pageId + '.html');
location.href = target;
}
// Render all tasks to the tasks page (support dashboard's #taskList and legacy #tasksList)
function renderAllTasks() {
const dashboardList = document.getElementById('taskList');
const tasksList = document.getElementById('tasksList');
const container = dashboardList || tasksList;
if (!container) return;
container.innerHTML = '';
Object.keys(tasksData).forEach(classNum => {
tasksData[classNum].forEach(task => {
const card = createTaskCard(task, classNum);
container.appendChild(card);
});
});
}
function toggleMobileMenu() {
const navLinks = document.getElementById('navLinks');
const mobileMenuBtn = document.getElementById('mobileMenuBtn');
if (!navLinks || !mobileMenuBtn) return; // nothing to toggle on this page
navLinks.classList.toggle('active');
mobileMenuBtn.classList.toggle('active');
}
// Helper to read query params from URL
function getQueryParam(name) {
const params = new URLSearchParams(window.location.search);
return params.get(name);
}
// Authentication functions
function handleLogin(event) {
event.preventDefault();
const emailOrUsername = document.getElementById('loginEmailOrUsername').value;
const password = document.getElementById('loginPassword').value;
// Get users from localStorage
const users = JSON.parse(localStorage.getItem('users') || '[]');
const user = users.find(u =>
(u.email === emailOrUsername || u.username === emailOrUsername) &&
u.password === password
);
if (user) {
currentUser = user;
localStorage.setItem('currentUser', JSON.stringify(user));
showMessage('loginMessage', 'Login successful! Redirecting...', 'success');
setTimeout(() => {
updateNavigation();
// If there's a next param in the URL, go there after login
const next = getQueryParam('next');
if (next) {
const allowed = ['tasks.html', 'dashboard.html', 'index.html'];
if (allowed.includes(next)) {
location.href = next;
return;
}
}
showPage('dashboard');
updateWelcomeMessage();
updateStudentDashboardStats();
updateProfileDisplay();
}, 1000);
} else {
showMessage('loginMessage', 'Invalid email/username or password!', 'error');
}
}
function handleSignup(event) {
event.preventDefault();
const name = document.getElementById('signupName').value;
const username = document.getElementById('signupUsername').value;
const email = document.getElementById('signupEmail').value;
const phone = document.getElementById('signupPhone').value;
const password = document.getElementById('signupPassword').value;
const confirmPassword = document.getElementById('confirmPassword').value;
// Validate passwords match
if (password !== confirmPassword) {
showMessage('signupMessage', 'Passwords do not match!', 'error');
return;
}
// Validate password strength
if (password.length < 6) {
showMessage('signupMessage', 'Password must be at least 6 characters long!', 'error');
return;
}
// Get existing users
const users = JSON.parse(localStorage.getItem('users') || '[]');
// Check if user already exists
if (users.find(u => u.email === email)) {
showMessage('signupMessage', 'User with this email already exists!', 'error');
return;
}
// Check if username already exists
if (users.find(u => u.username === username)) {
showMessage('signupMessage', 'Username is already taken!', 'error');
return;
}
// Create new user
const newUser = {
id: Date.now(),
name,
username,
email,
phone,
password,
profileImage: null,
joinDate: new Date().toISOString()
};
users.push(newUser);
localStorage.setItem('users', JSON.stringify(users));
showMessage('signupMessage', 'Account created successfully! Please login.', 'success');
setTimeout(() => {
showPage('login');
}, 1500);
}
function logout() {
currentUser = null;
localStorage.removeItem('currentUser');
updateNavigation();
showPage('home');
}
function checkAuthStatus() {
const savedUser = localStorage.getItem('currentUser');
if (savedUser) {
currentUser = JSON.parse(savedUser);
updateNavigation();
updateWelcomeMessage();
updateStudentDashboardStats();
updateProfileDisplay();
// If on tasks page (either id), render tasks
if (document.getElementById('taskList') || document.getElementById('tasksList')) {
renderAllTasks();
}
}
}
function updateNavigation() {
const loginLink = document.getElementById('loginLink');
const logoutLink = document.getElementById('logoutLink');
const dashboardLink = document.getElementById('dashboardLink');
const tasksLink = document.getElementById('tasksLink');
if (currentUser) {
if (loginLink) loginLink.style.display = 'none';
if (logoutLink) logoutLink.style.display = 'block';
if (dashboardLink) dashboardLink.style.display = 'block';
if (tasksLink) tasksLink.style.display = 'block';
} else {
if (loginLink) loginLink.style.display = 'block';
if (logoutLink) logoutLink.style.display = 'none';
if (dashboardLink) dashboardLink.style.display = 'none';
if (tasksLink) tasksLink.style.display = 'none';
}
}
function updateWelcomeMessage() {
if (currentUser) {
const welcomeEl = document.getElementById('welcomeMessage');
if (welcomeEl) {
welcomeEl.textContent = `Welcome back, ${currentUser.name}!`;
}
}
}
function updateProfileDisplay() {
if (!currentUser) return;
const profileImage = document.getElementById('userProfileImage');
const defaultAvatar = document.getElementById('defaultAvatar');
if (currentUser.profileImage) {
if (profileImage) {
profileImage.src = currentUser.profileImage;
profileImage.style.display = 'block';
}
if (defaultAvatar) defaultAvatar.style.display = 'none';
} else {
if (profileImage) profileImage.style.display = 'none';
if (defaultAvatar) defaultAvatar.style.display = 'flex';
}
}
// Profile management functions
function changeProfileImage() {
if (!currentUser) return;
const input = document.getElementById('profileImageInput');
if (input) input.click();
}
function handleProfileImageChange(event) {
const file = event.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = function(e) {
currentUser.profileImage = e.target.result;
// Update user in localStorage
const users = JSON.parse(localStorage.getItem('users') || '[]');
const userIndex = users.findIndex(u => u.id === currentUser.id);
if (userIndex !== -1) {
users[userIndex] = currentUser;
localStorage.setItem('users', JSON.stringify(users));
localStorage.setItem('currentUser', JSON.stringify(currentUser));
}
updateProfileDisplay();
};
reader.readAsDataURL(file);
}
function showEditProfile() {
if (!currentUser) return;
const modalTitle = document.getElementById('modalTaskTitle');
const modalContent = document.getElementById('modalTaskContent');
const taskModalEl = document.getElementById('taskModal');
if (!modalTitle || !modalContent || !taskModalEl) return;
modalTitle.textContent = '✏️ Edit Profile';
modalContent.innerHTML = `
<div style="color: white;">
<form onsubmit="handleProfileUpdate(event)">
<div style="text-align: center; margin-bottom: 2rem;">
<div style="position: relative; display: inline-block;">
${currentUser.profileImage ?
`<img src="${currentUser.profileImage}" class="profile-image" style="width: 120px; height: 120px;" onclick="changeProfileImage()">` :
`<div style="width: 120px; height: 120px; border-radius: 50%; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); display: flex; align-items: center; justify-content: center; font-size: 3rem; color: white; cursor: pointer; margin: 0 auto;" onclick="changeProfileImage()">👤</div>`
}
<div style="position: absolute; bottom: 0; right: 0; background: #667eea; border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 2px solid white;" onclick="changeProfileImage()">
<i class="fas fa-camera" style="font-size: 0.8rem;"></i>
</div>
</div>
<p style="margin-top: 1rem; opacity: 0.8; font-size: 0.9rem;">Click to change profile picture</p>
</div>
<div class="form-group">
<label for="editName">Full Name</label>
<input type="text" id="editName" value="${currentUser.name}" required>
</div>
<div class="form-group">
<label for="editEmail">Email</label>
<input type="email" id="editEmail" value="${currentUser.email}" required>
</div>
<div class="form-group">
<label for="editPassword">New Password (leave blank to keep current)</label>
<input type="password" id="editPassword" placeholder="Enter new password">
</div>
<div style="display: flex; gap: 1rem; margin-top: 2rem;">
<button type="submit" class="btn btn-primary" style="flex: 1;">Save Changes</button>
<button type="button" class="btn btn-secondary" onclick="closeModal()" style="flex: 1;">Cancel</button>
</div>
</form>
</div>
`;
taskModalEl.classList.add('active');
}
function handleProfileUpdate(event) {
event.preventDefault();
const newName = document.getElementById('editName').value;
const newEmail = document.getElementById('editEmail').value;
const newPassword = document.getElementById('editPassword').value;
// Check if email is already taken by another user
const users = JSON.parse(localStorage.getItem('users') || '[]');
const emailExists = users.find(u => u.email === newEmail && u.id !== currentUser.id);
if (emailExists) {
alert('This email is already taken by another user!');
return;
}
// Update current user
currentUser.name = newName;
currentUser.email = newEmail;
if (newPassword) {
currentUser.password = newPassword;
}
// Update in localStorage
const userIndex = users.findIndex(u => u.id === currentUser.id);
if (userIndex !== -1) {
users[userIndex] = currentUser;
localStorage.setItem('users', JSON.stringify(users));
localStorage.setItem('currentUser', JSON.stringify(currentUser));
}
updateWelcomeMessage();
closeModal();
// Show success message
setTimeout(() => {
alert('Profile updated successfully!');
}, 300);
}
// Task functions
function loadDefaultTasks() {
const taskList = document.getElementById('taskList');
if (!taskList) return;
taskList.innerHTML = '';
// Show tasks from classes 1-10 by default
for (let classNum = 1; classNum <= 10; classNum++) {
if (tasksData[classNum]) {
tasksData[classNum].forEach(task => {
taskList.appendChild(createTaskCard(task, classNum));
});
}
}
}
function searchTasks(event) {
event.preventDefault();
const classSearchEl = document.getElementById('classSearch');
const classNumber = classSearchEl ? classSearchEl.value : null;
const taskList = document.getElementById('taskList');
if (!taskList) return;
if (!classNumber) {
loadDefaultTasks();
return;
}
taskList.innerHTML = '';
if (tasksData[classNumber]) {
tasksData[classNumber].forEach(task => {
taskList.appendChild(createTaskCard(task, classNumber));
});
} else {
taskList.innerHTML = `
<div class="task-card">
<h3>No tasks found for Class ${classNumber}</h3>
<p>Tasks for this class haven't been assigned yet. Check back later!</p>
</div>
`;
}
}
function createTaskCard(task, classNumber) {
const card = document.createElement('div');
card.className = 'task-card';
card.innerHTML = `
<div class="task-header">
<h3>${task.title}</h3>
<span class="task-class">Class ${classNumber}</span>
</div>
<p style="font-size: 1.1rem; margin-bottom: 1rem;">${task.description}</p>
<div style="background: rgba(255,255,255,0.1); padding: 1rem; border-radius: 10px; margin: 1rem 0;">
<h4 style="color: #667eea; margin-bottom: 0.5rem;">📋 What You Need to Do:</h4>
<ul style="padding-left: 1.5rem; line-height: 1.6;">
${task.requirements.map(req => `<li>${req}</li>`).join('')}
</ul>
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin: 1rem 0; font-size: 0.9rem;">
<div><strong>📅 Due:</strong> ${task.dueDate}</div>
<div><strong>⭐ Level:</strong> ${task.difficulty}</div>
</div>
<div class="task-actions">
<button class="btn btn-primary" onclick="submitTask(${task.id}, ${classNumber})" style="flex: 1;">
📤 Submit Your Work
</button>
<button class="btn btn-secondary" onclick="viewTaskDetails(${task.id}, ${classNumber})">
👁️ Full Details
</button>
</div>
`;
return card;
}
function viewTaskDetails(taskId, classNumber) {
const task = tasksData[classNumber] && tasksData[classNumber].find(t => t.id === taskId);
if (!task) return;
const modalTitleEl = document.getElementById('modalTaskTitle');
const modalContentEl = document.getElementById('modalTaskContent');
const taskModalEl = document.getElementById('taskModal');
if (!modalTitleEl || !modalContentEl || !taskModalEl) return;
modalTitleEl.textContent = `📚 ${task.title} - Class ${classNumber}`;
modalContentEl.innerHTML = `
<div style="color: white; line-height: 1.6;">
<div style="background: rgba(102, 126, 234, 0.2); padding: 1.5rem; border-radius: 15px; margin-bottom: 2rem; border-left: 4px solid #667eea;">
<h4 style="margin-bottom: 1rem; color: #667eea;">📝 Task Description:</h4>
<p style="font-size: 1.1rem;">${task.description}</p>
</div>
<div style="background: rgba(255,255,255,0.1); padding: 1.5rem; border-radius: 15px; margin-bottom: 2rem;">
<h4 style="margin-bottom: 1rem; color: #f093fb;">✅ Step-by-Step Requirements:</h4>
<ol style="padding-left: 1.5rem; font-size: 1rem;">
${task.requirements.map(req => `<li style="margin-bottom: 0.5rem;">${req}</li>`).join('')}
</ol>
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2rem;">
<div style="background: rgba(245, 87, 108, 0.2); padding: 1rem; border-radius: 10px; text-align: center;">
<div style="font-size: 1.5rem; margin-bottom: 0.5rem;">📅</div>
<strong>Due Date</strong><br>
${task.dueDate}
</div>
<div style="background: rgba(79, 172, 254, 0.2); padding: 1rem; border-radius: 10px; text-align: center;">
<div style="font-size: 1.5rem; margin-bottom: 0.5rem;">⭐</div>
<strong>Difficulty</strong><br>
${task.difficulty}
</div>
<div style="background: rgba(0, 242, 254, 0.2); padding: 1rem; border-radius: 10px; text-align: center;">
<div style="font-size: 1.5rem; margin-bottom: 0.5rem;">🎯</div>
<strong>Class</strong><br>
Class ${classNumber}
</div>
</div>
<div style="text-align: center;">
<button class="btn btn-primary" onclick="closeModal(); submitTask(${task.id}, ${classNumber})" style="padding: 1rem 2rem; font-size: 1.1rem;">
📤 Ready to Submit Your Work
</button>
</div>
</div>
`;
taskModalEl.classList.add('active');
}
function submitTask(taskId, classNumber) {
if (!currentUser) {
alert('Please login to submit tasks!');
showPage('login');
return;
}
const task = tasksData[classNumber].find(t => t.id === taskId);
if (!task) return;
// Create file upload interface
const uploadHTML = `
<div class="file-upload">
<div style="text-align: center; margin-bottom: 2rem;">
<h3 style="color: white; margin-bottom: 0.5rem;">📤 Submit Your Work</h3>
<p style="color: rgba(255,255,255,0.8); font-size: 1.1rem;">${task.title}</p>
</div>
<form onsubmit="handleTaskSubmission(event, ${taskId}, ${classNumber})">
<div style="background: rgba(255,255,255,0.1); padding: 1.5rem; border-radius: 15px; margin-bottom: 1.5rem;">
<h4 style="color: #667eea; margin-bottom: 1rem;">👤 Student Information</h4>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem;">
<div class="form-group">
<label for="studentName">Name</label>
<input type="text" id="studentName" value="${currentUser.name}" readonly>
</div>
<div class="form-group">
<label for="studentEmail">Email</label>
<input type="email" id="studentEmail" value="${currentUser.email}" readonly>
</div>
</div>
</div>
<div style="background: rgba(255,255,255,0.1); padding: 1.5rem; border-radius: 15px; margin-bottom: 1.5rem;">
<h4 style="color: #f093fb; margin-bottom: 1rem;">📁 Upload Your Completed Work</h4>
<div class="form-group">
<label for="taskFile" style="font-size: 1rem; margin-bottom: 1rem; display: block;">
Choose your file (HTML, CSS, JS, ZIP, PDF, Images, etc.)
</label>
<div class="upload-area" onclick="document.getElementById('taskFile').click()">
<i class="fas fa-cloud-upload-alt" style="font-size: 3rem; margin-bottom: 1rem; color: #667eea;"></i>
<p style="font-size: 1.1rem; font-weight: 600;">Click here to select your file</p>
<p style="font-size: 0.9rem; opacity: 0.7; margin-top: 0.5rem;">or drag and drop your file here</p>
<p style="font-size: 0.8rem; opacity: 0.6; margin-top: 1rem;">✅ All file types accepted • No size limit</p>
</div>
<input type="file" id="taskFile" style="display: none;" required>
</div>
</div>
<div style="background: rgba(255,255,255,0.1); padding: 1.5rem; border-radius: 15px; margin-bottom: 1.5rem;">
<div class="form-group">
<label for="taskNotes" style="color: #4facfe; font-weight: 600;">💬 Additional Comments (Optional)</label>
<textarea id="taskNotes" placeholder="Tell us about your work, any challenges you faced, or special features you added..." style="width: 100%; padding: 1rem; border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 10px; background: rgba(255, 255, 255, 0.1); color: white; font-size: 1rem; min-height: 100px; resize: vertical;"></textarea>
</div>
</div>
<button type="submit" class="btn btn-primary" style="width: 100%; padding: 1rem; font-size: 1.1rem; font-weight: 600;">
🚀 Submit My Work
</button>
</form>
</div>
`;
const modalTitleEl = document.getElementById('modalTaskTitle');
const modalContentEl = document.getElementById('modalTaskContent');
const taskModalEl = document.getElementById('taskModal');
if (!modalTitleEl || !modalContentEl || !taskModalEl) return;
modalTitleEl.textContent = 'Submit Task';
modalContentEl.innerHTML = uploadHTML;
taskModalEl.classList.add('active');
// Add drag and drop functionality
setupDragAndDrop();
}
function setupDragAndDrop() {
const uploadArea = document.querySelector('.upload-area');
const fileInput = document.getElementById('taskFile');
if (!uploadArea || !fileInput) return;
uploadArea.addEventListener('dragover', (e) => {
e.preventDefault();
uploadArea.classList.add('dragover');
});
uploadArea.addEventListener('dragleave', () => {
uploadArea.classList.remove('dragover');
});
uploadArea.addEventListener('drop', (e) => {
e.preventDefault();
uploadArea.classList.remove('dragover');
const files = e.dataTransfer.files;
if (files.length > 0) {
fileInput.files = files;
updateUploadArea(files[0]);
}
});
fileInput.addEventListener('change', (e) => {
if (e.target.files.length > 0) {
updateUploadArea(e.target.files[0]);
}
});
}
function updateUploadArea(file) {
const uploadArea = document.querySelector('.upload-area');
if (!uploadArea) return;
uploadArea.innerHTML = `
<i class="fas fa-file-check" style="font-size: 3rem; margin-bottom: 1rem; color: #22c55e;"></i>
<p><strong>File Selected:</strong> ${file.name}</p>
<p style="font-size: 0.9rem; opacity: 0.7;">Size: ${(file.size / 1024 / 1024).toFixed(2)} MB</p>
<p style="font-size: 0.8rem; margin-top: 0.5rem;">Click to change file</p>
`;
}
function handleTaskSubmission(event, taskId, classNumber) {
event.preventDefault();
const fileInput = document.getElementById('taskFile');
const notesEl = document.getElementById('taskNotes');
const notes = notesEl ? notesEl.value : '';
if (!fileInput.files[0]) {
alert('Please select a file to submit!');
return;
}
const file = fileInput.files[0];
const submission = {
id: Date.now(),
taskId,
classNumber,
studentName: currentUser.name,
studentEmail: currentUser.email,
fileName: file.name,
fileSize: file.size,
notes,
submissionDate: new Date().toISOString()
};
// Save submission to localStorage
const submissions = JSON.parse(localStorage.getItem('taskSubmissions') || '[]');
submissions.push(submission);
localStorage.setItem('taskSubmissions', JSON.stringify(submissions));
// Show success message
const modalContent = document.getElementById('modalTaskContent');
if (modalContent) {
modalContent.innerHTML = `
<div style="text-align: center; color: white;">
<i class="fas fa-check-circle" style="font-size: 4rem; color: #22c55e; margin-bottom: 1rem;"></i>
<h3>Task Submitted Successfully!</h3>
<p style="margin: 1rem 0;">Your task has been submitted and will be reviewed by the instructor.</p>
<div style="background: rgba(255, 255, 255, 0.1); padding: 1rem; border-radius: 10px; margin: 1rem 0;">
<strong>Submission Details:</strong><br>
File: ${file.name}<br>
Size: ${(file.size / 1024 / 1024).toFixed(2)} MB<br>
Submitted: ${new Date().toLocaleString()}
</div>
<button class="btn btn-primary" onclick="closeModal(); updateStudentDashboardStats();">Close</button>
</div>
`;
}
}
function closeModal() {
const taskModalEl = document.getElementById('taskModal');
if (taskModalEl) taskModalEl.classList.remove('active');
}
// Contact form handler
function handleContactForm(event) {
event.preventDefault();
const name = document.getElementById('contactName').value;
const email = document.getElementById('contactEmail').value;
const subject = document.getElementById('contactSubject').value;
const message = document.getElementById('contactMessageText').value;
// Save contact message
const contacts = JSON.parse(localStorage.getItem('contactMessages') || '[]');
contacts.push({
id: Date.now(),
name,
email,
subject,
message,
date: new Date().toISOString()
});
localStorage.setItem('contactMessages', JSON.stringify(contacts));
showMessage('contactMessage', 'Message sent successfully! We\'ll get back to you soon.', 'success');
// Reset form
event.target.reset();
}
// Utility functions
function showMessage(elementId, message, type) {
const element = document.getElementById(elementId);
if (!element) return;
element.innerHTML = `<div class="message ${type}">${message}</div>`;
setTimeout(() => {
if (element) element.innerHTML = '';
}, 5000);
}
// Close modal when clicking outside
window.addEventListener('click', (e) => {
const modal = document.getElementById('taskModal');
if (e.target === modal) {
closeModal();
}
});
// Team member data
const teamMembers = {
1: {
name: "Ahmed Rahman",
role: "Lead Instructor",
specialty: "Full-Stack Development",
bio: "Ahmed has over 8 years of experience in web development and has worked with companies like Google and Microsoft. He leads the Web Dev Academy platform development and curriculum design.",
skills: ["JavaScript", "React", "Node.js", "Python", "MongoDB", "AWS", "Docker", "GraphQL"],
experience: "8+ years",
education: "MS Computer Science, BUET",
social: {
github: "https://github.com/ahmed-rahman",
linkedin: "https://linkedin.com/in/ahmed-rahman",
twitter: "https://twitter.com/ahmed_dev",
email: "ahmed@webdevacademy.com"
},
achievements: [
"Former Senior Developer at Google",
"Published author of 'Modern Web Development'",
"Speaker at 15+ tech conferences",
"Mentored 200+ developers",
"Created 10+ open source projects"
]
},
2: {
name: "Fatima Khan",
role: "Frontend Specialist",
specialty: "React & UI/UX Design",
bio: "Fatima is a creative frontend developer with a keen eye for design. She specializes in creating beautiful, user-friendly interfaces and has a passion for modern web technologies.",
skills: ["React", "Vue.js", "CSS3", "Figma", "Adobe XD", "TypeScript", "Tailwind CSS", "Framer Motion"],
experience: "5+ years",
education: "BS Software Engineering, NSU",
social: {
github: "https://github.com/fatima-khan",
linkedin: "https://linkedin.com/in/fatima-khan",
dribbble: "https://dribbble.com/fatima_designs",
email: "fatima@webdevacademy.com"
},
achievements: [
"UI/UX Designer at top fintech startup",
"Winner of 3 international design competitions",
"Created 50+ successful web applications",
"Expert in responsive and accessible design",
"Featured designer on Dribbble"
]
},
3: {
name: "Rafiq Hassan",
role: "Backend Developer",
specialty: "Node.js & Database Expert",
bio: "Rafiq is a backend specialist with extensive experience in server-side development, database optimization, and API design. He ensures our platform runs smoothly and efficiently.",
skills: ["Node.js", "Express.js", "MongoDB", "PostgreSQL", "Redis", "Docker", "Kubernetes", "Microservices"],
experience: "6+ years",
education: "MS Software Engineering, BUET",
social: {
github: "https://github.com/rafiq-hassan",
linkedin: "https://linkedin.com/in/rafiq-hassan",
stackoverflow: "https://stackoverflow.com/users/rafiq",
email: "rafiq@webdevacademy.com"
},
achievements: [
"Senior Backend Engineer at major e-commerce platform",
"Optimized systems handling 1M+ daily users",
"Expert in database performance tuning",
"Contributor to several open source projects",
"Top 1% contributor on Stack Overflow"
]
},
4: {
name: "Nadia Islam",
role: "UI/UX Designer",
specialty: "Creative Design & User Experience",
bio: "Nadia brings creativity and user-centered design thinking to our platform. She focuses on creating intuitive and engaging user experiences that make learning enjoyable.",
skills: ["Figma", "Adobe Creative Suite", "Sketch", "Principle", "InVision", "User Research", "Prototyping", "Design Systems"],
experience: "4+ years",
education: "BFA Graphic Design, University of Dhaka",
social: {
behance: "https://behance.net/nadia-islam",
linkedin: "https://linkedin.com/in/nadia-islam",
dribbble: "https://dribbble.com/nadia_ui",
email: "nadia@webdevacademy.com"
},
achievements: [
"Lead Designer at award-winning design agency",
"Designed interfaces for 100+ mobile apps",
"Winner of UX Design Excellence Award 2023",
"Speaker at Design Conference Bangladesh",
"Featured in top design publications"
]
},
5: {
name: "Karim Ahmed",
role: "DevOps Engineer",
specialty: "Cloud & Infrastructure",
bio: "Karim manages our cloud infrastructure and deployment pipelines. He ensures our platform is scalable, secure, and always available for our students worldwide.",
skills: ["AWS", "Docker", "Kubernetes", "Terraform", "Jenkins", "Monitoring", "Security", "CI/CD"],
experience: "7+ years",
education: "BS Computer Engineering, BUET",
social: {
github: "https://github.com/karim-ahmed",
linkedin: "https://linkedin.com/in/karim-ahmed",
medium: "https://medium.com/@karim_devops",
email: "karim@webdevacademy.com"
},
achievements: [