-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
692 lines (617 loc) · 34.1 KB
/
index.html
File metadata and controls
692 lines (617 loc) · 34.1 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
<!DOCTYPE html>
<html lang="vi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UniDocs - Kho tài liệu môn học</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/@phosphor-icons/web"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@300;400;500;600;700;800&display=swap');
body {
font-family: 'Be Vietnam Pro', sans-serif;
}
.hero-bg {
background: linear-gradient(135deg, #e0e7ff 0%, #f0fdf4 100%);
}
@keyframes float {
0% { transform: translateY(0px) rotate(0deg); }
50% { transform: translateY(-20px) rotate(1deg); }
100% { transform: translateY(0px) rotate(0deg); }
}
.animate-float {
animation: float 6s ease-in-out infinite;
}
/* Device Frames */
.laptop-frame {
position: relative;
background: #1e293b;
border-radius: 12px;
padding: 10px;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
border: 2px solid #334155;
}
.laptop-screen {
background: #fff;
border-radius: 4px;
overflow: hidden;
aspect-ratio: 16/10;
}
.laptop-base {
height: 10px;
background: #334155;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
width: 110%;
margin-left: -5%;
margin-top: 2px;
position: relative;
}
.laptop-base::after {
content: '';
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
width: 20%;
height: 4px;
background: #1e293b;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
.phone-frame {
width: 120px;
background: #0f172a;
border-radius: 20px;
padding: 8px;
border: 3px solid #1e293b;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
z-index: 20;
flex-shrink: 0;
position: relative;
}
.phone-screen {
background: #f8fafc; /* Match app background */
border-radius: 12px;
overflow: hidden;
aspect-ratio: 9/19;
padding-top: 20px; /* Safe Area for Notch/Dynamic Island */
}
.phone-notch {
position: absolute;
top: 14px;
left: 50%;
transform: translateX(-50%);
width: 32px;
height: 10px;
background: #0f172a;
border-radius: 5px;
z-index: 30;
}
@media (min-width: 768px) {
.phone-frame {
width: 165px;
padding: 10px;
border-radius: 24px;
}
.phone-screen {
border-radius: 16px;
padding-top: 26px;
}
.phone-notch {
width: 44px;
height: 12px;
top: 18px;
border-radius: 6px;
}
}
@keyframes fadeInUp {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
animation: fadeInUp 0.4s ease-out forwards;
}
/* Custom Scrollbar for tabs */
.custom-scrollbar::-webkit-scrollbar {
height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
background: #f1f5f9;
border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
background-color: #cbd5e1;
border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
background-color: #94a3b8;
}
</style>
</head>
<body class="bg-slate-50 text-slate-800 min-h-screen flex flex-col">
<!-- HERO SECTION -->
<header class="bg-white relative overflow-hidden border-b border-slate-100">
<!-- Background Decoration -->
<div
class="absolute top-0 right-0 w-[500px] h-[500px] bg-indigo-50/50 rounded-full blur-3xl -translate-y-1/2 translate-x-1/2 z-0">
</div>
<!-- TOP NAVIGATION -->
<nav class="container mx-auto px-6 py-6 relative z-20 flex items-center justify-between">
<!-- Logo -->
<div class="flex items-center gap-2">
<span class="bg-indigo-600 text-white p-1.5 rounded-lg shadow-sm flex items-center justify-center">
<i class="ph-bold ph-books text-lg"></i>
</span>
<span class="text-xl font-bold text-slate-800 tracking-tight">UniDocs</span>
</div>
<!-- GitHub Button -->
<a href="https://github.com/TranHuuDat2004/UniDocs" target="_blank"
class="flex items-center gap-2 bg-slate-900 text-white px-3 py-2 rounded-full text-sm font-medium hover:bg-slate-800 transition shadow-lg hover:shadow-xl group">
<i class="ph-bold ph-github-logo text-lg"></i>
<div class="h-4 w-[1px] bg-slate-700 mx-1"></div>
<div class="flex items-center gap-1.5 text-amber-400">
<span id="repoStars" class="text-white group-hover:text-amber-400 transition font-bold">...</span>
<i class="ph-fill ph-star"></i>
</div>
</a>
</nav>
<div class="container mx-auto px-6 py-16 md:py-24 relative z-10">
<div class="flex flex-col md:flex-row items-center gap-12 lg:gap-20">
<!-- LEFT CONTENT (Text) -->
<div class="w-full md:w-1/2 text-left">
<h1 class="text-5xl md:text-6xl font-extrabold text-slate-900 leading-[1.15] tracking-tight mb-6">
Kho tài liệu học tập <br>
<span class="text-indigo-600">UniDocs.</span>
</h1>
<p class="text-lg text-slate-500 mb-10 leading-relaxed max-w-lg">
Hệ thống lưu trữ và chia sẻ tài liệu môn học miễn phí.
Truy cập giáo trình, đề thi và bài giảng chất lượng cao chỉ với một cú click.
</p>
<!-- Buttons -->
<div class="flex flex-wrap items-center gap-4 mb-10">
<a href="#subjects" id="exploreBtn"
class="bg-indigo-600 hover:bg-indigo-700 text-white px-8 py-3.5 rounded-full font-bold shadow-lg shadow-indigo-200 transition-all hover:-translate-y-1 flex items-center gap-2">
<i class="ph-bold ph-rocket-launch"></i> Khám phá ngay
</a>
<a href="https://github.com/TranHuuDat2004/UniDocs/issues" target="_blank"
class="bg-white text-indigo-600 border border-indigo-100 hover:bg-indigo-50 px-8 py-3.5 rounded-full font-bold transition-all flex items-center gap-2">
<i class="ph-bold ph-github-logo"></i> Đóng góp
</a>
</div>
<!-- Stats -->
<div class="flex items-center gap-8 mb-12 border-l-4 border-indigo-500 pl-6 py-2">
<div>
<div class="text-3xl font-black text-slate-900">500+</div>
<div class="text-sm font-medium text-slate-500">Tài liệu học tập</div>
</div>
<div class="w-px h-10 bg-slate-200"></div>
<div>
<div class="text-3xl font-black text-slate-900">50+</div>
<div class="text-sm font-medium text-slate-500">Sinh viên đóng góp</div>
</div>
</div>
<!-- Mini Feature Cards -->
<div class="grid grid-cols-3 gap-4 max-w-md">
<div
class="flex flex-col items-center text-center p-3 rounded-xl bg-slate-50 border border-slate-100 hover:shadow-sm transition">
<div
class="w-8 h-8 rounded-full bg-orange-100 text-orange-600 flex items-center justify-center mb-2">
<i class="ph-fill ph-lightning"></i>
</div>
<span class="text-xs font-bold text-slate-700">Truy cập nhanh</span>
</div>
<div
class="flex flex-col items-center text-center p-3 rounded-xl bg-slate-50 border border-slate-100 hover:shadow-sm transition">
<div
class="w-8 h-8 rounded-full bg-blue-100 text-blue-600 flex items-center justify-center mb-2">
<i class="ph-fill ph-files"></i>
</div>
<span class="text-xs font-bold text-slate-700">Đa dạng file</span>
</div>
<div
class="flex flex-col items-center text-center p-3 rounded-xl bg-slate-50 border border-slate-100 hover:shadow-sm transition">
<div
class="w-8 h-8 rounded-full bg-emerald-100 text-emerald-600 flex items-center justify-center mb-2">
<i class="ph-fill ph-check-circle"></i>
</div>
<span class="text-xs font-bold text-slate-700">Miễn phí</span>
</div>
</div>
</div>
<!-- RIGHT CONTENT (Showcase) -->
<div class="w-full md:w-1/2 flex justify-center relative">
<div class="relative w-full max-w-[600px] flex items-end justify-center gap-2 md:gap-6 animate-float">
<!-- Laptop Showcase -->
<div class="laptop-frame decoration-indigo-500 flex-1 min-w-0">
<div class="laptop-screen">
<img src="img/pc-layout.jpg" alt="Desktop Layout" class="w-full h-full object-cover">
</div>
<div class="laptop-base"></div>
</div>
<!-- Phone Showcase -->
<div class="phone-frame relative">
<div class="phone-notch"></div>
<div class="phone-screen text-black">
<img src="img/mobile-layout.jpg" alt="Mobile Layout" class="w-full h-full object-cover">
</div>
</div>
<!-- Badge Decorations -->
<div class="absolute -top-10 left-10 bg-white p-3 rounded-2xl shadow-xl border border-indigo-50 z-30 animate-pulse hidden md:block">
<i class="ph-fill ph-check-circle text-2xl text-emerald-500"></i>
</div>
</div>
<!-- Subtle reflection under -->
<div class="absolute -bottom-16 left-1/2 -translate-x-1/2 w-full h-12 bg-indigo-900/5 blur-3xl rounded-full"></div>
</div>
</div>
</div>
</header>
<!-- SUBJECTS SECTION -->
<main id="subjects" class="container mx-auto px-6 py-16">
<div class="flex items-center justify-between mb-8">
<div>
<h2 class="text-2xl font-bold text-slate-800">Môn học hiện có</h2>
<p class="text-slate-500 mt-1">Chọn môn học để xem tài liệu chi tiết</p>
</div>
<div
class="hidden md:flex items-center bg-white border border-slate-200 rounded-lg px-4 py-2 w-64 focus-within:ring-2 ring-indigo-500/20 transition">
<i class="ph ph-magnifying-glass text-slate-400 text-lg"></i>
<input type="text" placeholder="Tìm kiếm môn học..."
class="bg-transparent border-none outline-none text-sm ml-2 w-full placeholder:text-slate-400">
</div>
</div>
<!-- TABS CONTAINER -->
<div id="categoryTabs" class="flex overflow-x-auto gap-2 mb-8 pb-4 border-b border-slate-200 custom-scrollbar">
<!-- Tabs will be injected here -->
</div>
<!-- Grid container for Categories -->
<div id="subjectContainer" class="min-h-[400px]">
<div class="text-center text-slate-400 py-12">
<i class="ph ph-spinner animate-spin text-3xl mb-3"></i>
<p>Đang tải danh sách môn học...</p>
</div>
</div>
</main>
<!-- NEW SECTION: PROJECTS -->
<section class="bg-white border-t border-slate-200">
<div class="container mx-auto px-6 py-16">
<div class="text-center mb-12">
<h2 class="text-2xl font-bold text-slate-800">Hệ sinh thái học tập</h2>
<p class="text-slate-500 mt-2">Các dự án mã nguồn mở khác được phát triển bởi Dat</p>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
<!-- Project 1: UniDocs -->
<div
class="bg-slate-50 border border-slate-200 rounded-2xl p-6 flex flex-col hover:shadow-lg transition-all duration-300">
<div class="flex items-center gap-4 mb-4">
<div
class="w-12 h-12 rounded-xl bg-indigo-100 text-indigo-600 flex items-center justify-center">
<i class="ph-fill ph-books text-2xl"></i>
</div>
<div>
<h3 class="font-bold text-slate-800 text-lg">UniDocs</h3>
<span class="text-xs font-medium px-2 py-0.5 rounded bg-indigo-100 text-indigo-700">Hiện
tại</span>
</div>
</div>
<p class="text-sm text-slate-600 mb-6 flex-1">
Kho tài liệu môn học mở, giúp sinh viên chia sẻ và tiếp cận kiến thức dễ dàng.
</p>
<div class="flex gap-3 mt-auto">
<a href="#"
class="flex-1 flex items-center justify-center py-2 text-sm font-semibold text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 transition">
Đang xem
</a>
<a href="https://github.com/TranHuuDat2004/UniDocs" target="_blank"
class="px-3 py-2 text-slate-500 bg-white border border-slate-200 rounded-lg hover:bg-slate-50"
title="Github Repo">
<i class="ph-bold ph-github-logo text-lg"></i>
</a>
</div>
</div>
<!-- Project 2: Slidify -->
<div
class="bg-slate-50 border border-slate-200 rounded-2xl p-6 flex flex-col hover:shadow-lg transition-all duration-300">
<div class="flex items-center gap-4 mb-4">
<div
class="w-12 h-12 rounded-xl bg-orange-100 text-orange-600 flex items-center justify-center">
<i class="ph-fill ph-presentation-chart text-2xl"></i>
</div>
<div>
<h3 class="font-bold text-slate-800 text-lg">Slidify</h3>
<span class="text-xs font-medium px-2 py-0.5 rounded bg-orange-100 text-orange-700">Slide
Platform</span>
</div>
</div>
<p class="text-sm text-slate-600 mb-6 flex-1">
Slidify - Nền tảng học tập qua Slide. Trình bày nội dung bài học trực quan và sinh động.
</p>
<div class="flex gap-3 mt-auto">
<a href="https://tranhuudat2004.github.io/Slidify/" target="_blank"
class="flex-1 flex items-center justify-center py-2 text-sm font-semibold text-slate-700 bg-white border border-slate-200 rounded-lg hover:border-orange-500 hover:text-orange-600 transition">
Truy cập Web
</a>
<a href="https://github.com/TranHuuDat2004/Slidify" target="_blank"
class="px-3 py-2 text-slate-500 bg-white border border-slate-200 rounded-lg hover:bg-slate-50"
title="Github Repo">
<i class="ph-bold ph-github-logo text-lg"></i>
</a>
</div>
</div>
<!-- Project 3: Aptis Practice -->
<div
class="bg-slate-50 border border-slate-200 rounded-2xl p-6 flex flex-col hover:shadow-lg transition-all duration-300">
<div class="flex items-center gap-4 mb-4">
<div
class="w-12 h-12 rounded-xl bg-emerald-100 text-emerald-600 flex items-center justify-center">
<i class="ph-fill ph-check-circle text-2xl"></i>
</div>
<div>
<h3 class="font-bold text-slate-800 text-lg">Aptis Practice</h3>
<span class="text-xs font-medium px-2 py-0.5 rounded bg-emerald-100 text-emerald-700">Luyện
thi</span>
</div>
</div>
<p class="text-sm text-slate-600 mb-6 flex-1">
Một trang web luyện thi Aptis ESOL tương tác được xây dựng bằng HTML, CSS và JavaScript.
</p>
<div class="flex gap-3 mt-auto">
<a href="https://tranhuudat2004.github.io/aptis-practice/" target="_blank"
class="flex-1 flex items-center justify-center py-2 text-sm font-semibold text-slate-700 bg-white border border-slate-200 rounded-lg hover:border-emerald-500 hover:text-emerald-600 transition">
Luyện ngay
</a>
<a href="https://github.com/TranHuuDat2004/aptis-practice" target="_blank"
class="px-3 py-2 text-slate-500 bg-white border border-slate-200 rounded-lg hover:bg-slate-50"
title="Github Repo">
<i class="ph-bold ph-github-logo text-lg"></i>
</a>
</div>
</div>
</div>
</div>
</section>
<!-- FOOTER -->
<footer class="bg-white border-t border-slate-200 pt-16 pb-8 mt-12">
<div class="container mx-auto px-6">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8 mb-12">
<!-- Col 1 -->
<div class="lg:col-span-1 pr-4">
<h3 class="text-2xl font-bold text-indigo-600 mb-4 tracking-tight">UniDocs</h3>
<p class="text-slate-500 text-sm leading-relaxed">
Hệ thống lưu trữ và chia sẻ tài liệu học tập miễn phí, giúp sinh viên dễ dàng tiếp cận với nguồn
giáo trình, bài giảng và đề thi chất lượng. Toàn bộ tài liệu được đóng góp và chia sẻ bởi cộng
đồng sinh viên.
</p>
</div>
<!-- Col 2 -->
<div class="lg:pl-8">
<h4 class="font-bold text-slate-800 mb-6 font-semibold">Điều hướng</h4>
<ul class="space-y-4 text-sm text-slate-600 font-medium tracking-wide">
<li><a href="#" class="hover:text-indigo-600 transition flex items-center gap-3"><i
class="ph-fill ph-info text-indigo-500 text-lg"></i> Giới thiệu</a></li>
<li><a href="#subjects" class="hover:text-indigo-600 transition flex items-center gap-3"><i
class="ph-fill ph-book-open text-indigo-500 text-lg"></i> Tài liệu môn học</a></li>
<li><a href="https://github.com/TranHuuDat2004/UniDocs/issues" target="_blank"
class="hover:text-indigo-600 transition flex items-center gap-3"><i
class="ph-fill ph-upload-simple text-indigo-500 text-lg"></i> Đóng góp tài liệu</a>
</li>
<li><a href="https://github.com/TranHuuDat2004/UniDocs" target="_blank"
class="hover:text-indigo-600 transition flex items-center gap-3"><i
class="ph-fill ph-github-logo text-indigo-500 text-lg"></i> Mã nguồn dự án</a></li>
</ul>
</div>
<!-- Col 3 -->
<div>
<h4 class="font-bold text-slate-800 mb-6 font-semibold">Danh mục nổi bật</h4>
<ul class="space-y-4 text-sm text-slate-600 font-medium tracking-wide">
<li><a id="footer-link-programming_algo" href="#subjects"
class="hover:text-indigo-600 transition flex items-center gap-3"><i
class="ph-fill ph-code text-slate-800 text-lg"></i> Lập trình & Thuật toán</a></li>
<li><a id="footer-link-system_network" href="#subjects"
class="hover:text-indigo-600 transition flex items-center gap-3"><i
class="ph-fill ph-cpu text-slate-800 text-lg"></i> Hệ thống & Mạng</a></li>
<li><a id="footer-link-math_basic" href="#subjects"
class="hover:text-indigo-600 transition flex items-center gap-3"><i
class="ph-fill ph-function text-slate-800 text-lg"></i> Toán & Cơ sở ngành</a></li>
<li><a id="footer-link-skills" href="#subjects"
class="hover:text-indigo-600 transition flex items-center gap-3"><i
class="ph-fill ph-users-three text-slate-800 text-lg"></i> Kĩ năng & Bổ trợ</a></li>
</ul>
</div>
<!-- Col 4 -->
<div>
<h4 class="font-bold text-slate-800 mb-6 font-semibold">Thông tin</h4>
<ul class="space-y-4 text-sm text-slate-600 font-medium tracking-wide">
<li class="flex items-center gap-3"><i class="ph-fill ph-user text-indigo-500 text-xl"></i>
<span><strong>Triển khai phần mềm: </strong>Trần Hữu Đạt</span>
</li>
<li class="flex items-center gap-3"><i
class="ph-fill ph-chalkboard-teacher text-indigo-500 text-xl"></i> <span><strong>Nguồn
tài liệu: </strong>Sinh viên TDTU & Tham khảo</span></li>
<li class="flex items-center gap-3"><i class="ph-fill ph-columns text-indigo-500 text-xl"></i>
<span><strong>Cập nhật tài liệu: </strong>25/02/2026</span>
</li>
<li class="flex items-center gap-3"><i
class="ph-fill ph-git-branch text-indigo-500 text-xl"></i> <span><strong>Phiên bản mới
nhất: </strong>
26/02/2026
<!-- <script>document.write(new Date().toLocaleDateString('vi-VN'))</script> -->
</span></li>
</ul>
<div class="mt-6 flex items-center gap-3">
<a href="https://github.com/TranHuuDat2004/UniDocs" target="_blank"
class="flex items-center justify-center w-10 h-10 rounded-full bg-slate-100 text-slate-600 hover:bg-slate-200 transition"
title="Github">
<i class="ph-bold ph-github-logo text-xl"></i>
</a>
</div>
</div>
</div>
</div>
<!-- Bottom Border & Copyright -->
<div class="border-t border-slate-100 bg-slate-50/50 py-6 text-center text-slate-500 text-sm">
© 2024 -
<script>document.write(new Date().getFullYear())</script> UniDocs Tool. All Rights Reserved.
</div>
</footer>
<script>
document.addEventListener('DOMContentLoaded', () => {
loadSubjects();
fetchGitHubStars();
});
// --- GITHUB STARS API ---
async function fetchGitHubStars() {
try {
const res = await fetch('https://api.github.com/repos/TranHuuDat2004/UniDocs');
if (res.ok) {
const data = await res.json();
document.getElementById('repoStars').innerText = data.stargazers_count;
} else {
document.getElementById('repoStars').innerText = '-';
}
} catch (e) {
console.error("Lỗi tải sao GitHub:", e);
document.getElementById('repoStars').innerText = '-';
}
}
// --- CATEGORY CONFIG ---
const CATEGORIES = {
"math_basic": { name: "Toán & Cơ sở ngành", icon: "ph-function" },
"programming_algo": { name: "Lập trình & Thuật toán", icon: "ph-code" },
"system_network": { name: "Hệ thống & Mạng", icon: "ph-cpu" },
"software_db": { name: "Phần Mềm & Cơ sở dữ liệu", icon: "ph-database" },
"app_dev": { name: "Lập trình Ứng dụng", icon: "ph-device-mobile" },
"ai": { name: "Trí tuệ nhân tạo", icon: "ph-brain" },
"skills": { name: "Tổ bộ môn Kĩ năng", icon: "ph-users-three" },
"intern": { name: "Thực tập", icon: "ph-buildings" },
"other": { name: "Khác", icon: "ph-dots-three-circle" }
};
async function loadSubjects() {
try {
const res = await fetch('data/subjects.json');
const allSubjects = await res.json();
if (allSubjects.length > 0) {
const firstSubject = allSubjects[0];
const btn = document.getElementById('exploreBtn');
if (btn) btn.href = `subject.html?id=${firstSubject.id}`;
}
renderCategorizedSubjects(allSubjects);
} catch (e) {
console.error("Lỗi tải subjects:", e);
const container = document.getElementById('subjectContainer');
if (container) {
container.innerHTML = `
<div class="text-center py-12">
<div class="bg-red-50 text-red-600 rounded-lg p-4 inline-block">
<i class="ph-bold ph-warning-circle text-2xl mb-2"></i>
<p>Không thể tải dữ liệu môn học.</p>
</div>
</div>
`;
}
}
}
function renderCategorizedSubjects(subjects) {
const tabContainer = document.getElementById('categoryTabs');
const contentContainer = document.getElementById('subjectContainer');
if (!tabContainer || !contentContainer) return;
tabContainer.innerHTML = '';
contentContainer.innerHTML = '';
// Group subjects
const grouped = {};
subjects.forEach(sub => {
const cat = sub.category || 'other';
if (!grouped[cat]) grouped[cat] = [];
grouped[cat].push(sub);
});
// Update footer links to point to the first subject of each category
const footerCats = ['programming_algo', 'system_network', 'math_basic', 'skills'];
footerCats.forEach(cat => {
const linkEl = document.getElementById(`footer-link-${cat}`);
if (linkEl && grouped[cat] && grouped[cat].length > 0) {
linkEl.href = `subject.html?id=${grouped[cat][0].id}`;
}
});
// Order of categories to display
const order = ["math_basic", "programming_algo", "system_network", "software_db", "app_dev", "ai", "skills", "intern", "other"];
// Filter empty categories
const activeCategories = order.filter(k => grouped[k] && grouped[k].length > 0);
// Set default active
let currentActive = activeCategories[0] || 'other';
// RENDER TABS & SECTIONS
activeCategories.forEach(catKey => {
const subs = grouped[catKey];
const catInfo = CATEGORIES[catKey] || CATEGORIES['other'];
// 1. Create Tab Button
const btn = document.createElement('button');
const isSelected = catKey === currentActive;
btn.className = `whitespace-nowrap px-4 py-3 text-sm font-semibold transition-all border-b-2 flex items-center gap-2 ${isSelected
? 'text-indigo-600 border-indigo-600'
: 'text-slate-500 border-transparent hover:text-indigo-600 hover:border-indigo-100'
}`;
btn.innerHTML = `<i class="ph-bold ${catInfo.icon}"></i> ${catInfo.name}`;
btn.onclick = () => switchTab(catKey);
btn.dataset.tab = catKey;
tabContainer.appendChild(btn);
// 2. Create Section Content
const section = document.createElement('div');
section.id = `cat-${catKey}`;
section.className = isSelected ? 'block animate-fade-in' : 'hidden'; // Removed fade-in-section specific class if not defined
section.innerHTML = `
<div class="mb-6">
<h3 class="text-xl font-bold text-slate-800 flex items-center gap-2">
<i class="ph-fill ${catInfo.icon} text-indigo-600"></i> ${catInfo.name}
<span class="text-xs font-medium text-slate-500 bg-slate-100 px-2 py-1 rounded-full">${subs.length} môn</span>
</h3>
<p class="text-slate-500 text-sm mt-1">Danh sách các môn học thuộc nhóm ${catInfo.name}</p>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
${subs.map(sub => createSubjectCard(sub)).join('')}
</div>
`;
contentContainer.appendChild(section);
});
}
function switchTab(catKey) {
// Update Tabs
document.querySelectorAll('#categoryTabs button').forEach(btn => {
const isSelected = btn.dataset.tab === catKey;
btn.className = `whitespace-nowrap px-4 py-3 text-sm font-semibold transition-all border-b-2 flex items-center gap-2 ${isSelected
? 'text-indigo-600 border-indigo-600'
: 'text-slate-500 border-transparent hover:text-indigo-600 hover:border-indigo-100'
}`;
});
// Update Sections
document.querySelectorAll('#subjectContainer > div').forEach(div => {
if (div.id === `cat-${catKey}`) {
div.classList.remove('hidden');
div.classList.add('block', 'animate-fade-in');
} else {
div.classList.add('hidden');
div.classList.remove('block', 'animate-fade-in');
}
});
}
function createSubjectCard(sub) {
return `
<a href="subject.html?id=${sub.id}" class="group relative bg-white border border-slate-200 rounded-2xl p-6 hover:shadow-xl hover:shadow-indigo-500/10 transition-all hover:-translate-y-1 block h-full flex flex-col">
<div class="absolute top-4 right-4 opacity-0 group-hover:opacity-100 transition-opacity">
<i class="ph-bold ph-arrow-up-right text-indigo-500 text-xl"></i>
</div>
<div class="w-12 h-12 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-500 flex items-center justify-center text-white shadow-lg shadow-indigo-500/30 mb-4 group-hover:scale-110 transition-transform duration-300">
<i class="ph-fill ${sub.icon || 'ph-folder'} text-2xl"></i>
</div>
<h3 class="text-lg font-bold text-slate-800 mb-2">${sub.name}</h3>
<p class="text-sm text-slate-500 line-clamp-2 flex-1">
${sub.description || 'Truy cập tài liệu, bài giảng, đề thi và nhiều hơn nữa.'}
</p>
<div class="mt-4 flex items-center gap-2 text-xs font-medium text-indigo-600 bg-indigo-50 w-fit px-2 py-1 rounded-md">
<i class="ph-fill ph-files"></i> Tài liệu có sẵn
</div>
</a>
`;
}
</script>
</body>
</html>