-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
1596 lines (1442 loc) · 58.7 KB
/
Copy pathscript.js
File metadata and controls
1596 lines (1442 loc) · 58.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ─────────────────────────────────────────────
// PORTFOLIO -- script.js
// ─────────────────────────────────────────────
(function () {
'use strict';
// Inject Pokéball dot style dynamically to bypass stylesheet caching
const dotStyle = document.createElement('style');
dotStyle.innerHTML = `
.pokeball-dot {
display: inline-block !important;
width: 0.18em !important;
height: 0.18em !important;
border-radius: 50% !important;
border: 0.03em solid var(--gray-600) !important;
position: relative !important;
vertical-align: baseline !important;
margin-left: 0.06em !important;
cursor: none !important;
background: transparent !important;
transition: transform 0.3s ease, border-color 0.3s ease !important;
}
.pokeball-dot:hover {
transform: rotate(20deg) !important;
border-color: var(--text-primary) !important;
}
.pokeball-dot::before {
content: '' !important;
position: absolute !important;
top: 50% !important;
left: 0 !important;
width: 100% !important;
height: 0.03em !important;
background: var(--gray-600) !important;
transform: translateY(-50%) !important;
transition: background-color 0.3s ease !important;
}
.pokeball-dot:hover::before {
background: var(--text-primary) !important;
}
.coming-soon-title em {
color: transparent !important;
-webkit-text-stroke: 1px var(--gray-500) !important;
font-style: normal !important;
}
`;
document.head.appendChild(dotStyle);
// ─── CURSOR (desktop only) ────────────────
const isTouchDevice =
'ontouchstart' in window ||
navigator.maxTouchPoints > 0 ||
window.matchMedia('(hover: none) and (pointer: coarse)').matches;
const cursor = document.getElementById('cursor');
const trail = document.getElementById('cursorTrail');
if (isTouchDevice) {
if (cursor) cursor.style.display = 'none';
if (trail) trail.style.display = 'none';
document.body.style.cursor = 'auto';
// Also reset the nav toggle which has cursor: none in CSS
const navToggle = document.getElementById('navToggle');
if (navToggle) navToggle.style.cursor = 'auto';
} else {
let mouseX = 0, mouseY = 0;
let trailX = 0, trailY = 0;
document.addEventListener('mousemove', (e) => {
mouseX = e.clientX;
mouseY = e.clientY;
cursor.style.left = mouseX + 'px';
cursor.style.top = mouseY + 'px';
});
// Smooth trailing cursor
(function animateTrail() {
trailX += (mouseX - trailX) * 0.12;
trailY += (mouseY - trailY) * 0.12;
trail.style.left = trailX + 'px';
trail.style.top = trailY + 'px';
requestAnimationFrame(animateTrail);
})();
// Hover effect on interactive elements (delegated to document for dynamic components)
document.addEventListener('mouseover', (e) => {
const target = e.target.closest('a, button, .project-card, .fact-card, .tag, .btn-primary, .btn-ghost, .indicator-dot, .slider-btn, .modal-close, .pokeball-dot');
if (target) {
document.body.classList.add('cursor-hover');
} else {
document.body.classList.remove('cursor-hover');
}
});
}
// ─── NAV SCROLL ───────────────────────────
const nav = document.getElementById('nav');
const onScroll = () => {
nav.classList.toggle('scrolled', window.scrollY > 60);
};
window.addEventListener('scroll', onScroll, { passive: true });
// ─── MOBILE MENU ──────────────────────────
const navToggle = document.getElementById('navToggle');
const mobileMenu = document.getElementById('mobileMenu');
let menuOpen = false;
const toggleMenu = () => {
menuOpen = !menuOpen;
mobileMenu.classList.toggle('open', menuOpen);
document.body.style.overflow = menuOpen ? 'hidden' : '';
const spans = navToggle.querySelectorAll('span');
if (menuOpen) {
spans[0].style.transform = 'translateY(6.5px) rotate(45deg)';
spans[1].style.transform = 'translateY(-6.5px) rotate(-45deg)';
} else {
spans[0].style.transform = '';
spans[1].style.transform = '';
}
};
navToggle.addEventListener('click', toggleMenu);
document.querySelectorAll('.mobile-link').forEach(link => {
link.addEventListener('click', () => {
if (menuOpen) toggleMenu();
});
});
const navLogo = document.querySelector('.nav-logo');
if (navLogo) {
navLogo.addEventListener('click', () => {
if (menuOpen) toggleMenu();
});
}
// ─── REVEAL ON SCROLL ─────────────────────
const revealEls = document.querySelectorAll('.reveal-up');
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target);
}
});
}, {
threshold: 0.12,
rootMargin: '0px 0px -40px 0px'
});
revealEls.forEach(el => observer.observe(el));
// ─── PROJECT CARD GLOW ────────────────────
document.querySelectorAll('.project-card').forEach(card => {
card.addEventListener('mousemove', (e) => {
const rect = card.getBoundingClientRect();
const x = ((e.clientX - rect.left) / rect.width) * 100;
const y = ((e.clientY - rect.top) / rect.height) * 100;
card.style.setProperty('--mouse-x', x + '%');
card.style.setProperty('--mouse-y', y + '%');
});
});
// ─── TICKER PAUSE ON HOVER ────────────────
const ticker = document.querySelector('.ticker');
if (ticker) {
ticker.addEventListener('mouseenter', () => {
ticker.style.animationPlayState = 'paused';
});
ticker.addEventListener('mouseleave', () => {
ticker.style.animationPlayState = 'running';
});
}
// ─── SMOOTH SCROLL ───────────────────────
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', (e) => {
const target = document.querySelector(anchor.getAttribute('href'));
if (target) {
e.preventDefault();
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
});
// ─── HERO NAME STROKE ANIMATION ──────────
// Subtle parallax on the orbs
const orb1 = document.querySelector('.orb-1');
const orb2 = document.querySelector('.orb-2');
if (orb1 && orb2) {
document.addEventListener('mousemove', (e) => {
const cx = window.innerWidth / 2;
const cy = window.innerHeight / 2;
const dx = (e.clientX - cx) / cx;
const dy = (e.clientY - cy) / cy;
orb1.style.transform = `translate(${dx * 20}px, ${dy * 20}px)`;
orb2.style.transform = `translate(${dx * -15}px, ${dy * -15}px)`;
});
}
// ─── STAGGERED REVEAL FOR CHILDREN ──────
// Trigger initial reveals for elements already in view on load
const initialCheck = () => {
revealEls.forEach(el => {
const rect = el.getBoundingClientRect();
if (rect.top < window.innerHeight * 0.95) {
el.classList.add('visible');
observer.unobserve(el);
}
});
};
// Small delay to let CSS load
setTimeout(initialCheck, 100);
// ─── PAGE LOAD ANIMATION ─────────────────
document.body.style.opacity = '0';
window.addEventListener('load', () => {
document.body.style.transition = 'opacity 0.5s ease';
document.body.style.opacity = '1';
});
// ─── TOAST HELPER ────────────────────────
const toast = document.getElementById('toast');
let toastTimer = null;
function showToast(msg) {
if (!toast) return;
toast.textContent = msg;
toast.classList.add('show');
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove('show'), 2800);
}
// ─── EMAIL COPY + MAILTO ─────────────────
// Intercept ALL mailto links: copy address to clipboard, then let the
// browser try to open the mail client. Shows a toast either way so the
// user always gets feedback even when no mail client is configured.
const EMAIL = 'udayaditya@proton.me';
document.querySelectorAll('a[href^="mailto:"]').forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
navigator.clipboard.writeText(EMAIL)
.then(() => showToast('Email copied -- ' + EMAIL))
.catch(() => showToast('✉ ' + EMAIL));
// Also attempt to open the mail client (works if one is configured)
setTimeout(() => { window.location.href = 'mailto:' + EMAIL; }, 300);
});
});
// ─── CONNECT CTA -- magnetic effect ───────
const connectCta = document.getElementById('connectCta');
if (connectCta) {
connectCta.addEventListener('mousemove', (e) => {
const rect = connectCta.getBoundingClientRect();
const cx = rect.left + rect.width / 2;
const cy = rect.top + rect.height / 2;
const dx = (e.clientX - cx) * 0.25;
const dy = (e.clientY - cy) * 0.25;
connectCta.style.transform = `translate(${dx}px, ${dy}px)`;
});
connectCta.addEventListener('mouseleave', () => {
connectCta.style.transform = '';
});
}
// ─── ACTIVE NAV LINK HIGHLIGHT ───────────
const sections = document.querySelectorAll('section[id]');
const navLinks = document.querySelectorAll('.nav-link');
const highlightNav = () => {
let current = '';
sections.forEach(section => {
if (window.scrollY >= section.offsetTop - 200) {
current = section.getAttribute('id');
}
});
navLinks.forEach(link => {
link.style.color = link.getAttribute('href') === `#${current}`
? 'var(--text-primary)'
: '';
});
};
window.addEventListener('scroll', highlightNav, { passive: true });
// ─── PROJECT DETAILS MODAL ────────────────
const projectData = {
'proj-cataclysm': {
title: 'Cataclysm',
number: '01',
tags: ['Game Dev', 'TypeScript', 'Strategy', 'WebGL'],
status: 'In progress',
statusClass: 'status-wip',
description: 'A turn-based hex strategy game with unique character mechanics -- traps, thresholds, and units that fight dirty. Built from scratch with custom rendering.',
features: [
'Custom rendering pipeline using HTML5 Canvas & WebGL.',
'Unique tactical unit abilities including traps, displacement, and catnip usage.',
'Interactive deckbuilder mode with card drawing limits and deck constraints.',
'Server integration tracking player matches and an ELO rating leaderboard.'
],
media: [
{ type: 'image', path: 'media/catnip/catnip1.png', caption: 'Tactical board layout showing hex grid and unit tokens.' },
{ type: 'video', path: 'media/catnip/catnip1.mp4', caption: 'Gameplay walkthrough and unit movement preview.' },
{ type: 'image', path: 'media/catnip/catnip2.png', caption: 'Cat Tree base defense and unit positioning.' },
{ type: 'video', path: 'media/catnip/catnip2.mp4', caption: 'Defeat / Victory game over screen display.' },
{ type: 'image', path: 'media/catnip/catnip3.png', caption: 'Card selection and unit detail overview.' }
],
links: [
{ text: 'Live Demo', url: 'https://cataclysm-main.onrender.com' },
{ text: 'GitHub', url: 'https://github.com/sleepcompiler/cataclysm' }
]
},
'proj-plaiground': {
title: 'Plaiground',
number: '02',
tags: ['AI', 'TypeScript', 'Web'],
status: 'Live',
statusClass: 'status-live',
description: 'An AI playground for experimenting with language models, specifically making them play Pokemon FireRed on an emulator. Watching them make decisions is fascinating and offers insights into agentic workflows.',
features: [
'Direct interface with Game Boy Advance emulator inside browser runtime.',
'Real-time OCR and RAM state reading to feed textual environment representations to LLM agents.',
'Live logging panel visualizing prompt details, decision trees, and battle actions.',
'Adjustable LLM hyperparameters and prompt injection control interface.'
],
media: [
{ type: 'image', path: 'media/plaiground/plaiground1.png', caption: 'Agentic model decision log panel side-by-side with active emulator.' }
],
links: [
{ text: 'GitHub', url: 'https://github.com/sleepcompiler/plaiground' }
]
},
'proj-clipmaster': {
title: 'ClipMaster 95',
number: '03',
tags: ['Rust', 'Tauri', 'Desktop'],
status: 'Live',
statusClass: 'status-live',
description: 'A retro-styled clipboard manager for power users. Global hotkeys, persistent history, and a UI that nods to the golden era of software aesthetics.',
features: [
'Ultra-fast desktop integration using Tauri and Rust backend.',
'Authentic Windows 95 classic design theme with customizable widgets.',
'Local SQLite database cache with rapid full-text search index.',
'Global shortcut listener and automatic clipboard monitoring with minimal resource usage.'
],
media: [
{ type: 'image', path: 'media/clipmaster/clipmaster1.png', caption: 'Classic dialog box layout with retro styled borders.' },
{ type: 'image', path: 'media/clipmaster/clipmaster2.png', caption: 'Clipboard history scrolling menu with instant copying.' },
{ type: 'image', path: 'media/clipmaster/clipmaster3.png', caption: 'Advanced theme customizer and retro font selectors.' },
{ type: 'image', path: 'media/clipmaster/clipmaster4.png', caption: 'Settings menu modal in the nostalgic OS styling.' },
{ type: 'image', path: 'media/clipmaster/clipmaster5.png', caption: 'Vintage interface controls, checkboxes, and buttons.' },
{ type: 'image', path: 'media/clipmaster/clipmaster6.png', caption: 'Vintage grid list showcasing copied text snippets.' }
],
links: [
{ text: 'GitHub', url: 'https://github.com/sleepcompiler/clipmaster95' }
]
},
'proj-cinereview': {
title: 'CineReview',
number: '04',
tags: ['Full Stack', 'Prisma', 'Node.js'],
status: 'In progress',
statusClass: 'status-wip',
description: 'A movie tracking and review platform. Pulls from external APIs, persists data with Prisma, and serves up a clean, modern browsing experience.',
features: [
'Real-time movie details retrieval via Tmdb API wrapper integrations.',
'Secure user authentication and relational database schema modeled with Prisma.',
'Responsive layout for browsing popular, trending, and highly-rated movies.',
'Custom review creation, tracking lists, and ratings logging.'
],
media: [
{ type: 'image', path: 'media/cinerev/cinerev (1).png', caption: 'CineReview homepage displaying trending, popular, and top-rated movies.' },
{ type: 'image', path: 'media/cinerev/cinerev (2).png', caption: 'Detailed movie page featuring synopsis, ratings, and genre tags.' },
{ type: 'image', path: 'media/cinerev/cinerev (3).png', caption: 'Personalized user dashboard for tracking watchlist and reviews.' },
{ type: 'image', path: 'media/cinerev/cinerev (4).png', caption: 'Interactive movie search and advanced filters.' },
{ type: 'image', path: 'media/cinerev/cinerev (5).png', caption: 'User reviews and movie ratings discussion panel.' }
],
links: [
{ text: 'Live Demo', url: 'https://cinerev.onrender.com/' },
{ text: 'GitHub', url: 'https://github.com/sleepcompiler/cinerev' }
]
},
'proj-p2psync': {
title: 'P2P Sync',
number: '05',
tags: ['Rust', 'WebRTC', 'CRDTs'],
status: 'Coming soon',
statusClass: 'status-wip',
description: 'A local-first synchronization library written in Rust. Leverages CRDTs for seamless conflict resolution, WebRTC for direct peer-to-peer data transfer, and encrypted SQLite for secure local storage in Tauri apps.',
features: [
'Local-first data management using Conflict-Free Replicated Data Types (CRDTs).',
'Direct browser-to-browser and device-to-device communication using WebRTC.',
'Tauri-ready storage layer relying on SQLCipher/SQLite encryption.',
'Distributed replication mechanism bypassing centralized servers.'
],
media: [], // Empty (will show "No screencaptures to show. Visit GitHub for project details.")
links: [
{ text: 'GitHub', url: 'https://github.com/sleepcompiler/p2p-sync' }
]
},
'proj-archivist': {
title: 'Archivist',
number: '06',
tags: ['Rust', 'Tauri', 'Wasm AI'],
status: 'Coming soon',
statusClass: 'status-wip',
description: 'A local-first, semantic clipboard manager. Runs local WebAssembly sentence transformers to cluster, search, and categorize clippings into structured Markdown folders, with a 2D interactive canvas graph and PDF exports.',
features: [
'Offline sentence embeddings generated client-side using Transformers.js.',
'Auto-categorization of clipboard contents into specific folders based on cosine similarity.',
'Interactive 2D physics graph layout displaying semantic relationships.',
'One-click clean PDF document exports.'
],
media: [],
links: [
{ text: 'GitHub', url: 'https://github.com/sleepcompiler/archivist' }
]
},
'proj-wiki': {
title: 'Wiki Engine',
number: '07',
tags: ['React', 'Node.js', 'Full Stack'],
status: 'Coming soon',
statusClass: 'status-wip',
description: 'A lightweight, clean local wiki and knowledge base engine for developers. Features lightning fast full-text searching, markdown parsing, visual category browsing, and instant page linking.',
features: [
'Dynamic markdown parsing and local link resolution.',
'Interactive Category Browser grid view.',
'Fast local indexing for full-text search.',
'Zero-configuration database storage.'
],
media: [],
links: [
{ text: 'GitHub', url: 'https://github.com/sleepcompiler/wiki' }
]
}
};
const modal = document.getElementById('projectModal');
const backdrop = document.getElementById('modalBackdrop');
const closeBtn = document.getElementById('modalClose');
const slidesTrack = document.getElementById('modalSlidesTrack');
const sliderPrev = document.getElementById('sliderPrev');
const sliderNext = document.getElementById('sliderNext');
const sliderIndicators = document.getElementById('sliderIndicators');
const modalNum = document.getElementById('modalProjectNum');
const modalTitle = document.getElementById('modalProjectTitle');
const modalTags = document.getElementById('modalProjectTags');
const modalDesc = document.getElementById('modalProjectDesc');
const modalFeatures = document.getElementById('modalProjectFeatures');
const modalStatus = document.getElementById('modalProjectStatus');
const modalLinks = document.getElementById('modalProjectLinks');
let currentProjectList = [
'proj-cataclysm',
'proj-plaiground',
'proj-clipmaster',
'proj-cinereview',
'proj-p2psync',
'proj-archivist',
'proj-wiki'
];
let currentProjectIndex = -1;
let currentSlideIndex = 0;
let activeMedia = [];
let previousActiveElement = null;
// Scroll wheel locks to prevent rapid spinning
let scrollLock = false;
let projectScrollLock = false;
const openProjectModal = (projectId) => {
const data = projectData[projectId];
if (!data) return;
previousActiveElement = document.activeElement;
currentProjectIndex = currentProjectList.indexOf(projectId);
activeMedia = data.media || [];
currentSlideIndex = 0;
// Populate details
modalNum.textContent = data.number;
modalTitle.textContent = data.title;
modalDesc.textContent = data.description;
modalStatus.textContent = data.status;
modalStatus.className = 'project-status ' + data.statusClass;
// Populate tags
modalTags.innerHTML = '';
data.tags.forEach(tag => {
const span = document.createElement('span');
span.className = 'ptag';
span.textContent = tag;
modalTags.appendChild(span);
});
// Populate features
modalFeatures.innerHTML = '';
data.features.forEach(feat => {
const li = document.createElement('li');
li.textContent = feat;
modalFeatures.appendChild(li);
});
// Populate links
modalLinks.innerHTML = '';
data.links.forEach(link => {
const a = document.createElement('a');
a.href = link.url;
a.target = '_blank';
a.rel = 'noopener';
a.className = 'project-link-text';
a.textContent = link.text + ' ↗';
modalLinks.appendChild(a);
});
// Populate slides
slidesTrack.innerHTML = '';
sliderIndicators.innerHTML = '';
if (activeMedia.length === 0) {
const slide = document.createElement('div');
slide.className = 'modal-slide';
const placeholder = document.createElement('div');
placeholder.className = 'modal-placeholder';
placeholder.innerHTML = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<rect x="2" y="3" width="20" height="14" rx="2" ry="2" />
<line x1="8" y1="21" x2="16" y2="21" />
<line x1="12" y1="17" x2="12" y2="21" />
</svg>
`;
const p = document.createElement('p');
if (projectId === 'proj-p2psync') {
p.textContent = 'No screencaptures to show. Visit GitHub for project details.';
} else {
p.textContent = 'No screenshots available yet. Visit GitHub or Live Demo for project details.';
}
placeholder.appendChild(p);
slide.appendChild(placeholder);
slidesTrack.appendChild(slide);
sliderPrev.classList.add('hidden');
sliderNext.classList.add('hidden');
} else {
activeMedia.forEach((media, idx) => {
const slide = document.createElement('div');
slide.className = 'modal-slide';
if (media.type === 'video') {
const video = document.createElement('video');
video.src = media.path;
video.controls = true;
video.loop = true;
video.muted = true;
video.playsInline = true;
slide.appendChild(video);
} else {
const img = document.createElement('img');
img.src = media.path;
img.alt = media.caption;
img.loading = 'lazy';
slide.appendChild(img);
}
slidesTrack.appendChild(slide);
const dot = document.createElement('button');
dot.className = 'indicator-dot' + (idx === 0 ? ' active' : '');
dot.setAttribute('aria-label', 'Go to slide ' + (idx + 1));
dot.addEventListener('click', () => {
goToSlide(idx);
});
sliderIndicators.appendChild(dot);
});
if (activeMedia.length > 1) {
sliderPrev.classList.remove('hidden');
sliderNext.classList.remove('hidden');
} else {
sliderPrev.classList.add('hidden');
sliderNext.classList.add('hidden');
}
}
updateSlider();
modal.classList.add('open');
modal.setAttribute('aria-hidden', 'false');
document.body.classList.add('modal-open');
if (closeBtn) {
closeBtn.focus();
}
};
const closeModal = () => {
if (previousActiveElement && typeof previousActiveElement.focus === 'function') {
previousActiveElement.focus();
} else if (modal.contains(document.activeElement)) {
document.activeElement.blur();
}
modal.classList.remove('open');
modal.setAttribute('aria-hidden', 'true');
document.body.classList.remove('modal-open');
const videos = slidesTrack.querySelectorAll('video');
videos.forEach(video => video.pause());
};
const updateSlider = () => {
if (activeMedia.length === 0) return;
slidesTrack.style.transform = `translateX(-${currentSlideIndex * 100}%)`;
const dots = sliderIndicators.querySelectorAll('.indicator-dot');
dots.forEach((dot, idx) => {
dot.classList.toggle('active', idx === currentSlideIndex);
});
const slides = slidesTrack.querySelectorAll('.modal-slide');
slides.forEach((slide, idx) => {
const video = slide.querySelector('video');
if (video) {
if (idx === currentSlideIndex) {
video.play().catch(() => { });
} else {
video.pause();
}
}
});
};
const goToSlide = (index) => {
if (activeMedia.length === 0) return;
currentSlideIndex = index;
updateSlider();
};
const nextSlide = () => {
if (activeMedia.length <= 1) return;
currentSlideIndex = (currentSlideIndex + 1) % activeMedia.length;
updateSlider();
};
const prevSlide = () => {
if (activeMedia.length <= 1) return;
currentSlideIndex = (currentSlideIndex - 1 + activeMedia.length) % activeMedia.length;
updateSlider();
};
// Close handlers
backdrop.addEventListener('click', closeModal);
closeBtn.addEventListener('click', closeModal);
// Slider navigation clicks
sliderPrev.addEventListener('click', prevSlide);
sliderNext.addEventListener('click', nextSlide);
// Click on project cards to open modal
document.querySelectorAll('.project-card').forEach(card => {
const handleActivation = (e) => {
if (e.target.closest('a')) return;
e.preventDefault();
openProjectModal(card.id);
};
card.addEventListener('click', handleActivation);
card.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
handleActivation(e);
}
});
});
// keyboard handlers
document.addEventListener('keydown', (e) => {
if (!modal.classList.contains('open')) return;
if (e.key === 'Escape') {
closeModal();
} else if (e.key === 'ArrowRight') {
nextSlide();
} else if (e.key === 'ArrowLeft') {
prevSlide();
}
});
// Wheel hijacking inside modal
modal.addEventListener('wheel', (e) => {
if (!modal.classList.contains('open')) return;
const onMedia = e.target.closest('.modal-media-container');
if (onMedia) {
if (activeMedia.length <= 1) return;
e.preventDefault();
if (scrollLock) return;
scrollLock = true;
if (e.deltaY > 0) {
nextSlide();
} else if (e.deltaY < 0) {
prevSlide();
}
setTimeout(() => {
scrollLock = false;
}, 400);
} else {
e.preventDefault();
if (projectScrollLock) return;
projectScrollLock = true;
const contentEl = modal.querySelector('.modal-content');
if (contentEl) {
contentEl.style.transition = 'opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1)';
contentEl.style.opacity = '0';
contentEl.style.transform = 'scale(0.98)';
}
setTimeout(() => {
let nextProjIndex = currentProjectIndex;
if (e.deltaY > 0) {
nextProjIndex = (currentProjectIndex + 1) % currentProjectList.length;
} else if (e.deltaY < 0) {
nextProjIndex = (currentProjectIndex - 1 + currentProjectList.length) % currentProjectList.length;
}
const nextProjId = currentProjectList[nextProjIndex];
const data = projectData[nextProjId];
if (data) {
const videos = slidesTrack.querySelectorAll('video');
videos.forEach(v => v.pause());
currentProjectIndex = nextProjIndex;
activeMedia = data.media || [];
currentSlideIndex = 0;
modalNum.textContent = data.number;
modalTitle.textContent = data.title;
modalDesc.textContent = data.description;
modalStatus.textContent = data.status;
modalStatus.className = 'project-status ' + data.statusClass;
modalTags.innerHTML = '';
data.tags.forEach(tag => {
const span = document.createElement('span');
span.className = 'ptag';
span.textContent = tag;
modalTags.appendChild(span);
});
modalFeatures.innerHTML = '';
data.features.forEach(feat => {
const li = document.createElement('li');
li.textContent = feat;
modalFeatures.appendChild(li);
});
modalLinks.innerHTML = '';
data.links.forEach(link => {
const a = document.createElement('a');
a.href = link.url;
a.target = '_blank';
a.rel = 'noopener';
a.className = 'project-link-text';
a.textContent = link.text + ' ↗';
modalLinks.appendChild(a);
});
slidesTrack.innerHTML = '';
sliderIndicators.innerHTML = '';
if (activeMedia.length === 0) {
const slide = document.createElement('div');
slide.className = 'modal-slide';
const placeholder = document.createElement('div');
placeholder.className = 'modal-placeholder';
placeholder.innerHTML = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<rect x="2" y="3" width="20" height="14" rx="2" ry="2" />
<line x1="8" y1="21" x2="16" y2="21" />
<line x1="12" y1="17" x2="12" y2="21" />
</svg>
`;
const p = document.createElement('p');
if (nextProjId === 'proj-p2psync') {
p.textContent = 'No screencaptures to show. Visit GitHub for project details.';
} else {
p.textContent = 'No screenshots available yet. Visit GitHub or Live Demo for project details.';
}
placeholder.appendChild(p);
slide.appendChild(placeholder);
slidesTrack.appendChild(slide);
sliderPrev.classList.add('hidden');
sliderNext.classList.add('hidden');
} else {
activeMedia.forEach((media, idx) => {
const slide = document.createElement('div');
slide.className = 'modal-slide';
if (media.type === 'video') {
const video = document.createElement('video');
video.src = media.path;
video.controls = true;
video.loop = true;
video.muted = true;
video.playsInline = true;
slide.appendChild(video);
} else {
const img = document.createElement('img');
img.src = media.path;
img.alt = media.caption;
img.loading = 'lazy';
slide.appendChild(img);
}
slidesTrack.appendChild(slide);
const dot = document.createElement('button');
dot.className = 'indicator-dot' + (idx === 0 ? ' active' : '');
dot.setAttribute('aria-label', 'Go to slide ' + (idx + 1));
dot.addEventListener('click', () => {
goToSlide(idx);
});
sliderIndicators.appendChild(dot);
});
if (activeMedia.length > 1) {
sliderPrev.classList.remove('hidden');
sliderNext.classList.remove('hidden');
} else {
sliderPrev.classList.add('hidden');
sliderNext.classList.add('hidden');
}
}
updateSlider();
}
if (contentEl) {
contentEl.style.transition = 'opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)';
contentEl.style.opacity = '1';
contentEl.style.transform = 'scale(1)';
}
setTimeout(() => {
projectScrollLock = false;
}, 600);
}, 250);
}
}, { passive: false });
// Usage:
// dex()
let dexDatabase = null;
let dexHeaders = [];
async function preloadPokedex() {
let csvText = "";
const paths = ['./dexfull.csv', '../dexfull.csv', '/dexfull.csv'];
for (const path of paths) {
try {
const res = await fetch(path);
if (res.ok) {
csvText = await res.text();
break;
}
} catch (_) { }
}
if (!csvText) return;
const lines = csvText.split('\n');
dexHeaders = lines[0].split(',').map(h => h.replace(/"/g, '').trim());
const idIdx = dexHeaders.indexOf("Pokemon Id");
const numIdx = dexHeaders.indexOf("Pokedex Number");
const nameIdx = dexHeaders.indexOf("Pokemon Name");
const classIdx = dexHeaders.indexOf("Classification");
const preEvoIdx = dexHeaders.indexOf("Pre-Evolution Pokemon Id");
const type1Idx = dexHeaders.indexOf("Primary Type");
const type2Idx = dexHeaders.indexOf("Secondary Type");
const hpIdx = dexHeaders.indexOf("Health Stat");
const atkIdx = dexHeaders.indexOf("Attack Stat");
const defIdx = dexHeaders.indexOf("Defense Stat");
const spatkIdx = dexHeaders.indexOf("Special Attack Stat");
const spdefIdx = dexHeaders.indexOf("Special Defense Stat");
const speedIdx = dexHeaders.indexOf("Speed Stat");
const totalIdx = dexHeaders.indexOf("Base Stat Total");
const heightIdx = dexHeaders.indexOf("Pokemon Height");
const weightIdx = dexHeaders.indexOf("Pokemon Weight");
const abilityIdx = dexHeaders.indexOf("Primary Ability");
if (nameIdx === -1 || preEvoIdx === -1) return;
dexDatabase = [];
const parentIds = new Set();
for (let i = 1; i < lines.length; i++) {
const line = lines[i].trim();
if (!line) continue;
const row = [];
let insideQuote = false;
let entry = "";
for (let c = 0; c < line.length; c++) {
const ch = line[c];
if (ch === '"') {
insideQuote = !insideQuote;
} else if (ch === ',' && !insideQuote) {
row.push(entry.trim());
entry = "";
} else {
entry += ch;
}
}
row.push(entry.trim());
if (row.length <= nameIdx) continue;
const pokemonId = row[idIdx]?.replace(/^["']|["']$/g, '').trim();
const preEvoId = row[preEvoIdx]?.replace(/^["']|["']$/g, '').trim();
if (preEvoId && preEvoId !== 'NULL') {
parentIds.add(preEvoId);
}
dexDatabase.push({
id: pokemonId,
pokedexNum: row[numIdx]?.replace(/^["']|["']$/g, '').trim(),
name: row[nameIdx]?.replace(/^["']|["']$/g, '').trim(),
class: row[classIdx]?.replace(/^["']|["']$/g, '').trim(),
preEvoId: preEvoId,
type1: row[type1Idx]?.replace(/^["']|["']$/g, '').trim(),
type2: row[type2Idx]?.replace(/^["']|["']$/g, '').trim(),
hp: parseInt(row[hpIdx]) || 0,
atk: parseInt(row[atkIdx]) || 0,
def: parseInt(row[defIdx]) || 0,
spatk: parseInt(row[spatkIdx]) || 0,
spdef: parseInt(row[spdefIdx]) || 0,
speed: parseInt(row[speedIdx]) || 0,
total: parseInt(row[totalIdx]) || 0,
height: row[heightIdx]?.replace(/^["']|["']$/g, '').trim(),
weight: row[weightIdx]?.replace(/^["']|["']$/g, '').trim(),
ability: row[abilityIdx]?.replace(/^["']|["']$/g, '').trim(),
rawRow: row
});
}
dexDatabase.forEach(p => {
if (!p.preEvoId || p.preEvoId === 'NULL') {
p.stage = 1;
} else if (parentIds.has(p.id)) {
p.stage = 2;
} else {
p.stage = 3;
}
});
}
let dexWidget = null;
let dexScreen = null;
let dexSearchInput = null;
function initDexWidget() {
if (dexWidget) return;
// Inject styles dynamically to guarantee rendering and bypass browser caching
const styleEl = document.createElement('style');
styleEl.innerHTML = `
.cursor {
z-index: 999999999 !important;
mix-blend-mode: normal !important;
}
.cursor-trail {
z-index: 999999998 !important;
mix-blend-mode: normal !important;
}
.dex-chat-widget {
position: fixed !important;
bottom: 0 !important;
right: 40px !important;
width: 330px !important;
height: 40px !important;
background: #dc0a2d !important;
border: 2px solid #222 !important;
border-bottom: none !important;
border-radius: 8px 8px 0 0 !important;