This repository was archived by the owner on Oct 11, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
1422 lines (1258 loc) · 49.3 KB
/
Copy pathapp.js
File metadata and controls
1422 lines (1258 loc) · 49.3 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
/**
* GITHUB REPO LINKTREE & MINI WEBSITE ENGINE
* Ultra-minimalist, mobile-first GitHub showcase engine.
* Features a tactile Tinder-style card deck and Swiss Linktree list view.
* Zero dependencies, zero build step, real-time sync with GitHub API.
*
* Open Source & Universally Configurable (c) Emanuele BDC (emaf205).
* Licensed under the MIT License.
*/
(function () {
'use strict';
// Open-Source Default Configuration Template
const DEFAULT_CONFIG = {
username: 'your-github-username',
name: 'Your Name',
title: 'Projects & Repositories',
tagline: 'Curated collection of public repositories, web apps and client-side tools.',
theme: 'acid', // 'acid' | 'dark' | 'warm'
layout: 'cards', // 'cards' (Masonry Schede) | 'deck' (Tinder Swipe) | 'list' (Compact)
homeUrl: '',
blogUrl: '',
hideConfigButton: false,
hideForks: true,
excludedRepos: [],
pinnedRepos: [],
customDemos: {},
customCovers: {}
};
// Curated metadata and verified bespoke covers for Emanuele BDC (emaf205)
const VERIFIED_PROJECTS = {
'github': {
title: 'GitHub Repo Linktree Engine',
desc: 'Open-source mobile-first portfolio engine with responsive Masonry & 3D Swipe Deck.',
demo: 'https://emaf205.com/github/',
cover: 'assets/covers/github.jpg',
cat: 'pwa',
badge: 'Engine'
},
'silvo-tv': {
title: 'SILVO TV',
desc: 'Player vintage CRT con 200 video storici in autoplay continuo.',
demo: 'https://emaf205.com/ideas/silvo-tv/',
cover: 'assets/covers/silvo-tv.jpg',
cat: 'pwa',
badge: 'PWA'
},
'BRERA-STYLEBOOK': {
title: 'BRERA StyleBook',
desc: 'Design system editoriale svizzero e libreria visuale per workflow con l\'AI.',
demo: 'https://brera-stylebook.netlify.app/',
cover: 'assets/covers/BRERA-STYLEBOOK.jpg',
cat: 'visual',
badge: 'Design'
},
'FIXYOUREYES': {
title: 'FIXYOUREYES',
desc: 'Utility sensoriale di sollievo oculare ed esercizi per affaticamento visivo da schermo.',
demo: 'https://fixyoureyes.netlify.app',
cover: 'assets/covers/FIXYOUREYES.jpg',
cat: 'visual',
badge: 'Design'
},
'ai-policy-builder': {
title: 'AI Policy Builder',
desc: 'Generatore in 3 step di bozze di governance ed etica AI interna per aziende e studi.',
demo: 'https://emaf205.com/ideas/ai-policy-builder/',
cover: 'assets/covers/ai-policy-builder.jpg',
cat: 'pwa',
badge: 'Web App'
},
'SIMPLE-PDF-SIGN': {
title: 'Simple PDF Sign',
desc: 'Firma e timbro crittografico su PDF nel browser. 100% offline, zero caricamento server.',
demo: 'https://emaf205.com/ideas/simple-pdf-sign/',
cover: 'assets/covers/SIMPLE-PDF-SIGN.jpg',
cat: 'pwa',
badge: 'PWA'
},
'DEAD-TEXT-SOCIETY': {
title: 'Dead Text Society',
desc: 'Cripta tipografica interattiva e zine per distillare testi dimenticati e frammenti.',
demo: 'https://emaf205.com/ideas/dead-text-society/',
cover: 'assets/covers/DEAD-TEXT-SOCIETY.jpg',
cat: 'editorial',
badge: 'Editoriale'
},
'ai-diary': {
title: 'AI Diary',
desc: 'Diario intimo e cronaca di riflessione crittografata local-first con storage IndexedDB.',
demo: 'https://emaf205.com/ideas/ai-diary/',
cover: 'assets/covers/ai-diary.jpg',
cat: 'pwa',
badge: 'PWA'
},
'emaf205-tapetone': {
title: 'TapeTone Player',
desc: 'Saturatore analogico per nastro a cassetta e synth acustico via Web Audio API.',
demo: 'https://emaf205.com/ideas/tapetone/',
cover: 'assets/covers/emaf205-tapetone.jpg',
cat: 'visual',
badge: 'Audio'
},
'office-os': {
title: 'Office OS',
desc: 'Desktop environment retrò anni \'90, sistema operativo vintage e soundboard d\'ufficio.',
demo: 'https://emaf205.com/ideas/office-os/',
cover: 'assets/covers/office-os.jpg',
cat: 'tools',
badge: 'Tool'
},
'gif-tv': {
title: 'GIF TV',
desc: 'Emittente algoritmica vintage per broadcast continuo di GIF animate retrò.',
demo: 'https://emaf205.com/ideas/gif-tv/',
cover: 'assets/covers/gif-tv.jpg',
cat: 'visual',
badge: 'Design'
},
'torno-subito': {
title: 'Torno Subito',
desc: 'Net art: cartello vintage italiano con oscillazione fisica e orari di apertura.',
demo: 'https://emaf205.com/ideas/torno-subito/',
cover: 'assets/covers/torno-subito.jpg',
cat: 'visual',
badge: 'Concept'
},
'prompt-search': {
title: 'Prompt Search',
desc: 'Ricerca istantanea e catalogo visuale client-side per prompt generativi ed istruzioni AI.',
demo: 'https://emaf205.com/ideas/prompt-search/',
cover: 'assets/covers/prompt-search.jpg',
cat: 'tools',
badge: 'Tool'
},
'EASY-PERSONAL-LINKTREE': {
title: 'Easy Personal Linktree',
desc: 'Biolink minimale ad altissima velocità (<50ms), zero tracker e zero dipendenze.',
demo: 'https://linktr.ee/emaf205',
cover: 'assets/covers/EASY-PERSONAL-LINKTREE.jpg',
cat: 'pwa',
badge: 'Biolink'
},
'FTP-Minimal-Archive': {
title: 'FTP Minimal Archive',
desc: 'Browser statico di directory e deployer leggero per hosting condivisi e pacchetti release.',
demo: 'https://emaf205.com/ideas/',
cover: 'assets/covers/FTP-Minimal-Archive.jpg',
cat: 'tools',
badge: 'Tool'
},
'Rex-for-ChatGPT': {
title: 'REX for ChatGPT',
desc: 'Direttiva di sistema ad alta densità per reasoning esecutivo e revisione forense del codice.',
demo: 'https://emaf205.com/github',
cover: 'assets/covers/Rex-for-ChatGPT.jpg',
cat: 'tools',
badge: 'Persona'
},
'static-folder-publisher': {
title: 'Static Folder Publisher',
desc: 'CLI Python per compilare, sanitizzare metadati OS e sincronizzare cartelle su server web.',
demo: 'https://emaf205.com/github',
cover: 'assets/covers/static-folder-publisher.jpg',
cat: 'tools',
badge: 'CLI Tool'
},
'emaf205-landing': {
title: 'EMAF205 Landing',
desc: 'Landing page editoriale e portfolio architettonico con tipografia svizzera e codice snello.',
demo: 'https://emaf205.com',
cover: 'assets/covers/emaf205-landing.jpg',
cat: 'pwa',
badge: 'Web App'
},
'EmaF205-LinksX': {
title: 'Links-X',
desc: 'Indice personale ad alto contrasto, design brutalista e touch ergonomics su mobile.',
demo: 'https://emaf205.com/ideas/easy-links/',
cover: 'assets/covers/EmaF205-LinksX.jpg',
cat: 'pwa',
badge: 'Web App'
},
'emaf205-snap': {
title: 'SNAP Framing Utility',
desc: 'Cattura e inquadratura viewport con proporzioni perfette per mockup di web app.',
demo: 'https://emaf205.com/github',
cover: 'assets/covers/emaf205-snap.jpg',
cat: 'tools',
badge: 'Utility'
},
'EMAF205-Easy-ChatGPT-Importer': {
title: 'ChatGPT Importer',
desc: 'PWA offline-first per esplorare archivi OpenAI JSON ed esportare in Markdown pulito.',
demo: 'https://emaf205.com/ideas/chatgpt-importer/',
cover: 'assets/covers/EMAF205-Easy-ChatGPT-Importer.jpg',
cat: 'tools',
badge: 'Tool'
},
'transcript-to-magazine-ai': {
title: 'Transcript to Magazine',
desc: 'Motore editoriale per trasformare trascrizioni AI in magazine monografici stampabili.',
demo: 'https://emaf205.com/github',
cover: 'assets/covers/transcript-to-magazine-ai.jpg',
cat: 'editorial',
badge: 'Editoriale'
},
'kurt-cobain-street-critic': {
title: 'Kurt Cobain Street Critic',
desc: 'Simulatore di fanzine grunge lo-fi anni \'90 e critico stradale satirico in PWA.',
demo: 'https://emaf205.com/ideas/kurt-critic/',
cover: 'assets/covers/kurt-cobain-street-critic.jpg',
cat: 'visual',
badge: 'Game / PWA'
},
'emaf205': {
title: 'Emanuele BDC (Profile)',
desc: 'Manifesto architettonico, principi di design, profilo e repository selezionati.',
demo: 'https://emaf205.com/github',
cover: 'assets/covers/emaf205.jpg',
cat: 'editorial',
badge: 'Manifesto'
}
};
const CACHE_TTL_MS = 10 * 60 * 1000; // 10 minutes cache
// DOM Elements
const cardsSection = document.getElementById('cardsSection');
const cardsGrid = document.getElementById('cardsGrid');
const cardsEmpty = document.getElementById('cardsEmpty');
const controlsBox = document.getElementById('controlsBox');
const deckSection = document.getElementById('deckSection');
const deckStage = document.getElementById('deckStage');
const deckCounter = document.getElementById('deckCounter');
const prevCardBtn = document.getElementById('prevCardBtn');
const nextCardBtn = document.getElementById('nextCardBtn');
const listSection = document.getElementById('listSection');
const listEl = document.getElementById('list');
const searchEl = document.getElementById('search');
const clearBtn = document.getElementById('clearBtn');
const chips = document.querySelectorAll('.chip');
const countEl = document.getElementById('count');
const emptyEl = document.getElementById('empty');
const viewCardsBtn = document.getElementById('viewCardsBtn');
const viewDeckBtn = document.getElementById('viewDeckBtn');
const viewListBtn = document.getElementById('viewListBtn');
const brandNameEl = document.getElementById('brandName');
const brandLinkEl = document.getElementById('brandLink');
const pageTitleEl = document.getElementById('pageTitle');
const footGhEl = document.getElementById('footGh');
// Modal & Config Elements
const openConfigBtn = document.getElementById('openConfigBtn');
const closeConfigBtn = document.getElementById('closeConfigBtn');
const modalBackdrop = document.getElementById('modalBackdrop');
const usernameInput = document.getElementById('usernameInput');
const fetchUserBtn = document.getElementById('fetchUserBtn');
const layoutPicker = document.getElementById('layoutPicker');
const themePicker = document.getElementById('themePicker');
const repoManager = document.getElementById('repoManager');
const copyShareLinkBtn = document.getElementById('copyShareLinkBtn');
const downloadConfigBtn = document.getElementById('downloadConfigBtn');
// State
let config = Object.assign({}, DEFAULT_CONFIG);
let activeUsername = DEFAULT_CONFIG.username;
let activeTheme = DEFAULT_CONFIG.theme;
let currentView = DEFAULT_CONFIG.layout;
let hiddenRepos = new Set(DEFAULT_CONFIG.excludedRepos);
let allRepos = [];
let activeDeckProjects = [];
let deckIndex = 0;
let activeCat = 'all';
let query = '';
// Touch / Drag Gesture State
let startX = 0;
let startY = 0;
let currentX = 0;
let currentY = 0;
let isDragging = false;
let startTime = 0;
// Parse URL query parameters
function parseQueryParams() {
const params = new URLSearchParams(window.location.search);
if (params.has('u')) activeUsername = params.get('u').trim();
if (params.has('theme')) {
const th = params.get('theme').toLowerCase();
if (['acid', 'dark', 'warm'].includes(th)) activeTheme = th;
}
if (params.has('view') || params.has('layout')) {
const v = (params.get('view') || params.get('layout')).toLowerCase();
if (['cards', 'masonry', 'deck', 'list'].includes(v)) {
currentView = (v === 'masonry' ? 'cards' : v);
}
}
if (params.has('hide')) {
const hides = params.get('hide').split(',').map(s => s.trim()).filter(Boolean);
hides.forEach(h => hiddenRepos.add(h));
}
if (params.has('config') && modalBackdrop) {
modalBackdrop.classList.add('open');
}
}
// Set Theme
function setTheme(theme) {
activeTheme = theme;
document.documentElement.setAttribute('data-theme', theme);
if (themePicker) {
themePicker.querySelectorAll('.pill-btn').forEach(btn => {
btn.classList.toggle('selected', btn.getAttribute('data-val') === theme);
});
}
}
// Set View (Cards/Masonry vs Deck vs List)
function setView(view) {
if (view === 'masonry') view = 'cards';
currentView = view;
document.body.setAttribute('data-view', view);
if (viewCardsBtn) {
viewCardsBtn.classList.toggle('active', view === 'cards');
viewCardsBtn.setAttribute('aria-selected', view === 'cards');
}
if (viewDeckBtn) {
viewDeckBtn.classList.toggle('active', view === 'deck');
viewDeckBtn.setAttribute('aria-selected', view === 'deck');
}
if (viewListBtn) {
viewListBtn.classList.toggle('active', view === 'list');
viewListBtn.setAttribute('aria-selected', view === 'list');
}
if (layoutPicker) {
layoutPicker.querySelectorAll('.pill-btn').forEach(btn => {
btn.classList.toggle('selected', btn.getAttribute('data-val') === view);
});
}
if (view === 'cards') {
if (cardsSection) cardsSection.hidden = false;
if (deckSection) deckSection.hidden = true;
if (listSection) listSection.hidden = true;
if (controlsBox) controlsBox.hidden = false;
filterCards();
} else if (view === 'deck') {
if (cardsSection) cardsSection.hidden = true;
if (deckSection) deckSection.hidden = false;
if (listSection) listSection.hidden = true;
if (controlsBox) controlsBox.hidden = true;
updateDeckStack(false);
} else {
if (cardsSection) cardsSection.hidden = true;
if (deckSection) deckSection.hidden = true;
if (listSection) listSection.hidden = false;
if (controlsBox) controlsBox.hidden = false;
filterList();
}
}
// Categorize a generic repository
function categorizeRepo(repo) {
const name = (repo.name || '').toLowerCase();
const desc = (repo.description || '').toLowerCase();
const lang = (repo.language || '').toLowerCase();
if (name.includes('pwa') || desc.includes('pwa') || name.includes('link') || name.includes('landing') || repo.has_pages) {
return { cat: 'pwa', badge: 'Web App' };
}
if (name.includes('tool') || name.includes('importer') || name.includes('publisher') || desc.includes('utility') || desc.includes('tool')) {
return { cat: 'tools', badge: 'Tool' };
}
if (name.includes('visual') || name.includes('tv') || name.includes('audio') || name.includes('critic') || desc.includes('design') || desc.includes('style')) {
return { cat: 'visual', badge: 'Design' };
}
if (desc.includes('magazine') || desc.includes('testo') || desc.includes('doc') || desc.includes('bio') || name.includes('doc')) {
return { cat: 'editorial', badge: 'Editoriale' };
}
return { cat: 'tools', badge: lang ? lang.toUpperCase() : 'Code' };
}
// Render Welcome Onboarding Card in Deck when unconfigured
function renderWelcomeCard() {
if (!deckStage) return;
deckStage.innerHTML = '';
const card = document.createElement('article');
card.className = 'deck-card';
card.style.display = 'flex';
card.style.zIndex = '30';
card.style.opacity = '1';
card.style.transform = 'translate3d(0, 0, 0) scale(1) rotate(0deg)';
const cover = document.createElement('div');
cover.className = 'card-cover';
cover.innerHTML = `
<div class="cover-fallback" style="display:flex; background: linear-gradient(135deg, #111, #222); color: #fff;">
<span class="fallback-tag" style="background:var(--acid); color:#111;">OPEN SOURCE</span>
<span class="fallback-title" style="font-size:22px; color:#fff;">GitHub Repo Engine</span>
</div>
<span class="cover-badge" style="background:var(--acid); color:#111;">Quickstart</span>
`;
const content = document.createElement('div');
content.className = 'card-content';
content.innerHTML = `
<div class="card-meta">
<span class="card-num">#01</span>
<span class="card-category">Configurazione Rapida</span>
</div>
<h2 class="deck-card-title">I Tuoi Repository GitHub</h2>
<p class="deck-card-desc">Trasforma i tuoi repository pubblici in uno stack a card swipabili o linktree minimal. Inserisci il tuo username per provarlo subito:</p>
<div class="welcome-card-box">
<div class="welcome-input-row">
<input type="text" id="welcomeInput" class="welcome-input" placeholder="es. torvalds, emaf205..." autocomplete="off" spellcheck="false">
<button type="button" id="welcomeBtn" class="welcome-btn-submit">Carica ↗</button>
</div>
<div class="welcome-presets">
<span class="welcome-preset-label">Prova:</span>
<button type="button" class="welcome-preset-btn" data-u="emaf205">@emaf205</button>
<button type="button" class="welcome-preset-btn" data-u="torvalds">@torvalds</button>
<button type="button" class="welcome-preset-btn" data-u="antfu">@antfu</button>
</div>
</div>
`;
const actions = document.createElement('div');
actions.className = 'deck-card-actions';
actions.innerHTML = `
<button type="button" id="openConfigFromCardBtn" class="deck-btn-primary" style="cursor:pointer;">⚙️ Apri Configuratore</button>
<a href="https://github.com/emaf205/github" target="_blank" rel="noopener" class="deck-btn-secondary">GitHub Repo ↗</a>
`;
card.appendChild(cover);
card.appendChild(content);
card.appendChild(actions);
deckStage.appendChild(card);
if (deckCounter) deckCounter.textContent = '01 / 01';
// Welcome card events
const input = card.querySelector('#welcomeInput');
const btn = card.querySelector('#welcomeBtn');
const applyUser = (u) => {
const trimmed = (u || '').trim();
if (trimmed) {
activeUsername = trimmed;
updateHeaderInfo(activeUsername, activeUsername);
fetchUserRepos(activeUsername);
}
};
if (btn) btn.addEventListener('click', () => applyUser(input.value));
if (input) {
input.addEventListener('keydown', (e) => {
if (e.key === 'Enter') {
e.preventDefault();
applyUser(input.value);
}
});
}
card.querySelectorAll('.welcome-preset-btn').forEach(pb => {
pb.addEventListener('click', () => {
const u = pb.getAttribute('data-u');
if (u) applyUser(u);
});
});
const cfgBtn = card.querySelector('#openConfigFromCardBtn');
if (cfgBtn && modalBackdrop) {
cfgBtn.addEventListener('click', () => modalBackdrop.classList.add('open'));
}
}
// Render Deck Cards
function renderDeck(projects) {
if (!deckStage) return;
if (!activeUsername || activeUsername === 'your-github-username') {
renderWelcomeCard();
return;
}
activeDeckProjects = projects.filter(p => !hiddenRepos.has(p.name));
deckStage.innerHTML = '';
if (!activeDeckProjects.length) {
deckStage.innerHTML = '<div class="empty"><p>Nessun repository trovato o visibile.</p></div>';
if (deckCounter) deckCounter.textContent = '00 / 00';
return;
}
if (deckIndex >= activeDeckProjects.length) {
deckIndex = 0;
}
const frag = document.createDocumentFragment();
activeDeckProjects.forEach((p, idx) => {
const card = document.createElement('article');
card.className = 'deck-card';
card.setAttribute('data-index', String(idx));
card.setAttribute('data-repo', p.name);
// Cover container
const cover = document.createElement('div');
cover.className = 'card-cover';
if (p.cover) {
const img = document.createElement('img');
img.className = 'cover-img';
img.src = p.cover;
img.alt = p.title || p.name;
img.loading = (idx < 3) ? 'eager' : 'lazy';
const fallback = document.createElement('div');
fallback.className = 'cover-fallback';
fallback.style.display = 'none';
fallback.innerHTML = `<span class="fallback-tag">${p.badge || 'PROJECT'}</span><span class="fallback-title">${p.title || p.name}</span>`;
img.onerror = function () {
this.style.display = 'none';
fallback.style.display = 'flex';
};
cover.appendChild(img);
cover.appendChild(fallback);
} else {
const fallback = document.createElement('div');
fallback.className = 'cover-fallback';
fallback.innerHTML = `<span class="fallback-tag">${p.badge || 'PROJECT'}</span><span class="fallback-title">${p.title || p.name}</span>`;
cover.appendChild(fallback);
}
const badge = document.createElement('span');
badge.className = 'cover-badge';
badge.textContent = p.badge || 'Repo';
cover.appendChild(badge);
// Content container
const content = document.createElement('div');
content.className = 'card-content';
const meta = document.createElement('div');
meta.className = 'card-meta';
meta.innerHTML = `<span class="card-num">#${String(idx + 1).padStart(2, '0')}</span><span class="card-category">${p.catLabel || p.badge || 'Progetto'}</span>`;
const title = document.createElement('h2');
title.className = 'deck-card-title';
title.textContent = p.title || p.name;
const desc = document.createElement('p');
desc.className = 'deck-card-desc';
desc.textContent = p.desc || p.description || 'Nessuna descrizione disponibile.';
content.appendChild(meta);
content.appendChild(title);
content.appendChild(desc);
// Actions container
const actions = document.createElement('div');
actions.className = 'deck-card-actions';
const primaryBtn = document.createElement('a');
primaryBtn.className = 'deck-btn-primary';
primaryBtn.href = p.demo || p.html_url || `https://github.com/${activeUsername}/${p.name}`;
primaryBtn.target = '_blank';
primaryBtn.rel = 'noopener';
primaryBtn.textContent = p.demo ? 'Apri Progetto ↗' : 'GitHub Code ↗';
actions.appendChild(primaryBtn);
const codeBtn = document.createElement('a');
codeBtn.className = 'deck-btn-secondary';
codeBtn.href = p.html_url || `https://github.com/${activeUsername}/${p.name}`;
codeBtn.target = '_blank';
codeBtn.rel = 'noopener';
codeBtn.textContent = 'Code ↗';
actions.appendChild(codeBtn);
card.appendChild(cover);
card.appendChild(content);
card.appendChild(actions);
// Touch / pointer drag bindings
attachDragEvents(card);
frag.appendChild(card);
});
deckStage.appendChild(frag);
updateDeckStack(false);
}
// Update 3D Visual Deck Stack
function updateDeckStack(animate) {
if (!deckStage || !activeDeckProjects.length) return;
const cards = deckStage.querySelectorAll('.deck-card');
const total = activeDeckProjects.length;
cards.forEach(card => {
const idx = parseInt(card.getAttribute('data-index'), 10);
const diff = (idx - deckIndex + total) % total;
card.classList.remove('is-dragging');
if (diff === 0) {
// Active top card
card.style.display = 'flex';
card.style.zIndex = '30';
card.style.pointerEvents = 'auto';
card.style.opacity = '1';
card.style.transition = animate ? 'transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease' : 'none';
card.style.transform = 'translate3d(0, 0, 0) scale(1) rotate(0deg)';
} else if (diff === 1) {
// Second card underneath
card.style.display = 'flex';
card.style.zIndex = '20';
card.style.pointerEvents = 'none';
card.style.opacity = '0.9';
card.style.transition = animate ? 'transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease' : 'none';
card.style.transform = 'translate3d(0, 13px, -15px) scale(0.95) rotate(0deg)';
} else if (diff === 2) {
// Third card underneath
card.style.display = 'flex';
card.style.zIndex = '10';
card.style.pointerEvents = 'none';
card.style.opacity = '0.6';
card.style.transition = animate ? 'transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease' : 'none';
card.style.transform = 'translate3d(0, 26px, -30px) scale(0.90) rotate(0deg)';
} else {
// Hidden cards in deck
card.style.display = 'none';
card.style.zIndex = '1';
card.style.pointerEvents = 'none';
card.style.opacity = '0';
card.style.transform = 'translate3d(0, 36px, -45px) scale(0.85) rotate(0deg)';
}
});
if (deckCounter) {
deckCounter.textContent = `${String(deckIndex + 1).padStart(2, '0')} / ${String(total).padStart(2, '0')}`;
}
}
// Advance Deck Index
function advanceDeck(direction) {
if (!activeDeckProjects.length) return;
const total = activeDeckProjects.length;
const currentCard = deckStage.querySelector(`.deck-card[data-index="${deckIndex}"]`);
if (currentCard) {
currentCard.style.transition = 'transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s ease';
const flyX = direction > 0 ? -450 : 450;
currentCard.style.transform = `translate3d(${flyX}px, 0, 0) rotate(${direction > 0 ? -20 : 20}deg)`;
currentCard.style.opacity = '0';
}
setTimeout(() => {
deckIndex = (deckIndex + direction + total) % total;
updateDeckStack(true);
}, 200);
}
// Attach Touch / Pointer Drag Gesture to Card
function attachDragEvents(card) {
function startDrag(e) {
const idx = parseInt(card.getAttribute('data-index'), 10);
if (idx !== deckIndex) return;
if (e.target.closest('a') || e.target.closest('button') || e.target.closest('input')) {
return;
}
isDragging = true;
startTime = Date.now();
card.classList.add('is-dragging');
if (e.type === 'touchstart') {
startX = e.touches[0].clientX;
startY = e.touches[0].clientY;
} else {
startX = e.clientX;
startY = e.clientY;
}
currentX = startX;
currentY = startY;
}
function moveDrag(e) {
if (!isDragging) return;
if (e.type === 'touchmove') {
currentX = e.touches[0].clientX;
currentY = e.touches[0].clientY;
} else {
currentX = e.clientX;
currentY = e.clientY;
}
const deltaX = currentX - startX;
const deltaY = currentY - startY;
const rotation = deltaX * 0.08;
card.style.transition = 'none';
card.style.transform = `translate3d(${deltaX}px, ${deltaY * 0.25}px, 0) rotate(${rotation}deg)`;
const total = activeDeckProjects.length;
const nextCard = deckStage.querySelector(`.deck-card[data-index="${(deckIndex + 1) % total}"]`);
if (nextCard) {
const progress = Math.min(Math.abs(deltaX) / 180, 1);
nextCard.style.transform = `translate3d(0, ${13 - progress * 13}px, ${-15 + progress * 15}px) scale(${0.95 + progress * 0.05})`;
nextCard.style.opacity = `${0.9 + progress * 0.1}`;
}
}
function endDrag() {
if (!isDragging) return;
isDragging = false;
card.classList.remove('is-dragging');
const deltaX = currentX - startX;
const timeDiff = Date.now() - startTime;
const velocity = Math.abs(deltaX) / Math.max(timeDiff, 1);
const threshold = 75;
if (Math.abs(deltaX) > threshold || velocity > 0.55) {
const dir = deltaX > 0 ? 1 : -1;
card.style.transition = 'transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.32s ease';
card.style.transform = `translate3d(${dir * 500}px, 0, 0) rotate(${dir * 28}deg)`;
card.style.opacity = '0';
setTimeout(() => {
const total = activeDeckProjects.length;
deckIndex = (deckIndex + 1) % total;
updateDeckStack(true);
}, 260);
} else {
// Snap back spring
card.style.transition = 'transform 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275)';
card.style.transform = 'translate3d(0, 0, 0) scale(1) rotate(0deg)';
const total = activeDeckProjects.length;
const nextCard = deckStage.querySelector(`.deck-card[data-index="${(deckIndex + 1) % total}"]`);
if (nextCard) {
nextCard.style.transform = 'translate3d(0, 13px, -15px) scale(0.95)';
nextCard.style.opacity = '0.9';
}
}
}
card.addEventListener('pointerdown', startDrag);
window.addEventListener('pointermove', moveDrag);
window.addEventListener('pointerup', endDrag);
window.addEventListener('pointercancel', endDrag);
card.addEventListener('touchstart', startDrag, { passive: true });
window.addEventListener('touchmove', moveDrag, { passive: true });
window.addEventListener('touchend', endDrag);
window.addEventListener('touchcancel', endDrag);
}
// Render Masonry Schede (Default View: Vertical Stack on Mobile, Grid Side-by-Side on Desktop)
function renderCards(projects) {
if (!cardsGrid) return;
cardsGrid.innerHTML = '';
if (!activeUsername || activeUsername === 'your-github-username') {
if (cardsEmpty) {
cardsEmpty.hidden = false;
cardsEmpty.innerHTML = '<p>Inserisci un GitHub username per iniziare.</p>';
}
return;
}
const frag = document.createDocumentFragment();
projects.forEach((p, idx) => {
const isHidden = hiddenRepos.has(p.name);
const card = document.createElement('article');
card.className = 'masonry-card';
card.setAttribute('data-cat', p.cat || 'tools');
card.setAttribute('data-search', `${p.name} ${p.title} ${p.desc || ''}`.toLowerCase());
card.setAttribute('data-repo', p.name);
if (isHidden) card.style.display = 'none';
// Cover container
const cover = document.createElement('div');
cover.className = 'card-cover';
if (p.cover) {
const img = document.createElement('img');
img.className = 'cover-img';
img.src = p.cover;
img.alt = p.title || p.name;
img.loading = 'lazy';
img.onerror = function () {
this.style.display = 'none';
if (cover.querySelector('.cover-fallback')) return;
const fb = document.createElement('div');
fb.className = 'cover-fallback';
fb.innerHTML = `<span class="fallback-tag">${p.badge || 'PROGETTO'}</span><div class="fallback-title">${p.title || p.name}</div>`;
cover.appendChild(fb);
};
cover.appendChild(img);
} else {
const fb = document.createElement('div');
fb.className = 'cover-fallback';
fb.innerHTML = `<span class="fallback-tag">${p.badge || 'PROGETTO'}</span><div class="fallback-title">${p.title || p.name}</div>`;
cover.appendChild(fb);
}
const badge = document.createElement('span');
badge.className = 'cover-badge';
badge.textContent = p.badge || 'Repo';
cover.appendChild(badge);
// Content container
const content = document.createElement('div');
content.className = 'card-content';
const meta = document.createElement('div');
meta.className = 'card-meta';
meta.innerHTML = `<span class="card-num">#${String(idx + 1).padStart(2, '0')}</span><span class="card-category">${p.catLabel || p.badge || 'Progetto'}</span>`;
const title = document.createElement('h2');
title.className = 'masonry-card-title';
title.textContent = p.title || p.name;
const desc = document.createElement('p');
desc.className = 'masonry-card-desc';
desc.textContent = p.desc || p.description || 'Nessuna descrizione disponibile.';
content.appendChild(meta);
content.appendChild(title);
content.appendChild(desc);
// Actions container
const actions = document.createElement('div');
actions.className = 'masonry-card-actions';
if (p.demo) {
const demoBtn = document.createElement('a');
demoBtn.className = 'card-btn-primary';
demoBtn.href = p.demo;
demoBtn.target = '_blank';
demoBtn.rel = 'noopener';
demoBtn.textContent = 'Live Demo ↗';
actions.appendChild(demoBtn);
}
const codeBtn = document.createElement('a');
codeBtn.className = p.demo ? 'card-btn-secondary' : 'card-btn-primary';
codeBtn.href = p.html_url || `https://github.com/${activeUsername}/${p.name}`;
codeBtn.target = '_blank';
codeBtn.rel = 'noopener';
codeBtn.textContent = 'GitHub Code ↗';
actions.appendChild(codeBtn);
card.appendChild(cover);
card.appendChild(content);
card.appendChild(actions);
frag.appendChild(card);
});
cardsGrid.appendChild(frag);
filterCards();
}
// Filter Masonry Schede
function filterCards() {
if (!cardsGrid) return;
const cards = cardsGrid.querySelectorAll('.masonry-card');
let visible = 0;
const q = query.toLowerCase().trim();
cards.forEach(card => {
const repoName = card.getAttribute('data-repo');
const isHidden = hiddenRepos.has(repoName);
const matchCat = (activeCat === 'all' || card.getAttribute('data-cat') === activeCat);
const matchSearch = !q || (card.getAttribute('data-search') || '').includes(q);
if (!isHidden && matchCat && matchSearch) {
card.style.display = 'flex';
visible++;
} else {
card.style.display = 'none';
}
});
if (countEl) countEl.textContent = String(visible);
if (cardsEmpty) cardsEmpty.hidden = (visible > 0);
}
// Render Scrollable List Cards (Alternative Swiss Linktree View)
function renderList(projects) {
if (!listEl) return;
listEl.innerHTML = '';
if (!activeUsername || activeUsername === 'your-github-username') {
if (emptyEl) {
emptyEl.hidden = false;
emptyEl.innerHTML = '<p>Inserisci un username GitHub per visualizzare l\'elenco.</p>';
}
if (countEl) countEl.textContent = '0';
return;
}
const frag = document.createDocumentFragment();
projects.forEach(p => {
const isHidden = hiddenRepos.has(p.name);
const card = document.createElement('article');
card.className = 'card';
card.setAttribute('data-cat', p.cat || 'tools');
card.setAttribute('data-search', `${p.name} ${p.title} ${p.desc || ''}`.toLowerCase());
card.setAttribute('data-repo', p.name);
if (isHidden) card.style.display = 'none';
const info = document.createElement('div');
info.className = 'card-info';
const titleRow = document.createElement('div');
titleRow.className = 'card-title-row';
const title = document.createElement('h2');
title.className = 'card-title';
title.textContent = p.title || p.name;
const badge = document.createElement('span');
badge.className = 'card-badge';
badge.textContent = p.badge || 'Repo';
titleRow.appendChild(title);
titleRow.appendChild(badge);
const desc = document.createElement('p');
desc.className = 'card-desc';
desc.textContent = p.desc || p.description || '';
info.appendChild(titleRow);
info.appendChild(desc);
const actions = document.createElement('div');
actions.className = 'card-actions';
if (p.demo) {
const demoLink = document.createElement('a');
demoLink.className = 'btn-demo';
demoLink.href = p.demo;
demoLink.target = '_blank';
demoLink.rel = 'noopener';
demoLink.textContent = 'Demo ↗';
actions.appendChild(demoLink);
}
const codeLink = document.createElement('a');
codeLink.className = 'btn-code';
codeLink.href = p.html_url || `https://github.com/${activeUsername}/${p.name}`;
codeLink.target = '_blank';
codeLink.rel = 'noopener';
codeLink.textContent = 'Code ↗';
actions.appendChild(codeLink);
card.appendChild(info);
card.appendChild(actions);
frag.appendChild(card);
});
listEl.appendChild(frag);
updateRepoManager();
filterList();
}
// Update repository checkboxes in modal drawer
function updateRepoManager() {
if (!repoManager) return;
repoManager.innerHTML = '';
allRepos.forEach(repo => {
const label = document.createElement('label');
label.className = 'repo-check-item';
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.value = repo.name;
checkbox.checked = !hiddenRepos.has(repo.name);
checkbox.addEventListener('change', () => {
if (checkbox.checked) {