Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
2030 lines (1888 loc) · 73.2 KB
/
Copy pathscript.js
File metadata and controls
2030 lines (1888 loc) · 73.2 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
/* =========================================================
Dhellskieee Portfolio | script.js
Lahat ng galaw nandito: boot loader, animated background,
terminal, project network (naka-connect sa GitHub),
contact handshake at mga maliliit na effects.
========================================================= */
(function () {
'use strict';
// Sinasabi sa CSS na gumagana ang JavaScript (para sa reveal animations).
document.documentElement.classList.add('js');
/* ---------- 1. Helpers ---------- */
const $ = (sel, root) => (root || document).querySelector(sel);
const $$ = (sel, root) => Array.from((root || document).querySelectorAll(sel));
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
const lerp = (a, b, t) => a + (b - a) * t;
const rand = (lo, hi) => lo + Math.random() * (hi - lo);
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
const finePointer = window.matchMedia('(pointer: fine)').matches;
function el(tag, className, text) {
const node = document.createElement(tag);
if (className) node.className = className;
if (text !== undefined && text !== null) node.textContent = text;
return node;
}
// Seeded random: pare-pareho ang layout tuwing bubuksan ang page.
function mulberry32(seed) {
let a = seed;
return function () {
a = (a + 0x6d2b79f5) | 0;
let t = Math.imul(a ^ (a >>> 15), 1 | a);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
const DATE_LONG = { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' };
const fmtDate = (iso) => new Date(iso + 'T00:00:00Z').toLocaleDateString('en-US', DATE_LONG);
function flash(node, cls) {
const c = cls || 'is-pinged';
node.classList.remove(c);
void node.offsetWidth; // para mag-restart ang CSS animation
node.classList.add(c);
clearTimeout(node.flashTimer);
node.flashTimer = setTimeout(() => node.classList.remove(c), 850);
}
/* ---------- 2. Colors (galing sa CSS variables ng style.css) ---------- */
const rootStyle = getComputedStyle(document.documentElement);
const token = (name, fallback) => rootStyle.getPropertyValue(name).trim() || fallback;
const COLOR = {
bg: token('--bg', '#030403'),
panel: token('--panel', '#090c0a'),
text: token('--text', '#e8ede4'),
signal: token('--signal', '#c8f560'),
deploy: token('--deploy', '#e8ede4'),
stream: token('--stream-2', '#6fcff6'),
};
function rgba(hex, alpha) {
let h = hex.replace('#', '');
if (h.length === 3) h = h.split('').map((c) => c + c).join('');
const n = parseInt(h, 16);
return 'rgba(' + ((n >> 16) & 255) + ',' + ((n >> 8) & 255) + ',' + (n & 255) + ',' + alpha + ')';
}
/* ---------- 3. Data ---------- */
const GITHUB = 'https://github.com/Dhellss';
const PAGES = 'https://dhellss.github.io/';
let publicRepos = 28; // na-save noong Oct 13, 2026; ina-update ng refreshGitHub() kapag may internet
// Mga folder sa network. anchor = puwesto sa map (0 hanggang 1).
const GROUPS = [
{ id: 'games', label: 'games/', name: 'Games', tag: 'Game Dev', anchor: [0.78, 0.66] },
{ id: 'web', label: 'web-apps/', name: 'Web apps', tag: 'Web Dev', anchor: [0.76, 0.18] },
{ id: 'software', label: 'software/', name: 'Software', tag: 'Software Dev', anchor: [0.24, 0.2] },
{ id: 'designs', label: 'portfolios/', name: 'Portfolio designs', tag: 'Web Dev', anchor: [0.22, 0.72] },
];
// Lahat ng projects. Para magdagdag: kopyahin ang isang item at palitan ang laman.
// repo : pangalan ng repo sa github.com/Dhellss/
// live : link ng GitHub Pages (null kung code lang)
// pushed : huling push (YYYY-MM-DD)
const PROJECTS = [
// Software
{ id: 'linux-system-observatory', group: 'software', title: 'Linux System Observatory', year: '2026', repo: 'linux-system-observatory', live: null, pushed: '2026-10-05', stack: ['Python', 'Qt', 'Linux'],
desc: 'A desktop system monitor for Linux: CPU, GPU, memory, storage, sensors, services and processes in one Qt interface. Runs fully offline, with no telemetry.' },
{ id: 'lifeos', group: 'software', title: 'LifeOS', year: '2026', repo: 'LifeOS', live: null, pushed: '2026-10-05', stack: ['Next.js', 'TypeScript', 'Prisma', 'PostgreSQL'],
desc: 'A personal operating system for tasks, projects, habits, study, fitness, calendar and journalling, with XP, achievements and analytics computed from your own records. Real auth, real database, 253 tests.' },
{ id: 'student-management-system', group: 'software', title: 'Student Management System', year: '2026', repo: 'student-management-system', live: null, pushed: '2026-09-21', stack: ['Python', 'Flask', 'SQLite'],
desc: 'A Flask and SQLite web app for students, subjects, enrollment and grades, including GWA on the Philippine 1.00 to 5.00 scale.' },
// Web apps
{ id: 'sqdhell', group: 'web', title: 'SQDhell', year: '2026', repo: 'SQL-Learning', live: PAGES + 'SQL-Learning/', pushed: '2026-09-21', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'An interactive SQL tutorial you work through in the browser, lesson by lesson.' },
{ id: 'mysql-playground', group: 'web', title: 'MySQL Playground', year: '2026', repo: 'SQL-Practice', live: PAGES + 'SQL-Practice/MYSQL%20WEB/', pushed: '2026-09-22', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'A terminal-themed sandbox for practising MySQL queries without installing a database.' },
{ id: 'notely', group: 'web', title: 'Notely', year: '2026', repo: 'Notely', live: null, pushed: '2026-10-05', stack: ['React', 'Vite', 'JavaScript', 'CSS'],
desc: 'A notes app with a proper design system: pin, tag, archive, search and sort, plus light and dark themes built as two separate palettes. No backend and no accounts; everything lives in your browser.' },
// Games
{ id: 'dash-break', group: 'games', title: 'DASH//BREAK', year: '2026', repo: 'dash-break', live: PAGES + 'dash-break/', pushed: '2026-10-08', stack: ['TypeScript', 'Three.js', 'Vite'],
desc: 'An isometric 3D bullet-hell arena. Four dashes with no cooldown and one attack dash; press them together for eleven combos, up to the ZERO//BREAK ultimate. Seven enemy types, a three-phase boss, and music generated in code.' },
{ id: 'below-100m', group: 'games', title: 'Below 100m', year: '2026', repo: 'Below_100m', live: null, pushed: '2026-10-07', isNew: true, stack: ['HTML', 'CSS', 'JavaScript', 'Web Audio'],
desc: 'A small underwater diving game. Swim down into a blue hole, find treasure and get back up before your air runs out. Sell what you bring up, upgrade your gear and go deeper. Something is waiting at 100 metres.' },
{ id: 'the-last-room', group: 'games', title: 'The Last Room', year: '2026', repo: 'the-last-room', live: PAGES + 'the-last-room/', pushed: '2026-10-05', stack: ['HTML', 'CSS', 'JavaScript'],
desc: "A mystery set in one room. It's always 11:43, and whenever you look away something changes: the photograph, the chair, the street outside. Three endings, decided by what you notice." },
{ id: 'zombie-night', group: 'games', title: 'Zombie Night', year: '2026', repo: 'zombie-night', live: PAGES + 'zombie-night/', pushed: '2026-10-05', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'A top-down zombie survival shooter. Hold a dark intersection against waves of walkers, runners and tanks, then spend your coins on upgrades between waves.' },
{ id: 'tetris', group: 'games', title: 'Tetris', year: '2026', repo: 'tetris', live: PAGES + 'tetris/', pushed: '2026-10-02', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'A modern Tetris with full SRS wall kicks and T-spins, plus an animated guide that teaches how spins actually work.' },
{ id: 'projectbato', group: 'games', title: 'ProjectBato', year: '2026', repo: 'ProjectBato', live: PAGES + 'ProjectBato/', pushed: '2026-09-21', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'An underwater arcade game where you play a crocodile that eats money to survive while dodging harmful obstacles.' },
{ id: 'pulse', group: 'games', title: 'pulse', year: '2026', repo: 'pulse', live: PAGES + 'pulse/', pushed: '2026-09-21', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'Rings collapse toward the centre. Hit each one the moment it crosses the lock ring.' },
{ id: 'keycrack', group: 'games', title: 'keycrack', year: '2026', repo: 'keycrack', live: PAGES + 'keycrack/', pushed: '2026-09-21', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'Every lock holds a key of four different symbols. Guess, read the feedback, and cut down what is left.' },
{ id: 'handshake', group: 'games', title: 'handshake', year: '2026', repo: 'handshake', live: PAGES + 'handshake/', pushed: '2026-09-21', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'A signal flashes across nine nodes. Then the whole board turns a quarter, and you repeat it.' },
{ id: 'inject', group: 'games', title: 'inject', year: '2026', repo: 'inject', live: PAGES + 'inject/', pushed: '2026-09-21', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'Processes are dropping into the kernel. Type a name to kill it before it lands.' },
{ id: 'kernel-route', group: 'games', title: 'kernel-route', year: '2026', repo: 'kernel-route', live: PAGES + 'kernel-route/', pushed: '2026-09-21', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'Every node on the grid is dead except the core. Turn the links until the signal reaches all of them.' },
{ id: 'patrol', group: 'games', title: 'patrol', year: '2026', repo: 'patrol', live: PAGES + 'patrol/', pushed: '2026-09-23', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'Grab every file and reach the stairs. The cameras turn a quarter every time you move.' },
// Portfolio designs
{ id: 'dragon', group: 'designs', title: 'Dragon', year: '2026', repo: 'Dragon', live: PAGES + 'Dragon/', pushed: '2026-09-23', stack: ['HTML', 'CSS', 'JavaScript', 'Three.js'],
desc: 'A one-page portfolio with a 3D dragon guarding a glowing orb, with terminal windows layered on top.' },
{ id: 'os', group: 'designs', title: 'OS', year: '2026', repo: 'OS', live: PAGES + 'OS/', pushed: '2026-09-23', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'A fake desktop OS as a portfolio: icons, draggable windows and a dock instead of a normal page.' },
{ id: 'terminal', group: 'designs', title: 'Terminal', year: '2026', repo: 'Terminal', live: PAGES + 'Terminal/', pushed: '2026-09-23', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'A portfolio you navigate by typing commands into a working terminal.' },
{ id: 'readme', group: 'designs', title: 'Readme', year: '2026', repo: 'Readme', live: PAGES + 'Readme/', pushed: '2026-09-23', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'A quiet, text-first portfolio styled like a project README file.' },
{ id: 'grid', group: 'designs', title: 'Grid', year: '2026', repo: 'Grid', live: PAGES + 'Grid/', pushed: '2026-09-23', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'A dashboard-style portfolio: bordered cells laid out in a grid with a sidebar nav.' },
{ id: 'prompt', group: 'designs', title: 'Prompt', year: '2026', repo: 'Prompt', live: PAGES + 'Prompt/', pushed: '2026-09-23', stack: ['HTML', 'CSS', 'JavaScript'],
desc: 'A minimal command-prompt portfolio that types itself out, navigated with keyboard shortcuts.' },
];
PROJECTS.forEach((p) => {
p.img = 'assets/projects/' + p.id + '.webp';
});
const groupOf = (p) => GROUPS.find((g) => g.id === p.group);
const latestProject = () => PROJECTS.slice().sort((a, b) => (a.pushed < b.pushed ? 1 : a.pushed > b.pushed ? -1 : 0))[0];
/* ---------- 4. Icons ---------- */
const ICONS = {
branch: '<circle cx="6" cy="5" r="2.2"/><circle cx="6" cy="19" r="2.2"/><circle cx="18" cy="8" r="2.2"/><path d="M6 7.2v9.6M18 10.2c0 4-4 4.2-9.8 6.4"/>',
folder: '<path d="M3.5 7.5a2 2 0 0 1 2-2h4l2 2h7a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2z"/>',
play: '<path d="M8 5.5l10 6.5-10 6.5z"/>',
code: '<path d="M8.5 7.5L4 12l4.5 4.5M15.5 7.5L20 12l-4.5 4.5"/>',
ext: '<path d="M14 4h6v6M20 4l-9 9M18 13.5V19a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5.5"/>',
left: '<path d="M14.5 6l-6 6 6 6"/>',
right: '<path d="M9.5 6l6 6-6 6"/>',
};
const svg = (name) =>
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">' +
ICONS[name] +
'</svg>';
function linkBtn(href, label, variant, iconName) {
const a = el('a', 'btn btn--sm btn--' + variant);
a.href = href;
a.target = '_blank';
a.rel = 'noopener';
a.innerHTML = svg(iconName);
a.append(document.createTextNode(label));
return a;
}
/* ---------- 5. Background: particle network + light stream ---------- */
const bg = (function () {
const canvas = $('#bg');
const ctx = canvas.getContext('2d');
const spot = $('#spot');
const rnd = mulberry32(42);
const mouse = { x: -9999, y: -9999, nx: 0, ny: 0, sx: -9999, sy: -9999, on: false };
const packets = [];
let W = 0;
let H = 0;
let lastW = 0;
let small = false;
let pts = [];
let strong = [];
let lines = 32;
let seg = 110;
const seeds = Array.from({ length: 40 }, (_, i) => {
const x = Math.sin(i * 12.9898) * 43758.5453;
return x - Math.floor(x);
});
function resize() {
const dpr = Math.min(window.devicePixelRatio || 1, 1.25);
W = window.innerWidth;
H = window.innerHeight;
canvas.width = Math.round(W * dpr);
canvas.height = Math.round(H * dpr);
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
small = W < 700;
lines = small ? 18 : 32;
seg = small ? 60 : 110;
// Bagong points lang kapag nagbago ang lapad (iwas "talon" sa mobile scroll).
if (Math.abs(W - lastW) > 40 || !pts.length) {
lastW = W;
const n = small ? 44 : Math.round(clamp((W * H) / 14500, 70, 140));
pts = Array.from({ length: n }, () => ({
x: rnd() * W,
y: rnd() * (H + 120) - 60,
z: 0.3 + rnd() * 0.7,
vx: (rnd() - 0.5) * 0.22,
vy: (rnd() - 0.5) * 0.22,
lime: rnd() < 0.24,
ph: rnd() * 6.28,
sx: 0,
sy: 0,
}));
}
}
window.addEventListener('pointermove', (e) => {
if (e.pointerType !== 'mouse') return;
mouse.x = e.clientX;
mouse.y = e.clientY;
mouse.nx = e.clientX / W - 0.5;
mouse.ny = e.clientY / H - 0.5;
if (!mouse.on) {
mouse.sx = mouse.x;
mouse.sy = mouse.y;
}
mouse.on = true;
}, { passive: true });
window.addEventListener('mouseout', (e) => {
if (!e.relatedTarget) mouse.on = false;
});
// Light stream: isang ribbon ng ilaw na tumatawid sa screen.
const centre = (t, time, s) =>
H * (0.9 - 0.66 * t) +
H * 0.09 * Math.sin(t * Math.PI * 2 + time * 0.00014 + s * 4.2) +
mouse.ny * H * 0.08 * Math.sin(Math.PI * t);
const spread = (t, time, s) =>
H * 0.13 * Math.pow(Math.sin(Math.PI * t), 1.2) * Math.cos(t * 3.3 - time * 0.00028 + s * 3.4);
function drawStream(time, s) {
ctx.globalCompositeOperation = 'lighter';
const grad = ctx.createLinearGradient(0, H, W, 0);
grad.addColorStop(0, rgba(COLOR.signal, 0));
grad.addColorStop(0.28, rgba(COLOR.signal, 1));
grad.addColorStop(0.62, rgba(COLOR.stream, 1));
grad.addColorStop(1, rgba(COLOR.text, 0));
ctx.strokeStyle = grad;
ctx.lineCap = 'round';
[[56, 0.04], [20, 0.06]].forEach((pass) => {
ctx.globalAlpha = pass[1];
ctx.lineWidth = pass[0];
ctx.beginPath();
for (let k = 0; k <= seg; k++) {
const t = k / seg;
const x = -0.1 * W + t * 1.2 * W;
const y = centre(t, time, s);
if (k) ctx.lineTo(x, y);
else ctx.moveTo(x, y);
}
ctx.stroke();
});
ctx.lineWidth = 1;
for (let i = 0; i < lines; i++) {
const u = i / (lines - 1) - 0.5;
ctx.globalAlpha = 0.09 + 0.26 * seeds[i];
ctx.beginPath();
for (let k = 0; k <= seg; k++) {
const t = k / seg;
const x = -0.1 * W + t * 1.2 * W;
const y = centre(t, time, s) + u * 2 * spread(t, time, s) + Math.sin(t * 9 + i * 0.8 + time * 0.0007) * 2;
if (k) ctx.lineTo(x, y);
else ctx.moveTo(x, y);
}
ctx.stroke();
}
ctx.globalAlpha = 1;
ctx.globalCompositeOperation = 'source-over';
}
function draw(time, dt, scrollY, scrollP) {
ctx.clearRect(0, 0, W, H);
drawStream(time, scrollP);
// Points: gumagalaw, may depth (z), at may parallax kapag nag-scroll.
const span = H + 120;
const move = dt * 60;
for (const p of pts) {
p.x += p.vx * move;
p.y += p.vy * move;
if (p.x < -40) p.x += W + 80;
else if (p.x > W + 40) p.x -= W + 80;
p.sx = p.x + mouse.nx * 24 * p.z;
let sy = (p.y - scrollY * 0.28 * p.z) % span;
if (sy < 0) sy += span;
p.sy = sy - 60 + mouse.ny * 16 * p.z;
}
// Mga linya sa pagitan ng magkakalapit na points
strong = [];
const maxD = small ? 110 : 145;
ctx.lineWidth = 1;
for (let i = 0; i < pts.length; i++) {
const a = pts[i];
for (let j = i + 1; j < pts.length; j++) {
const b = pts[j];
const dx = a.sx - b.sx;
const dy = a.sy - b.sy;
const lim = maxD * (a.z + b.z) * 0.5;
const d2 = dx * dx + dy * dy;
if (d2 > lim * lim) continue;
const k = 1 - Math.sqrt(d2) / lim;
const alpha = k * 0.3 * Math.min(a.z, b.z);
ctx.strokeStyle = a.lime || b.lime ? rgba(COLOR.signal, alpha * 1.2) : rgba(COLOR.text, alpha * 0.55);
ctx.beginPath();
ctx.moveTo(a.sx, a.sy);
ctx.lineTo(b.sx, b.sy);
ctx.stroke();
if (k > 0.3) strong.push(i, j);
}
}
// Ang mouse ay nagiging isang node din: kumokonekta sa mga malapit na points.
if (mouse.on) {
for (const p of pts) {
const dx = p.sx - mouse.x;
const dy = p.sy - mouse.y;
const d = Math.sqrt(dx * dx + dy * dy);
if (d > 190) continue;
const k = 1 - d / 190;
ctx.strokeStyle = rgba(COLOR.signal, k * 0.55);
ctx.beginPath();
ctx.moveTo(mouse.x, mouse.y);
ctx.lineTo(p.sx, p.sy);
ctx.stroke();
p.near = k;
}
}
// Packets na tumatakbo sa mga linya
if (strong.length && Math.random() < dt * (small ? 4 : 9)) {
const k = (Math.floor(Math.random() * (strong.length / 2)) * 2);
const flip = Math.random() < 0.5;
packets.push({ a: strong[flip ? k : k + 1], b: strong[flip ? k + 1 : k], t: 0, v: rand(0.7, 1.4) });
}
ctx.globalCompositeOperation = 'lighter';
for (let i = packets.length - 1; i >= 0; i--) {
const pk = packets[i];
pk.t += pk.v * dt;
if (pk.t >= 1) {
packets.splice(i, 1);
continue;
}
const a = pts[pk.a];
const b = pts[pk.b];
if (!a || !b) {
packets.splice(i, 1);
continue;
}
const x = lerp(a.sx, b.sx, pk.t);
const y = lerp(a.sy, b.sy, pk.t);
ctx.fillStyle = rgba(COLOR.signal, 0.16);
ctx.beginPath();
ctx.arc(x, y, 5, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = COLOR.signal;
ctx.beginPath();
ctx.arc(x, y, 1.5, 0, Math.PI * 2);
ctx.fill();
}
ctx.globalCompositeOperation = 'source-over';
// Points
for (const p of pts) {
const tw = 0.5 + 0.5 * Math.sin(time * 0.002 + p.ph);
const near = mouse.on ? p.near || 0 : 0;
const alpha = clamp(0.16 + p.z * 0.5 + tw * 0.15 + near * 0.5, 0, 1);
ctx.fillStyle = p.lime || near > 0.2 ? rgba(COLOR.signal, alpha) : rgba(COLOR.text, alpha * 0.8);
ctx.beginPath();
ctx.arc(p.sx, p.sy, 0.6 + p.z * 1.5 + near * 1.2, 0, Math.PI * 2);
ctx.fill();
p.near = 0;
}
}
function spotlight() {
if (!mouse.on) {
if (mouse.sx !== -9999) {
mouse.sx = -9999;
spot.style.setProperty('--mx', '-999px');
spot.style.setProperty('--my', '-999px');
}
return;
}
mouse.sx = lerp(mouse.sx, mouse.x, 0.22);
mouse.sy = lerp(mouse.sy, mouse.y, 0.22);
spot.style.setProperty('--mx', mouse.sx.toFixed(1) + 'px');
spot.style.setProperty('--my', mouse.sy.toFixed(1) + 'px');
}
return { resize, draw, spotlight, mouse };
})();
/* ---------- 6. Text scramble ---------- */
const GLYPHS = '01<>/_#$%&*+=?';
function scramble(node, duration) {
const final = node.dataset.text || node.textContent;
node.dataset.text = final;
if (reduceMotion || node.scrambling) return;
node.scrambling = true;
const t0 = performance.now();
const dur = duration || 750;
node.setAttribute('aria-label', final);
function frame(now) {
const k = clamp((now - t0) / dur, 0, 1);
const shown = Math.floor(k * final.length);
let out = '';
for (let i = 0; i < final.length; i++) {
const c = final[i];
out += i < shown || c === ' ' ? c : GLYPHS[(Math.random() * GLYPHS.length) | 0];
}
node.textContent = out;
if (k < 1) {
requestAnimationFrame(frame);
} else {
node.textContent = final;
node.removeAttribute('aria-label');
node.scrambling = false;
}
}
requestAnimationFrame(frame);
}
/* ---------- 7. Hero terminal ---------- */
const termBody = $('#termBody');
const caret = el('span', 'caret');
let heroVisible = true;
const TERM_SCRIPT = () => [
{ cmd: 'whoami', out: [['Dhellmar Feliciano Mahilum', '']] },
{ cmd: 'cat role.txt', out: [['"Computer Science Student" @ University of the Cordilleras', 'str']] },
{ cmd: 'ls interests/', out: [['vibe-coding/ programming/ ethical-hacking/', 'dir'], ['cyber-security/ game-dev/ web-dev/', 'dir'], ['software-dev/ ui-ux/ system-dev/ ai/', 'dir']] },
{ cmd: 'git remote -v', out: [['origin github.com/Dhellss (' + publicRepos + ' public repos)', 'ok']] },
];
const TERM_LOOP = [
['sudo make coffee', '[ok] brewing... done', 'ok'],
['npm run build', '[ok] built in 0.4s', 'ok'],
['ping dhellmar', "reply: let's talk!", ''],
['git commit -m "it works"', '[ok] 1 file changed', 'ok'],
['cat motto.txt', '"I love the creation"', 'str'],
['ls ~/projects | wc -l', String(PROJECTS.length), ''],
];
function termLine() {
const line = el('div', 't-line is-new');
termBody.append(line);
// Tanggalin ang pinakaunang linya kapag puno na ang terminal.
while (termBody.scrollHeight > termBody.clientHeight + 2 && termBody.children.length > 1) {
termBody.firstElementChild.remove();
}
return line;
}
function promptLine() {
const line = termLine();
line.append(el('span', 't-user', 'dhell@github'), el('span', 't-path', ':~$ '));
return line;
}
async function typeCommand(cmd) {
const line = promptLine();
const cmdEl = el('span', 't-cmd', '');
line.append(cmdEl, caret);
if (reduceMotion) {
cmdEl.textContent = cmd;
return;
}
for (const ch of cmd) {
cmdEl.textContent += ch;
await wait(rand(26, 66));
}
await wait(170);
}
function printOut(text, kind) {
const line = termLine();
line.append(el('span', 't-out' + (kind ? ' is-' + kind : ''), text));
}
async function runTerminal() {
for (const step of TERM_SCRIPT()) {
await typeCommand(step.cmd);
step.out.forEach((o) => printOut(o[0], o[1]));
await wait(reduceMotion ? 0 : 380);
}
let idle = promptLine();
idle.append(caret);
if (reduceMotion) return;
let i = 0;
for (;;) {
await wait(4200);
if (!heroVisible || document.hidden) continue;
idle.remove();
const item = TERM_LOOP[i++ % TERM_LOOP.length];
await typeCommand(item[0]);
printOut(item[1], item[2]);
idle = promptLine();
idle.append(caret);
}
}
/* ---------- 8. Project network (lahat naka-connect sa GitHub) ---------- */
const net = (function () {
const wrap = $('#net');
const stage = $('.net__stage', wrap);
const map = $('#netMap');
const canvas = $('#netCanvas');
const ctx = canvas.getContext('2d');
const inspector = $('#inspector');
const list = $('#netList');
const backdrop = $('#sheetBackdrop');
const filtersEl = $('#filters');
const pauseBtn = $('#toolPause');
const sheetMQ = window.matchMedia('(max-width: 760px)');
const S = {
W: 0,
H: 0,
scale: 1,
mode: 'graph',
filter: 'all',
active: null,
selected: null,
paused: false,
visible: false,
entered: false,
ready: false,
view: 'map',
drag: null,
tween: null,
lastWidth: 0,
sheetOpen: false,
returnFocus: null,
};
const nodes = [];
const edges = [];
const packets = [];
let hotEdges = new Set();
let selEdges = new Set();
/* --- Build nodes and edges --- */
function makeNode(type, data) {
const n = { type, data, id: type === 'hub' ? 'hub' : data.id, x: 0, y: 0, vx: 0, vy: 0, w: 0, h: 0, ex: 0, ey: 0, children: [], dim: false, hidden: false, dragging: false };
const b = el('button', 'gnode gnode--' + type);
b.type = 'button';
if (type === 'hub') {
b.innerHTML = '<span class="gnode__icon">' + svg('branch') + '</span>';
const text = el('span', 'gnode__hubtext');
n.subEl = el('span', 'gnode__hubsub', publicRepos + ' public repos');
text.append(el('span', 'gnode__hubname', 'github.com/Dhellss'), n.subEl);
b.append(text);
b.setAttribute('aria-label', 'GitHub profile github.com/Dhellss. Show details');
} else if (type === 'group') {
b.innerHTML = svg('folder');
const count = PROJECTS.filter((p) => p.group === data.id).length;
b.append(el('span', 'gnode__label', data.label), el('span', 'gnode__count', String(count)));
b.setAttribute('aria-label', 'Show only ' + data.name + ', ' + count + ' projects');
} else {
b.append(el('i', 'ldot' + (data.live ? ' is-live' : '')), el('span', 'gnode__label', data.title));
if (data.isNew) b.append(el('span', 'gnode__new', 'new'));
b.setAttribute('aria-label', data.title + ', ' + groupOf(data).name + '. Show details');
}
n.el = b;
map.append(b);
nodes.push(n);
attachPointer(n);
return n;
}
const hub = makeNode('hub', null);
const groupNodes = {};
GROUPS.forEach((g) => {
groupNodes[g.id] = makeNode('group', g);
});
const projNodes = PROJECTS.map((p) => makeNode('project', p));
GROUPS.forEach((g) => {
const e = { a: hub, b: groupNodes[g.id], kind: 'trunk', bend: 1 };
edges.push(e);
groupNodes[g.id].edge = e;
});
projNodes.forEach((pn, i) => {
const gn = groupNodes[pn.data.group];
pn.parent = gn;
gn.children.push(pn);
const e = { a: gn, b: pn, kind: 'branch', bend: i % 2 ? 1 : -1 };
edges.push(e);
pn.edge = e;
});
/* --- Pointer: hover, drag, click --- */
function attachPointer(n) {
const b = n.el;
b.addEventListener('pointerenter', () => setActive(n));
b.addEventListener('pointerleave', () => {
if (S.active === n) setActive(null);
});
b.addEventListener('focus', () => setActive(n));
b.addEventListener('blur', () => {
if (S.active === n) setActive(null);
});
b.addEventListener('pointerdown', (e) => {
if (S.mode !== 'graph' || e.button !== 0 || S.tween) return;
const r = map.getBoundingClientRect();
S.drag = { n, id: e.pointerId, sx: e.clientX, sy: e.clientY, ox: n.x - (e.clientX - r.left), oy: n.y - (e.clientY - r.top), moved: false, lx: e.clientX, ly: e.clientY, vx: 0, vy: 0 };
try {
b.setPointerCapture(e.pointerId);
} catch (err) {
/* ignore */
}
});
b.addEventListener('pointermove', (e) => {
const d = S.drag;
if (!d || d.n !== n || d.id !== e.pointerId) return;
if (!d.moved && Math.hypot(e.clientX - d.sx, e.clientY - d.sy) > 5) {
d.moved = true;
n.dragging = true;
b.classList.add('is-dragging');
}
if (d.moved) {
const r = map.getBoundingClientRect();
n.x = clamp(e.clientX - r.left + d.ox, n.w / 2, S.W - n.w / 2);
n.y = clamp(e.clientY - r.top + d.oy, n.h / 2, S.H - n.h / 2);
d.vx = e.clientX - d.lx;
d.vy = e.clientY - d.ly;
d.lx = e.clientX;
d.ly = e.clientY;
}
});
const end = () => {
const d = S.drag;
if (!d || d.n !== n) return;
S.drag = null;
if (d.moved) {
n.dragging = false;
b.classList.remove('is-dragging');
// Ihagis: may konting bilis pagkabitaw
n.vx = clamp(d.vx, -30, 30) * 0.6;
n.vy = clamp(d.vy, -30, 30) * 0.6;
n.justDragged = true;
setTimeout(() => {
n.justDragged = false;
}, 0);
}
};
b.addEventListener('pointerup', end);
b.addEventListener('pointercancel', end);
b.addEventListener('click', (e) => {
if (n.justDragged) {
e.preventDefault();
return;
}
activate(n);
});
}
function chainEdges(n) {
const s = new Set();
if (!n) return s;
if (n.type === 'project') {
s.add(n.edge);
s.add(n.parent.edge);
} else if (n.type === 'group') {
s.add(n.edge);
n.children.forEach((c) => s.add(c.edge));
} else {
edges.forEach((e) => s.add(e));
}
return s;
}
function chainNodes(n) {
if (!n) return [];
if (n.type === 'project') return [n.parent, hub];
if (n.type === 'group') return [hub].concat(n.children);
return [];
}
function setActive(n) {
chainNodes(S.active).forEach((c) => c.el.classList.remove('is-hot'));
S.active = n;
hotEdges = chainEdges(n);
chainNodes(n).forEach((c) => c.el.classList.add('is-hot'));
}
function activate(n) {
if (n.type === 'group') {
setFilter(S.filter === n.id ? 'all' : n.id);
return;
}
select(n, { open: true, burst: true });
}
/* --- Selection + inspector --- */
function select(n, opts) {
const o = opts || {};
if (S.selected) S.selected.el.classList.remove('is-selected');
S.selected = n;
n.el.classList.add('is-selected');
selEdges = n.type === 'project' ? chainEdges(n) : new Set();
renderInspector(n, !o.quiet);
if (o.burst && n.type === 'project' && !reduceMotion) {
sendPush(n, true);
if (n.data.live) setTimeout(() => sendDeploy(n, true), 260);
}
if (o.open && sheetMQ.matches) openSheet(n.el);
}
function visibleProjects() {
return projNodes.filter((p) => !p.dim);
}
function step(dir) {
const pool = visibleProjects();
if (!pool.length) return;
const idx = S.selected && S.selected.type === 'project' ? pool.indexOf(S.selected) : -1;
const next = pool[(idx + dir + pool.length) % pool.length];
select(next, { burst: true });
}
function renderInspector(n, animate) {
inspector.replaceChildren();
const close = el('button', 'insp__close btn btn--ghost btn--sm', 'Close');
close.type = 'button';
close.addEventListener('click', closeSheet);
inspector.append(close);
const media = el('div', 'insp__media' + (animate ? ' is-new' : ''));
const meta = el('p', 'insp__meta mono');
const git = el('dl', 'insp__git mono');
const actions = el('div', 'insp__actions');
let title;
let desc;
let chips = null;
if (n.type === 'hub') {
const art = el('div', 'insp__hub');
art.innerHTML = svg('branch');
media.append(art);
meta.append(el('span', 'tag', 'GitHub'), el('span', null, 'profile'));
title = el('h3', 'insp__title', 'github.com/Dhellss');
desc = el('p', 'insp__desc', 'Where every project on this page lives: browser games, web apps, portfolio designs and desktop software. ' + publicRepos + ' public repositories so far.');
const latest = latestProject();
[['user', 'Dhellss'], ['public repos', String(publicRepos)], ['latest push', latest.repo + ', ' + fmtDate(latest.pushed)], ['on this page', PROJECTS.length + ' projects']].forEach((row) => {
git.append(el('dt', null, row[0]), el('dd', null, row[1]));
});
actions.append(linkBtn(GITHUB, 'Open GitHub profile', 'lime', 'ext'));
} else {
const p = n.data;
const img = el('img');
img.src = p.img;
img.alt = 'Screenshot of ' + p.title;
img.width = 960;
img.height = 540;
img.decoding = 'async';
media.append(img);
meta.append(el('span', 'tag', groupOf(p).tag), el('span', null, p.year), el('span', null, p.live ? 'live on GitHub Pages' : 'source on GitHub'));
title = el('h3', 'insp__title', p.title);
desc = el('p', 'insp__desc', p.desc);
chips = el('ul', 'chips');
p.stack.forEach((s) => chips.append(el('li', null, s)));
[['remote', 'github.com/Dhellss/' + p.repo], ['last push', fmtDate(p.pushed)]].forEach((row) => {
git.append(el('dt', null, row[0]), el('dd', null, row[1]));
});
if (p.live) actions.append(linkBtn(p.live, p.group === 'games' ? 'Play live' : 'Open live', 'lime', 'play'));
actions.append(linkBtn(GITHUB + '/' + p.repo, 'Code on GitHub', p.live ? 'ghost' : 'lime', 'code'));
}
const nav = el('div', 'insp__nav');
const prev = el('button', 'insp__step');
prev.type = 'button';
prev.innerHTML = svg('left');
prev.append(document.createTextNode('prev'));
prev.setAttribute('aria-label', 'Previous project');
prev.addEventListener('click', () => step(-1));
const next = el('button', 'insp__step');
next.type = 'button';
next.append(document.createTextNode('next'));
next.insertAdjacentHTML('beforeend', svg('right'));
next.setAttribute('aria-label', 'Next project');
next.addEventListener('click', () => step(1));
const pool = visibleProjects();
const idx = n.type === 'project' ? pool.indexOf(n) + 1 : 0;
nav.append(prev, el('span', null, idx ? idx + ' of ' + pool.length : pool.length + ' projects'), next);
inspector.append(media, meta, title, desc);
if (chips) inspector.append(chips);
inspector.append(git, actions, nav);
if (animate && !reduceMotion) {
inspector.classList.remove('is-swap');
void inspector.offsetWidth;
inspector.classList.add('is-swap');
requestAnimationFrame(() => media.style.setProperty('--h', media.clientHeight + 'px'));
}
}
function openSheet(from) {
S.sheetOpen = true;
S.returnFocus = from || null;
inspector.inert = false;
inspector.classList.add('is-open');
backdrop.hidden = false;
const c = $('.insp__close', inspector);
if (c) setTimeout(() => c.focus({ preventScroll: true }), 60);
}
function closeSheet() {
if (!S.sheetOpen) return;
S.sheetOpen = false;
inspector.classList.remove('is-open');
backdrop.hidden = true;
if (sheetMQ.matches) inspector.inert = true;
if (S.returnFocus) S.returnFocus.focus({ preventScroll: true });
}
// Sa phone, inililipat ang inspector sa <body> para lumabas bilang bottom sheet
// (hindi ito natatakpan o napuputol ng glass window).
const inspectorHome = inspector.parentElement;
function syncSheetMode() {
if (sheetMQ.matches) {
if (inspector.parentElement !== document.body) document.body.append(inspector);
inspector.inert = !S.sheetOpen;
} else {
if (inspector.parentElement !== inspectorHome) inspectorHome.append(inspector);
S.sheetOpen = false;
inspector.classList.remove('is-open');
backdrop.hidden = true;
inspector.inert = false;
}
}
backdrop.addEventListener('click', closeSheet);
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') closeSheet();
});
if (sheetMQ.addEventListener) sheetMQ.addEventListener('change', syncSheetMode);
/* --- Filters --- */
function buildFilters() {
const items = [{ id: 'all', name: 'All', count: PROJECTS.length }].concat(
GROUPS.map((g) => ({ id: g.id, name: g.name, count: PROJECTS.filter((p) => p.group === g.id).length }))
);
items.forEach((it) => {
const b = el('button', 'filter');
b.type = 'button';
b.dataset.filter = it.id;
b.setAttribute('aria-pressed', String(it.id === 'all'));
b.append(document.createTextNode(it.name), el('b', null, String(it.count)));
b.addEventListener('click', () => setFilter(it.id));
filtersEl.append(b);
});
}
function applyFilterFlags() {
const f = S.filter;
projNodes.forEach((p) => {
const match = f === 'all' || p.data.group === f;
p.dim = !match;
p.hidden = S.mode === 'tree' && !match;
});
GROUPS.forEach((g) => {
const gn = groupNodes[g.id];
const match = f === 'all' || g.id === f;
gn.dim = !match;
gn.hidden = S.mode === 'tree' && !match;
gn.el.classList.toggle('is-active', f === g.id);
});
nodes.forEach((n) => {
n.el.classList.toggle('is-dim', n.dim && S.mode === 'graph');
n.el.hidden = n.hidden;
});
}
function setFilter(id) {
S.filter = id;
$$('.filter', filtersEl).forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.filter === id)));
applyFilterFlags();
PROJECTS.forEach((p) => {
if (p.card) p.card.hidden = !(id === 'all' || p.group === id);
});
if (S.view === 'list') animateCards();
if (S.mode === 'tree') layout(true);
if (S.selected && S.selected.type === 'project' && S.selected.dim) {
const first = visibleProjects()[0];
if (first) select(first, { quiet: true });
} else if (S.selected) {
renderInspector(S.selected, false);
}
// Maliit na "sync" burst sa mga napiling projects
if (!reduceMotion && S.view === 'map') {
visibleProjects().forEach((p, i) => setTimeout(() => sendPush(p, false), i * 45));
}
}
/* --- Layout --- */
function measure() {
nodes.forEach((n) => {
if (n.hidden) return;
n.w = n.el.offsetWidth;
n.h = n.el.offsetHeight;
});
}
function sizeCanvas() {
const dpr = Math.min(window.devicePixelRatio || 1, 2);
canvas.width = Math.round(S.W * dpr);
canvas.height = Math.round(S.H * dpr);
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
}
function seedPositions() {
const r = mulberry32(1234);
const hx = S.W * 0.5;
const hy = S.H * 0.47;
hub.x = hx;
hub.y = hy;
GROUPS.forEach((g) => {
const gn = groupNodes[g.id];
gn.x = hx + (g.anchor[0] - 0.5) * S.W;
gn.y = hy + (g.anchor[1] - 0.47) * S.H;
const kids = gn.children;
const base = Math.atan2(gn.y - hy, gn.x - hx);
const spanA = Math.min(Math.PI * 1.5, 0.55 * kids.length);
kids.forEach((k, i) => {
const a = base + (kids.length > 1 ? (i / (kids.length - 1) - 0.5) * spanA : 0);
k.x = gn.x + Math.cos(a) * gn.rest + (r() - 0.5) * 10;
k.y = gn.y + Math.sin(a) * gn.rest * 0.8 + (r() - 0.5) * 10;
});
});
nodes.forEach((n) => {
n.vx = 0;
n.vy = 0;
});
}
function physicsStep(jitter) {
const W = S.W;
const H = S.H;
// GitHub hub: bumabalik sa gitna
if (!hub.dragging) {
hub.vx += (W * 0.5 - hub.x) * 0.03;
hub.vy += (H * 0.47 - hub.y) * 0.03;
}
// Folders: hinihila papunta sa kanilang puwesto (relative sa hub)
GROUPS.forEach((g) => {
const n = groupNodes[g.id];
if (n.dragging) return;
n.vx += (hub.x + (g.anchor[0] - 0.5) * W - n.x) * 0.014;
n.vy += (hub.y + (g.anchor[1] - 0.47) * H - n.y) * 0.014;
});
// Springs: project <-> folder
projNodes.forEach((p) => {
const g = p.parent;
const dx = p.x - g.x;
const dy = p.y - g.y;
const d = Math.hypot(dx, dy) || 0.01;
const f = (d - g.rest) * 0.012;
const ux = dx / d;
const uy = dy / d;
if (!p.dragging) {
p.vx -= ux * f;
p.vy -= uy * f;
}
if (!g.dragging) {
g.vx += ux * f * 0.2;
g.vy += uy * f * 0.2;
}
});
// Repulsion: nagtutulakan ang mga node
const R = 1500 * S.scale * S.scale;
for (let i = 0; i < nodes.length; i++) {
const a = nodes[i];
for (let j = i + 1; j < nodes.length; j++) {
const b = nodes[j];
let dx = b.x - a.x;
let dy = b.y - a.y;