-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudy.html
More file actions
980 lines (866 loc) · 55.6 KB
/
Copy pathstudy.html
File metadata and controls
980 lines (866 loc) · 55.6 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LK PYTHON LEARNING | Premium Study Platform</title>
<!-- Tailwind CSS with Typography Plugin -->
<script src="https://cdn.tailwindcss.com?plugins=typography"></script>
<!-- Google Fonts: Outfit for UI, JetBrains Mono for Code -->
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Outfit:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
<!-- FontAwesome Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- PrismJS syntax highlighting (Tomorrow Night Theme) & Line Numbers -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.css" rel="stylesheet" />
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ['Outfit', 'sans-serif'],
mono: ['JetBrains Mono', 'monospace'],
},
colors: {
navy: {
950: '#03050a',
900: '#0a0f1c',
800: '#111827',
700: '#1e293b',
},
accent: {
400: '#22d3ee',
500: '#0ea5e9',
600: '#2563eb',
}
},
animation: {
'fade-in': 'fadeIn 0.4s ease-out forwards',
'slide-up': 'slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards',
'pop-in': 'popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards',
},
keyframes: {
fadeIn: {
'0%': { opacity: '0' },
'100%': { opacity: '1' }
},
slideUp: {
'0%': { opacity: '0', transform: 'translateY(20px)' },
'100%': { opacity: '1', transform: 'translateY(0)' }
},
popIn: {
'0%': { opacity: '0', transform: 'scale(0.95) translateY(10px)' },
'100%': { opacity: '1', transform: 'scale(1) translateY(0)' }
}
}
}
}
}
</script>
<style>
/* Base Premium Styling */
body {
background-color: #0a0f1c;
color: #f8fafc;
background-image:
radial-gradient(circle at 15% 50%, rgba(34, 211, 238, 0.04) 0%, transparent 50%),
radial-gradient(circle at 85% 30%, rgba(37, 99, 235, 0.04) 0%, transparent 50%);
background-attachment: fixed;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(30, 41, 59, 0.8); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #38bdf8; }
/* Glassmorphism Components */
.glass-panel {
background: rgba(17, 24, 39, 0.65);
backdrop-filter: blur(24px);
-webkit-backdrop-filter: blur(24px);
border: 1px solid rgba(255, 255, 255, 0.06);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}
/* Spacious & Animated Card Styling */
.glass-card {
background: linear-gradient(145deg, rgba(30, 41, 59, 0.4) 0%, rgba(17, 24, 39, 0.7) 100%);
border: 1px solid rgba(255, 255, 255, 0.06);
box-shadow: 0 4px 20px rgba(0,0,0,0.1);
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.glass-card:hover {
transform: translateY(-5px) scale(1.02);
border-color: rgba(34, 211, 238, 0.4);
box-shadow: 0 20px 40px -10px rgba(34, 211, 238, 0.15);
background: linear-gradient(145deg, rgba(30, 41, 59, 0.6) 0%, rgba(17, 24, 39, 0.9) 100%);
}
.glass-card:active {
transform: translateY(2px) scale(0.98);
}
.gradient-text {
background: linear-gradient(to right, #22d3ee, #3b82f6);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
/* Prism Code Block Customization */
pre[class*="language-"] {
margin: 0 !important;
border-radius: 0 0 1rem 1rem !important;
background: #0d1321 !important;
border: none !important;
font-family: 'JetBrains Mono', monospace !important;
font-size: 0.95rem; /* Bigger code font */
}
code[class*="language-"] { font-family: 'JetBrains Mono', monospace !important; }
/* Premium Search Input Styling */
.search-glass {
background: rgba(30, 41, 59, 0.4);
border: 1px solid rgba(255, 255, 255, 0.1);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.search-glass:focus-within {
background: rgba(30, 41, 59, 0.8);
border-color: rgba(34, 211, 238, 0.5);
box-shadow: 0 0 20px rgba(34, 211, 238, 0.2);
transform: scale(1.01);
}
/* Terminal Styling */
.terminal-output {
background-color: #03050a;
color: #a5b4fc;
font-family: 'JetBrains Mono', monospace;
white-space: pre-wrap;
word-wrap: break-word;
}
/* Premium Markdown Customizations - SAAF SAAF DIKHNE KE LIYE */
.prose-premium {
font-size: 1.1rem; /* Slightly larger text for readability */
line-height: 1.85;
color: #f1f5f9 !important; /* Pure white/light grey text */
}
.prose-premium strong, .prose-premium b {
color: #ffffff !important;
font-weight: 700;
}
.prose-premium h1, .prose-premium h2, .prose-premium h3, .prose-premium h4 {
color: #ffffff !important;
font-family: 'Outfit', sans-serif;
font-weight: 800;
}
.prose-premium h1 { font-size: 2.5rem; margin-bottom: 2rem; border-bottom: 2px solid rgba(255,255,255,0.1); padding-bottom: 1rem; }
.prose-premium h2 { font-size: 1.85rem; margin-top: 3rem; color: #22d3ee !important; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 0.5rem;}
.prose-premium h3 { font-size: 1.5rem; margin-top: 2rem; color: #60a5fa !important;}
.prose-premium p { margin-bottom: 1.75rem; color: #f1f5f9 !important; }
.prose-premium a { color: #38bdf8 !important; text-decoration: none; border-bottom: 1px solid rgba(56, 189, 248, 0.4); padding-bottom: 2px; transition: all 0.2s;}
.prose-premium a:hover { color: #7dd3fc !important; border-color: #7dd3fc; }
.prose-premium ul, .prose-premium ol { padding-left: 1.5rem; margin-bottom: 1.75rem; color: #f1f5f9 !important; }
.prose-premium li { margin-bottom: 0.75rem; color: #f1f5f9 !important; }
.prose-premium li::marker { color: #22d3ee !important; }
.prose-premium pre { background: #05080f !important; border: 1px solid rgba(255,255,255,0.1); border-radius: 1rem !important; }
.prose-premium :where(code):not(:where([class~="not-prose"] *)) {
background-color: rgba(99, 102, 241, 0.2);
color: #c7d2fe !important;
padding: 0.2rem 0.5rem;
border-radius: 0.5rem;
font-family: 'JetBrains Mono', monospace;
font-size: 0.9em;
}
.prose-premium blockquote {
border-left: 4px solid #22d3ee;
background: rgba(34, 211, 238, 0.05);
padding: 1.5rem 2rem;
border-radius: 0 1rem 1rem 0;
font-style: italic;
color: #e2e8f0 !important;
margin-bottom: 2rem;
}
.prose-premium table { width: 100%; text-align: left; border-collapse: collapse; margin: 2rem 0; }
.prose-premium th { border-bottom: 2px solid rgba(255,255,255,0.1); padding: 1.25rem; color: #ffffff !important; background: rgba(255,255,255,0.03); }
.prose-premium td { border-bottom: 1px solid rgba(255,255,255,0.05); padding: 1.25rem; color: #f1f5f9 !important; }
.prose-premium hr { border-color: rgba(255,255,255,0.1); margin: 3rem 0; }
.prose-premium img { border-radius: 1rem; max-width: 100%; box-shadow: 0 8px 30px rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.05); }
/* Fullscreen API Handlers */
#viewer-wrapper:-webkit-full-screen {
background-color: #0a0f1c !important;
border: none !important;
border-radius: 0 !important;
width: 100vw !important;
height: 100vh !important;
max-width: 100% !important;
overflow-y: auto;
}
#viewer-wrapper:fullscreen {
background-color: #0a0f1c !important;
border: none !important;
border-radius: 0 !important;
width: 100vw !important;
height: 100vh !important;
max-width: 100% !important;
overflow-y: auto;
}
#viewer-wrapper:-webkit-full-screen .viewer-toolbar { display: none !important; }
#viewer-wrapper:fullscreen .viewer-toolbar { display: none !important; }
#viewer-wrapper:-webkit-full-screen .exit-fullscreen-btn { display: flex !important; }
#viewer-wrapper:fullscreen .exit-fullscreen-btn { display: flex !important; }
#viewer-wrapper:-webkit-full-screen .viewer-content { min-height: 100vh; padding: 3rem 2rem; }
#viewer-wrapper:fullscreen .viewer-content { min-height: 100vh; padding: 3rem 2rem; }
</style>
</head>
<body class="antialiased min-h-screen flex flex-col selection:bg-accent-400 selection:text-navy-900">
<!-- Navigation Header -->
<header class="glass-panel sticky top-0 z-50 w-full border-b border-white/10" id="main-header">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex flex-col md:flex-row items-center justify-between h-auto md:h-24 py-4 md:py-0 gap-4">
<!-- Logo / Title -->
<div class="flex items-center gap-4 cursor-pointer group active:scale-95 transition-transform duration-300" onclick="app.navigate('')">
<div class="bg-gradient-to-br from-accent-400 to-accent-600 p-3 rounded-2xl shadow-lg shadow-accent-500/20 group-hover:shadow-accent-500/40 transition-all duration-300">
<i class="fab fa-python text-3xl text-white"></i>
</div>
<div>
<h1 class="text-2xl md:text-3xl font-extrabold text-white tracking-tight">LK PYTHON <span class="gradient-text">LEARNING</span></h1>
<p class="text-[11px] md:text-xs text-accent-400 font-bold tracking-[0.2em] uppercase opacity-80 mt-1">Premium Study Platform</p>
</div>
</div>
<!-- Global Search -->
<div class="relative w-full md:w-[450px]">
<div class="relative search-glass rounded-2xl flex items-center bg-navy-900/40">
<span class="pl-5 text-slate-400 text-lg">
<i class="fas fa-search"></i>
</span>
<input type="text" id="searchInput"
class="w-full pl-4 pr-5 py-3.5 bg-transparent text-white placeholder-slate-500 focus:outline-none text-base font-medium"
placeholder="Search units, topics, files..." autocomplete="off">
<!-- Search Results Dropdown -->
<div id="searchResults" class="absolute top-full left-0 right-0 mt-3 glass-panel rounded-2xl hidden max-h-[450px] overflow-y-auto z-50 border border-white/10 shadow-2xl">
<!-- Populated via JS -->
</div>
</div>
</div>
</div>
</div>
</header>
<!-- Main Content Area -->
<main class="flex-grow w-full max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10 relative">
<!-- Breadcrumb Navigation -->
<nav class="flex items-center space-x-3 text-sm text-slate-400 mb-10 overflow-x-auto whitespace-nowrap pb-2 font-medium custom-scrollbar" id="breadcrumb">
<!-- Populated via JS -->
</nav>
<!-- Dynamic Content Container -->
<div id="content-container" class="relative min-h-[500px]">
<!-- Viewers and Cards will be injected here -->
</div>
</main>
<!-- Footer -->
<footer class="border-t border-white/10 py-8 mt-auto glass-panel" id="main-footer">
<div class="max-w-7xl mx-auto px-4 text-center">
<p class="text-slate-400 text-sm font-medium">
© <span id="year"></span> LK Python Learning. <span class="block sm:inline mt-1 sm:mt-0 opacity-70">Elevate your coding journey.</span>
</p>
</div>
</footer>
<!-- Libraries -->
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
<!-- PrismJS Core and Plugins -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-python.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
<!-- Pyodide for Python Execution -->
<script src="https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.js"></script>
<script>
// --- Core Application Logic ---
document.getElementById('year').textContent = new Date().getFullYear();
const CONFIG = {
owner: 'lkstudiokatoriya-ai',
repo: 'lk-python-learning',
branch: 'main'
};
const state = {
fullTree: [],
currentPath: '',
fileCache: {},
pyodideInstance: null,
isPyodideLoading: false
};
const elements = {
container: document.getElementById('content-container'),
breadcrumb: document.getElementById('breadcrumb'),
searchInput: document.getElementById('searchInput'),
searchResults: document.getElementById('searchResults')
};
const ALLOWED_EXTENSIONS = ['.py', '.md', '.pdf', '.png', '.jpg', '.jpeg', '.webp', '.gif', '.svg'];
// --- Pyodide Initialization & Execution Logic ---
async function loadPythonEngine() {
if (state.pyodideInstance) return state.pyodideInstance;
if (state.isPyodideLoading) {
while(state.isPyodideLoading) { await new Promise(r => setTimeout(r, 100)); }
return state.pyodideInstance;
}
state.isPyodideLoading = true;
try {
const pyodide = await loadPyodide();
window.appendTerminalOutput = (text) => {
const outputEl = document.getElementById('py-output');
if (outputEl) {
outputEl.textContent += text;
outputEl.scrollTop = outputEl.scrollHeight;
}
};
window.promptUserForInput = (promptText) => {
if (promptText) window.appendTerminalOutput(promptText);
const userInput = window.prompt(promptText || "Python Program Input:") || "";
window.appendTerminalOutput(userInput + "\n");
return userInput;
};
await pyodide.runPythonAsync(`
import sys
import js
import builtins
class CustomIO:
def write(self, text):
js.appendTerminalOutput(text)
def flush(self):
pass
sys.stdout = CustomIO()
sys.stderr = CustomIO()
def custom_input(prompt=""): return js.promptUserForInput(prompt)
builtins.input = custom_input
`);
state.pyodideInstance = pyodide;
return pyodide;
} catch (err) {
console.error("Pyodide loading failed", err);
throw err;
} finally {
state.isPyodideLoading = false;
}
}
window.runPythonProgram = async (code) => {
const outputEl = document.getElementById('py-output');
const runBtn = document.getElementById('runBtn');
const originalBtnHtml = runBtn.innerHTML;
outputEl.textContent = "Initializing Python Environment...\n";
runBtn.disabled = true;
runBtn.innerHTML = `<i class="fas fa-spinner fa-spin"></i> Running...`;
try {
const pyodide = await loadPythonEngine();
outputEl.textContent = ">>> Executing Program...\n\n";
await pyodide.runPythonAsync(code);
outputEl.textContent += "\n>>> Execution Completed.";
} catch (err) {
let errorStr = err.toString();
if (errorStr.includes("PythonError:")) errorStr = errorStr.split('PythonError:').pop().trim();
outputEl.textContent += `\n❌ Error:\n${errorStr}`;
} finally {
runBtn.disabled = false;
runBtn.innerHTML = originalBtnHtml;
}
};
window.clearPythonOutput = () => {
const outputEl = document.getElementById('py-output');
if (outputEl) outputEl.textContent = "Terminal cleared. Ready.\n";
};
// Fullscreen API toggle helper
window.toggleFullscreen = () => {
const viewer = document.getElementById('viewer-wrapper');
if (!viewer) return;
if (!document.fullscreenElement && !document.webkitFullscreenElement) {
if (viewer.requestFullscreen) {
viewer.requestFullscreen().catch(err => console.error("Fullscreen error:", err));
} else if (viewer.webkitRequestFullscreen) {
viewer.webkitRequestFullscreen();
}
if (screen.orientation && screen.orientation.lock) {
screen.orientation.lock('landscape').catch(() => {});
}
} else {
if (document.exitFullscreen) document.exitFullscreen();
else if (document.webkitExitFullscreen) document.webkitExitFullscreen();
}
};
// --- Application Initialization ---
async function initApp() {
renderLoading('Loading Premium Environment...');
try {
const response = await fetch(`https://api.github.com/repos/${CONFIG.owner}/${CONFIG.repo}/git/trees/${CONFIG.branch}?recursive=1`);
if (!response.ok) throw new Error('Failed to connect to repository structure.');
const data = await response.json();
state.fullTree = data.tree.filter(item => {
if (item.path.startsWith('.') || item.path.includes('/.')) return false;
if (item.type === 'tree') return true;
return ALLOWED_EXTENSIONS.some(ext => item.path.toLowerCase().endsWith(ext));
});
setTimeout(loadPythonEngine, 1000);
app.navigate('');
} catch (error) {
renderError('Unable to load study material. Please check connection and try again.');
}
}
// --- Formatting Helpers ---
const utils = {
formatName: (pathName) => {
let name = pathName.split('/').pop();
name = name.replace(/\.(py|md|pdf|png|jpg|jpeg|webp|gif|svg)$/i, '');
name = name.replace(/[-_]/g, ' ');
return name.replace(/\b\w/g, l => l.toUpperCase());
},
getFileDetails: (filename) => {
const ext = filename.split('.').pop().toLowerCase();
if (ext === 'py') return { icon: 'fab fa-python', color: 'text-accent-400', bg: 'bg-accent-400/10', border: 'border-accent-400/20' };
if (ext === 'md') return { icon: 'fas fa-file-alt', color: 'text-emerald-400', bg: 'bg-emerald-400/10', border: 'border-emerald-400/20' };
if (ext === 'pdf') return { icon: 'fas fa-file-pdf', color: 'text-rose-400', bg: 'bg-rose-400/10', border: 'border-rose-400/20' };
if (['png', 'jpg', 'jpeg', 'webp', 'gif', 'svg'].includes(ext)) return { icon: 'fas fa-image', color: 'text-purple-400', bg: 'bg-purple-400/10', border: 'border-purple-400/20' };
return { icon: 'fas fa-folder', color: 'text-amber-400', bg: 'bg-amber-400/10', border: 'border-amber-400/20' };
},
getChildren: (path) => {
const prefix = path === '' ? '' : `${path}/`;
return state.fullTree.filter(item => {
if (!item.path.startsWith(prefix)) return false;
const rem = item.path.substring(prefix.length);
return rem.length > 0 && !rem.includes('/');
}).sort((a, b) => {
if (a.type !== b.type) return a.type === 'tree' ? -1 : 1;
return a.path.localeCompare(b.path);
});
}
};
// --- Navigation and View Rendering ---
const app = {
navigate: async (path) => {
state.currentPath = path;
elements.searchInput.value = '';
elements.searchResults.classList.add('hidden');
app.updateBreadcrumbs();
const item = state.fullTree.find(i => i.path === path);
elements.container.className = "relative min-h-[500px] opacity-0";
if (item && item.type === 'blob') {
await app.renderFileViewer(item);
} else {
app.renderFolderView(path);
}
setTimeout(() => {
elements.container.className = "relative min-h-[500px] animate-pop-in";
}, 10);
window.scrollTo({ top: 0, behavior: 'smooth' });
},
updateBreadcrumbs: () => {
const parts = state.currentPath.split('/').filter(p => p);
let html = `
<button onclick="app.navigate('')" class="hover:text-white transition-colors flex items-center gap-2 px-4 py-2 rounded-xl hover:bg-white/5 border border-transparent hover:border-white/10 active:scale-95 text-base">
<i class="fas fa-home"></i> Home
</button>
`;
let accumPath = '';
parts.forEach((part, index) => {
accumPath += (accumPath ? '/' : '') + part;
const isLast = index === parts.length - 1;
const displayName = utils.formatName(part);
html += `<i class="fas fa-chevron-right text-[11px] text-slate-600 mx-1"></i>`;
if (isLast) {
html += `<span class="px-4 py-2 text-accent-400 font-bold truncate max-w-[200px] sm:max-w-xs drop-shadow-[0_0_10px_rgba(34,211,238,0.4)] text-base" title="${displayName}">${displayName}</span>`;
} else {
html += `<button onclick="app.navigate('${accumPath}')" class="hover:text-white transition-colors px-4 py-2 rounded-xl hover:bg-white/5 border border-transparent hover:border-white/10 truncate max-w-[150px] sm:max-w-xs active:scale-95 text-base" title="${displayName}">${displayName}</button>`;
}
});
elements.breadcrumb.innerHTML = html;
},
renderFolderView: (path) => {
const children = utils.getChildren(path);
if (children.length === 0) return renderEmptyFolder();
let html = `
<div class="mb-10 flex flex-row items-center gap-5">
${path !== '' ? `
<button onclick="app.navigate('${path.split('/').slice(0, -1).join('/')}')"
title="Go Back"
class="w-12 h-12 flex-shrink-0 bg-white/5 hover:bg-white/10 border border-white/10 text-slate-300 hover:text-white rounded-2xl transition-all flex items-center justify-center hover:scale-105 active:scale-95 shadow-lg group">
<i class="fas fa-arrow-left text-lg group-hover:-translate-x-1 transition-transform"></i>
</button>
` : ''}
<h2 class="text-2xl md:text-4xl font-extrabold text-white flex items-center gap-4 truncate" title="${utils.formatName(path)}">
${path === '' ?
'<div class="w-14 h-14 flex-shrink-0 rounded-2xl bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center shadow-lg"><i class="fas fa-layer-group text-white text-xl"></i></div> <span>Course Units</span>'
: `<div class="w-14 h-14 flex-shrink-0 rounded-2xl bg-gradient-to-br from-amber-400 to-orange-500 flex items-center justify-center shadow-lg"><i class="fas fa-folder-open text-white text-xl"></i></div> <span class="truncate">${utils.formatName(path)}</span>`}
</h2>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
`;
children.forEach(item => {
const isFolder = item.type === 'tree';
const name = utils.formatName(item.path);
const rawName = item.path.split('/').pop();
const details = isFolder ? utils.getFileDetails('folder') : utils.getFileDetails(item.path);
html += `
<div onclick="app.navigate('${item.path}')"
class="glass-card rounded-2xl p-6 cursor-pointer group flex items-center gap-5 relative overflow-hidden min-h-[110px]" title="${rawName}">
<!-- Subtle Glow Background Animation -->
<div class="absolute -right-8 -top-8 w-28 h-28 ${details.bg} blur-3xl rounded-full opacity-0 group-hover:opacity-60 transition-opacity duration-500"></div>
<div class="flex-shrink-0 w-14 h-14 rounded-2xl flex items-center justify-center border ${details.border} ${details.bg} group-hover:scale-110 transition-transform duration-300 shadow-md relative z-10">
<i class="${details.icon} ${details.color} text-2xl"></i>
</div>
<div class="flex-grow min-w-0 relative z-10">
<h3 class="text-base sm:text-lg font-bold text-slate-200 group-hover:text-white transition-colors truncate">
${name}
</h3>
</div>
<div class="flex-shrink-0 opacity-0 group-hover:opacity-100 transition-all duration-300 transform group-hover:translate-x-1 relative z-10">
<i class="fas fa-chevron-right ${details.color} text-lg"></i>
</div>
</div>
`;
});
html += `</div>`;
elements.container.innerHTML = html;
},
renderFileViewer: async (item) => {
const parentPath = item.path.split('/').slice(0, -1).join('/');
const fileName = item.path.split('/').pop();
const ext = fileName.split('.').pop().toLowerCase();
const rawUrl = `https://raw.githubusercontent.com/${CONFIG.owner}/${CONFIG.repo}/${CONFIG.branch}/${item.path}`;
renderLoading(`Loading File...`);
try {
if (ext === 'pdf') {
const response = await fetch(rawUrl);
if (!response.ok) throw new Error('Failed to fetch PDF');
const blob = await response.blob();
const pdfBlob = new Blob([blob], { type: 'application/pdf' });
const objectUrl = URL.createObjectURL(pdfBlob);
app.renderPDFViewer(fileName, parentPath, objectUrl);
return;
}
if (['png', 'jpg', 'jpeg', 'webp', 'gif', 'svg'].includes(ext)) {
app.renderImageViewer(fileName, parentPath, rawUrl);
return;
}
let content = state.fileCache[item.path];
if (!content) {
const response = await fetch(rawUrl);
if (!response.ok) throw new Error('Failed to fetch file');
content = await response.text();
state.fileCache[item.path] = content;
}
if (ext === 'py') {
app.renderPythonRunner(fileName, parentPath, content);
} else if (ext === 'md') {
app.renderMarkdownViewer(fileName, parentPath, content);
}
} catch (error) {
renderError(`Unable to load file. Network error or file missing.`);
}
},
renderPDFViewer: (fileName, parentPath, objectUrl) => {
const title = utils.formatName(fileName);
elements.container.innerHTML = `
<div class="w-full animate-slide-up">
<div id="viewer-wrapper" class="glass-panel border border-white/10 rounded-3xl overflow-hidden shadow-2xl relative bg-navy-900/90">
<!-- Premium Viewer Toolbar (Back Button Left, Arrow Only) -->
<div class="viewer-toolbar bg-navy-800/95 px-5 py-4 border-b border-white/5 flex flex-row items-center justify-between gap-4 backdrop-blur-xl z-10 relative">
<div class="flex items-center gap-4 w-full min-w-0">
<button onclick="app.navigate('${parentPath}')" title="Go Back" class="flex-shrink-0 w-12 h-12 rounded-xl hover:bg-white/10 flex items-center justify-center text-slate-300 hover:text-white transition-all hover:scale-105 active:scale-95 bg-white/5 border border-white/10 shadow-md group">
<i class="fas fa-arrow-left text-lg group-hover:-translate-x-1 transition-transform"></i>
</button>
<div class="flex items-center gap-3 overflow-hidden">
<div class="flex-shrink-0 w-12 h-12 rounded-xl bg-rose-400/10 border border-rose-400/20 flex items-center justify-center">
<i class="fas fa-file-pdf text-rose-400 text-xl"></i>
</div>
<div class="min-w-0">
<h2 class="text-white font-bold text-lg sm:text-xl leading-tight truncate" title="${fileName}">${title}</h2>
</div>
</div>
</div>
<button onclick="toggleFullscreen()" title="Fullscreen" class="flex-shrink-0 w-12 h-12 bg-white/5 hover:bg-white/10 border border-white/10 text-white rounded-xl transition-all flex items-center justify-center hover:shadow-lg hover:scale-105 active:scale-95">
<i class="fas fa-expand text-lg"></i>
</button>
</div>
<!-- PDF Content Area -->
<div class="viewer-content w-full bg-[#1e1e1e] h-[80vh] flex flex-col relative">
<iframe src="${objectUrl}#toolbar=0&navpanes=0" class="w-full h-full border-none" title="${fileName}"></iframe>
</div>
<!-- Fullscreen Exit Floating Button -->
<button onclick="toggleFullscreen()" title="Exit Fullscreen" class="exit-fullscreen-btn fixed bottom-8 right-8 z-[9999] w-14 h-14 bg-black/70 backdrop-blur-xl border border-white/20 rounded-full text-white hidden items-center justify-center hover:bg-white/20 hover:scale-110 active:scale-95 transition-all shadow-[0_0_30px_rgba(0,0,0,0.8)]">
<i class="fas fa-compress text-2xl"></i>
</button>
</div>
</div>
`;
},
renderImageViewer: (fileName, parentPath, url) => {
const title = utils.formatName(fileName);
elements.container.innerHTML = `
<div class="w-full animate-slide-up">
<div id="viewer-wrapper" class="glass-panel border border-white/10 rounded-3xl overflow-hidden shadow-2xl relative bg-navy-900/90">
<!-- Viewer Toolbar -->
<div class="viewer-toolbar bg-navy-800/95 px-5 py-4 border-b border-white/5 flex flex-row items-center justify-between gap-4 backdrop-blur-xl z-10 relative">
<div class="flex items-center gap-4 w-full min-w-0">
<button onclick="app.navigate('${parentPath}')" title="Go Back" class="flex-shrink-0 w-12 h-12 rounded-xl hover:bg-white/10 flex items-center justify-center text-slate-300 hover:text-white transition-all hover:scale-105 active:scale-95 bg-white/5 border border-white/10 shadow-md group">
<i class="fas fa-arrow-left text-lg group-hover:-translate-x-1 transition-transform"></i>
</button>
<div class="flex items-center gap-3 overflow-hidden">
<div class="flex-shrink-0 w-12 h-12 rounded-xl bg-purple-400/10 border border-purple-400/20 flex items-center justify-center">
<i class="fas fa-image text-purple-400 text-xl"></i>
</div>
<div class="min-w-0">
<h2 class="text-white font-bold text-lg sm:text-xl leading-tight truncate" title="${fileName}">${title}</h2>
</div>
</div>
</div>
<button onclick="toggleFullscreen()" title="Fullscreen" class="flex-shrink-0 w-12 h-12 bg-white/5 hover:bg-white/10 border border-white/10 text-white rounded-xl transition-all flex items-center justify-center hover:shadow-lg hover:scale-105 active:scale-95">
<i class="fas fa-expand text-lg"></i>
</button>
</div>
<!-- Image Content Area -->
<div class="viewer-content w-full bg-[#03050a] min-h-[65vh] flex items-center justify-center p-6 overflow-auto">
<img src="${url}" class="max-w-full max-h-[80vh] object-contain rounded-2xl shadow-2xl border border-white/5" alt="${fileName}">
</div>
<!-- Fullscreen Exit Floating Button -->
<button onclick="toggleFullscreen()" title="Exit Fullscreen" class="exit-fullscreen-btn fixed bottom-8 right-8 z-[9999] w-14 h-14 bg-black/70 backdrop-blur-xl border border-white/20 rounded-full text-white hidden items-center justify-center hover:bg-white/20 hover:scale-110 active:scale-95 transition-all shadow-[0_0_30px_rgba(0,0,0,0.8)]">
<i class="fas fa-compress text-2xl"></i>
</button>
</div>
</div>
`;
},
renderPythonRunner: (fileName, parentPath, content) => {
const safeContent = content.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
const rawCodeBase64 = btoa(unescape(encodeURIComponent(content)));
elements.container.innerHTML = `
<div class="w-full animate-slide-up">
<div class="glass-panel border border-white/10 rounded-3xl overflow-hidden shadow-2xl flex flex-col relative bg-navy-900/90">
<!-- Code Viewer Toolbar (No Fullscreen) -->
<div class="bg-navy-800/95 px-5 py-4 border-b border-white/5 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-5 backdrop-blur-xl z-10 relative">
<div class="flex items-center gap-4 w-full sm:w-auto min-w-0">
<button onclick="app.navigate('${parentPath}')" title="Go Back" class="flex-shrink-0 w-12 h-12 rounded-xl hover:bg-white/10 flex items-center justify-center text-slate-300 hover:text-white transition-all hover:scale-105 active:scale-95 bg-white/5 border border-white/10 shadow-md group">
<i class="fas fa-arrow-left text-lg group-hover:-translate-x-1 transition-transform"></i>
</button>
<div class="flex items-center gap-3 overflow-hidden">
<div class="flex-shrink-0 w-12 h-12 rounded-xl bg-accent-400/10 border border-accent-400/20 flex items-center justify-center">
<i class="fab fa-python text-accent-400 text-2xl"></i>
</div>
<div class="min-w-0">
<h2 class="text-white font-bold text-lg sm:text-xl leading-tight tracking-wide truncate" title="${fileName}">${fileName}</h2>
</div>
</div>
</div>
<div class="flex items-center gap-3 w-full sm:w-auto">
<button onclick="app.copyCode()" id="copyBtn" class="flex-1 sm:flex-none px-5 py-3 bg-white/5 hover:bg-white/10 border border-white/10 text-white rounded-xl transition-all text-sm font-bold flex items-center justify-center gap-2 group hover:scale-105 active:scale-95">
<i class="fas fa-copy text-slate-400 group-hover:text-white transition-colors"></i> <span>Copy</span>
</button>
<button onclick="runPythonProgram(decodeURIComponent(escape(atob('${rawCodeBase64}'))))" id="runBtn" class="flex-1 sm:flex-none px-8 py-3 bg-gradient-to-r from-accent-500 to-accent-600 hover:from-accent-400 hover:to-accent-500 shadow-lg shadow-accent-500/30 text-white rounded-xl transition-all text-sm font-bold flex items-center justify-center gap-2 hover:scale-105 active:scale-95">
<i class="fas fa-play"></i> Run Code
</button>
</div>
</div>
<!-- Viewer Content (Editor + Terminal) -->
<div class="flex flex-col flex-grow">
<div class="relative bg-[#0d1117] w-full overflow-hidden border-b border-white/5 flex-grow">
<pre class="line-numbers !m-0 !rounded-none !border-0 text-sm sm:text-base max-h-[60vh] custom-scrollbar overflow-y-auto"><code class="language-python" id="codeBlock">${safeContent}</code></pre>
</div>
<div class="bg-navy-950 flex flex-col flex-shrink-0">
<div class="flex items-center justify-between px-5 py-3 bg-[#080b12] border-b border-white/5">
<span class="text-xs sm:text-sm font-bold text-slate-400 uppercase tracking-widest flex items-center gap-2">
<i class="fas fa-terminal"></i> Terminal Output
</span>
<button onclick="clearPythonOutput()" class="text-xs sm:text-sm text-slate-500 hover:text-white transition-colors py-1.5 px-3 rounded-lg hover:bg-white/5 border border-transparent hover:border-white/10">
<i class="fas fa-eraser mr-1.5"></i> Clear
</button>
</div>
<div class="p-5 h-[250px] overflow-y-auto custom-scrollbar bg-[#03050a]">
<pre id="py-output" class="terminal-output text-sm sm:text-base leading-relaxed">Ready. Click 'Run Code' to execute.\n</pre>
</div>
</div>
</div>
</div>
</div>
`;
Prism.highlightAll();
},
renderMarkdownViewer: (fileName, parentPath, content) => {
marked.setOptions({
breaks: true, gfm: true,
highlight: (code, lang) => Prism.languages[lang] ? Prism.highlight(code, Prism.languages[lang], lang) : code
});
const htmlContent = marked.parse(content);
const title = utils.formatName(fileName);
elements.container.innerHTML = `
<div class="w-full animate-slide-up">
<div id="viewer-wrapper" class="glass-panel border border-white/10 rounded-3xl overflow-hidden shadow-2xl relative bg-navy-900/90">
<!-- Notes Viewer Toolbar -->
<div class="viewer-toolbar bg-navy-800/95 px-5 py-4 border-b border-white/5 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-5 backdrop-blur-xl z-10 relative">
<div class="flex items-center gap-4 w-full min-w-0">
<!-- BACK BUTTON: Extreme Left, Arrow Only -->
<button onclick="app.navigate('${parentPath}')" title="Go Back" class="flex-shrink-0 w-12 h-12 rounded-xl hover:bg-white/10 flex items-center justify-center text-slate-300 hover:text-white transition-all hover:scale-105 active:scale-95 bg-white/5 border border-white/10 shadow-md group">
<i class="fas fa-arrow-left text-lg group-hover:-translate-x-1 transition-transform"></i>
</button>
<div class="flex items-center gap-3 overflow-hidden">
<div class="flex-shrink-0 w-12 h-12 rounded-xl bg-emerald-400/10 border border-emerald-400/20 flex items-center justify-center">
<i class="fas fa-file-alt text-emerald-400 text-xl"></i>
</div>
<div class="min-w-0">
<h2 class="text-white font-bold text-lg sm:text-xl leading-tight tracking-wide truncate" title="${fileName}">${title}</h2>
</div>
</div>
</div>
<div class="flex items-center gap-3 flex-shrink-0">
<button onclick="toggleFullscreen()" title="Fullscreen" class="w-12 h-12 bg-white/5 hover:bg-white/10 border border-white/10 text-white rounded-xl transition-all flex items-center justify-center hover:shadow-lg hover:scale-105 active:scale-95">
<i class="fas fa-expand text-lg"></i>
</button>
<button onclick="app.downloadPDF('${title}')" id="pdfBtn" class="px-5 py-3 bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-400 hover:to-teal-500 shadow-lg shadow-emerald-500/30 text-white rounded-xl transition-all text-sm font-bold flex items-center justify-center gap-2 hover:scale-105 active:scale-95">
<i class="fas fa-download"></i> <span class="hidden sm:inline">Download</span>
</button>
</div>
</div>
<!-- Note Content Area - SPACING ENHANCED -->
<div class="viewer-content overflow-y-auto bg-[#03050a] p-6 sm:p-10 md:p-16">
<div id="notes-export-area" class="max-w-5xl mx-auto bg-[#0a0f1c] rounded-3xl p-8 sm:p-14 md:p-20 border border-white/10 shadow-[0_20px_50px_rgba(0,0,0,0.5)]">
<article class="prose prose-invert prose-premium w-full max-w-none">
${htmlContent}
</article>
</div>
</div>
<!-- Fullscreen Exit Floating Button -->
<button onclick="toggleFullscreen()" title="Exit Fullscreen" class="exit-fullscreen-btn fixed bottom-8 right-8 z-[9999] w-14 h-14 bg-black/70 backdrop-blur-xl border border-white/20 rounded-full text-white hidden items-center justify-center hover:bg-white/20 hover:scale-110 active:scale-95 transition-all shadow-[0_0_30px_rgba(0,0,0,0.8)]">
<i class="fas fa-compress text-2xl"></i>
</button>
</div>
</div>
`;
},
copyCode: () => {
const code = document.getElementById('codeBlock').textContent;
const btn = document.getElementById('copyBtn');
const span = btn.querySelector('span');
const icon = btn.querySelector('i');
const successUI = () => {
span.textContent = 'Copied!';
icon.className = 'fas fa-check text-emerald-400';
btn.classList.add('border-emerald-500/50', 'bg-emerald-500/10');
setTimeout(() => {
span.textContent = 'Copy';
icon.className = 'fas fa-copy text-slate-400 group-hover:text-white transition-colors';
btn.classList.remove('border-emerald-500/50', 'bg-emerald-500/10');
}, 2000);
};
navigator.clipboard.writeText(code).then(successUI).catch(() => {
const textarea = document.createElement('textarea');
textarea.value = code; document.body.appendChild(textarea);
textarea.select(); document.execCommand('copy');
document.body.removeChild(textarea); successUI();
});
},
downloadPDF: (title) => {
const btn = document.getElementById('pdfBtn');
const originalHtml = btn.innerHTML;
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Wait...';
btn.disabled = true;
const element = document.getElementById('notes-export-area');
const opt = {
margin: [10, 5, 10, 5],
filename: `${title.replace(/[^a-z0-9]/gi, '_').toLowerCase()}_notes.pdf`,
image: { type: 'jpeg', quality: 1.0 },
html2canvas: {
scale: 2,
useCORS: true,
backgroundColor: '#0a0f1c', // Matches container background
scrollY: 0
},
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
};
html2pdf().set(opt).from(element).save().then(() => {
btn.innerHTML = originalHtml;
btn.disabled = false;
}).catch(err => {
console.error("PDF Gen Error:", err);
alert("Error generating PDF.");
btn.innerHTML = originalHtml;
btn.disabled = false;
});
},
handleSearch: (query) => {
if (query.trim().length < 2) {
elements.searchResults.classList.add('hidden');
return;
}
const lowercaseQuery = query.toLowerCase();
const results = state.fullTree.filter(item => {
const formattedName = utils.formatName(item.path).toLowerCase();
return formattedName.includes(lowercaseQuery) || item.path.toLowerCase().includes(lowercaseQuery);
}).slice(0, 8);
if (results.length === 0) {
elements.searchResults.innerHTML = `<div class="p-6 text-center text-slate-400 font-medium">No material found</div>`;
} else {
let html = '<ul class="py-2">';
results.forEach(item => {
const isFolder = item.type === 'tree';
const details = isFolder ? utils.getFileDetails('folder') : utils.getFileDetails(item.path);
const parts = item.path.split('/');
const rawName = parts.pop();
const name = utils.formatName(rawName);
const parent = parts.join(' / ').replace(/[-_]/g, ' ');
html += `
<li>
<button onclick="app.navigate('${item.path}')" class="w-full text-left px-5 py-4 hover:bg-white/5 transition flex items-center gap-4 focus:outline-none focus:bg-white/10 group active:bg-white/10" title="${rawName}">
<div class="w-10 h-10 rounded-xl ${details.bg} border ${details.border} flex flex-shrink-0 items-center justify-center">
<i class="${details.icon} ${details.color} text-lg"></i>
</div>
<div class="overflow-hidden">
<div class="text-slate-200 font-bold text-base group-hover:text-white transition-colors truncate">${name}</div>
${parent ? `<div class="text-xs text-slate-500 mt-1 truncate">${parent}</div>` : ''}
</div>
</button>
</li>
`;
});
html += '</ul>';
elements.searchResults.innerHTML = html;
}
elements.searchResults.classList.remove('hidden');
}
};
// --- UI Feedback Components ---
function renderLoading(message) {
elements.container.innerHTML = `
<div class="flex flex-col items-center justify-center py-40 animate-pop-in">
<div class="premium-loader mb-8"></div>
<p class="text-accent-400 font-bold tracking-widest uppercase animate-pulse text-center px-4 text-sm">${message}</p>
</div>
`;
}
function renderError(message) {
elements.container.innerHTML = `
<div class="glass-panel border-red-500/30 rounded-3xl p-10 sm:p-14 text-center max-w-2xl mx-auto mt-16 animate-slide-up relative overflow-hidden shadow-2xl shadow-red-500/10">
<div class="absolute inset-0 bg-red-500/5"></div>
<div class="relative z-10">
<div class="w-16 h-16 bg-red-500/10 rounded-2xl border border-red-500/20 flex items-center justify-center mx-auto mb-6">
<i class="fas fa-exclamation-triangle text-3xl text-red-400 shadow-sm"></i>
</div>
<h3 class="text-2xl font-extrabold text-white mb-3">Connection Error</h3>
<p class="text-slate-400 mb-8 text-base">${message}</p>
<button onclick="initApp()" class="px-8 py-3 bg-white/5 hover:bg-white/10 text-white rounded-xl transition-all text-base font-bold border border-white/10 flex items-center gap-3 mx-auto active:scale-95 hover:shadow-lg">
<i class="fas fa-sync-alt"></i> Retry Connection
</button>
</div>
</div>
`;
}
function renderEmptyFolder() {
elements.container.innerHTML = `
<div class="glass-panel rounded-3xl p-16 sm:p-20 text-center max-w-2xl mx-auto mt-16 border-white/5 animate-slide-up shadow-2xl">
<div class="w-24 h-24 bg-white/5 rounded-2xl flex items-center justify-center mx-auto mb-8 border border-white/10 shadow-inner">
<i class="fas fa-folder-open text-5xl text-slate-600"></i>
</div>
<h3 class="text-3xl font-extrabold text-white mb-3">Empty Directory</h3>
<p class="text-slate-400 text-lg">Nothing to see here right now.</p>
</div>
`;
}
// --- Global Events ---
elements.searchInput.addEventListener('input', (e) => app.handleSearch(e.target.value));
document.addEventListener('click', (e) => {
if (!elements.searchInput.contains(e.target) && !elements.searchResults.contains(e.target)) {
elements.searchResults.classList.add('hidden');
}
});
elements.searchInput.addEventListener('keydown', (e) => {
if (e.key === 'Escape') { elements.searchResults.classList.add('hidden'); elements.searchInput.blur(); }
});
window.addEventListener('DOMContentLoaded', initApp);
</script>
</body>
</html>