-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1036 lines (905 loc) · 48.7 KB
/
index.html
File metadata and controls
1036 lines (905 loc) · 48.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
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PiBOH · GitHub Portfolio</title>
<meta name="description" content="Portfolio personale GitHub di PiBOH">
<meta name="theme-color" content="#0d1117">
<style>
/* ==========================================================================
RESET E VARIABILI (GitHub Dark Theme)
========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #0d1117;
--bg-surface: #161b22;
--bg-card: #1c2128;
--border-subtle: #21262d;
--border-default: #30363d;
--text-main: #e6edf3;
--text-muted: #8b949e;
--text-dim: #6e7681;
--accent-blue: #58a6ff;
--accent-green: #3fb950;
--accent-purple: #bc8cff;
--accent-red: #f85149;
--radius-md: 8px;
--radius-sm: 6px;
--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
--font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
html { scroll-behavior: smooth; }
body {
background-color: var(--bg);
color: var(--text-main);
font-family: var(--font-sans);
line-height: 1.5;
min-height: 100vh;
display: flex;
flex-direction: column;
}
a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: inline-block; vertical-align: middle; }
/* Skip Link per accessibilità */
.skip-link {
position: fixed; left: 10px; top: 10px; z-index: 1000;
transform: translateY(-200%);
background: var(--bg-surface); border: 1px solid var(--border-default);
padding: 8px 16px; border-radius: var(--radius-sm); font-size: 14px;
}
.skip-link:focus { transform: translateY(0); outline: 2px solid var(--accent-blue); }
/* ==========================================================================
HEADER E NAVIGAZIONE
========================================================================== */
.site-header {
position: sticky; top: 0; z-index: 100;
border-bottom: 1px solid var(--border-subtle);
background-color: rgba(13, 17, 23, 0.9);
backdrop-filter: blur(10px);
}
.container {
max-width: 1080px; margin: 0 auto; padding: 0 16px;
}
.header-inner {
display: flex; align-items: center; justify-content: space-between;
gap: 16px; min-height: 54px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text-main); }
.brand:hover { text-decoration: none; }
.nav-tabs { display: flex; gap: 4px; }
.tab-btn {
background: transparent; border: none; color: var(--text-muted);
font-size: 14px; font-weight: 500; padding: 6px 12px;
border-radius: var(--radius-sm); cursor: pointer;
display: inline-flex; align-items: center; gap: 6px;
transition: color 0.15s, background 0.15s;
}
.tab-btn:hover { color: var(--text-main); background-color: var(--bg-card); }
.tab-btn.active { color: var(--text-main); background-color: rgba(88, 166, 255, 0.1); }
.badge {
display: inline-flex; align-items: center; justify-content: center;
min-width: 20px; height: 20px; padding: 0 6px; font-size: 11px; font-weight: 600;
color: var(--text-muted); background-color: var(--bg-card);
border: 1px solid var(--border-default); border-radius: 10px; line-height: 1;
}
.sync-status {
display: inline-flex; align-items: center; gap: 6px;
font-size: 12px; color: var(--text-dim); white-space: nowrap; margin-left: auto;
}
.sync-dot {
width: 8px; height: 8px; border-radius: 50%;
background-color: var(--accent-blue);
box-shadow: 0 0 0 0 rgba(88, 166, 255, 0.4);
animation: pulse-sync 2s infinite;
}
.sync-status[data-state="live"] .sync-dot { background-color: var(--accent-green); box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.4); }
.sync-status[data-state="error"] .sync-dot { background-color: var(--accent-red); animation: none; }
@keyframes pulse-sync {
0% { box-shadow: 0 0 0 0 currentColor; }
70% { box-shadow: 0 0 0 6px transparent; }
100% { box-shadow: 0 0 0 0 transparent; }
}
/* ==========================================================================
MAIN CONTENT E PROFILO
========================================================================== */
.main-content { flex: 1; padding-bottom: 60px; }
.profile-section {
display: flex; align-items: flex-start; gap: 24px;
padding: 40px 0 32px; border-bottom: 1px solid var(--border-subtle);
margin-bottom: 32px; flex-wrap: wrap;
}
.profile-avatar { flex-shrink: 0; }
.avatar-img {
width: 160px; height: 160px; border-radius: 50%;
border: 2px solid var(--border-default); object-fit: cover;
background-color: var(--bg-surface); transition: opacity 0.3s;
}
.avatar-img.loading { opacity: 0.3; }
.profile-data { flex: 1; min-width: 280px; }
.profile-name { font-size: 26px; font-weight: 700; color: var(--text-main); line-height: 1.2; }
.profile-handle { font-size: 18px; color: var(--text-muted); font-weight: 300; margin-top: 2px; }
.profile-bio { margin-top: 12px; font-size: 15px; color: var(--text-muted); max-width: 600px; line-height: 1.5; }
.profile-stats { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--text-dim); }
.profile-stats strong { color: var(--text-main); font-weight: 600; }
.stat-item { display: inline-flex; align-items: center; gap: 4px; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 13px; color: var(--text-dim); }
.meta-item { display: inline-flex; align-items: center; gap: 6px; }
.btn {
display: inline-flex; align-items: center; gap: 8px;
padding: 6px 14px; font-size: 13px; font-weight: 600;
background-color: var(--bg-card); border: 1px solid var(--border-default);
border-radius: var(--radius-sm); color: var(--text-main); cursor: pointer;
margin-top: 16px; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background-color: #30363d; border-color: var(--text-muted); text-decoration: none; }
/* ==========================================================================
SEZIONI CONTENUTO (REPOS & ISSUES)
========================================================================== */
.content-header {
display: flex; align-items: center; justify-content: space-between; gap: 12px;
margin-bottom: 16px; flex-wrap: wrap;
}
.content-title { font-size: 18px; font-weight: 600; }
.search-input-wrapper { position: relative; flex: 1; max-width: 300px; min-width: 200px; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
.search-input {
width: 100%; padding: 6px 10px 6px 30px; font-size: 13px;
background-color: var(--bg); border: 1px solid var(--border-default);
border-radius: var(--radius-sm); color: var(--text-main); outline: none;
}
.search-input:focus { border-color: var(--accent-blue); }
.search-input::placeholder { color: var(--text-dim); }
.filter-bar {
display: flex; align-items: center; gap: 4px; margin-bottom: 20px; flex-wrap: wrap;
}
.filter-btn {
background: transparent; border: none; color: var(--text-muted);
font-size: 13px; padding: 4px 10px; border-radius: var(--radius-sm); cursor: pointer;
}
.filter-btn:hover { color: var(--text-main); background-color: var(--bg-card); }
.filter-btn.active { color: var(--text-main); background-color: rgba(88, 166, 255, 0.1); }
.sort-select {
margin-left: auto; padding: 4px 8px; font-size: 13px;
background-color: var(--bg); border: 1px solid var(--border-default);
border-radius: var(--radius-sm); color: var(--text-muted); outline: none; cursor: pointer;
}
.sort-select:focus { border-color: var(--accent-blue); }
/* Avvisi ed errori API */
.alert-box {
background-color: rgba(248, 81, 73, 0.1); border: 1px solid rgba(248, 81, 73, 0.4);
padding: 16px; border-radius: var(--radius-md); color: #ffb4a0; font-size: 14px;
margin-bottom: 20px; display: flex; align-items: center; gap: 12px;
}
/* ==========================================================================
CARD GRID E SKELETON
========================================================================== */
.grid-container {
display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
@media (max-width: 860px) { .grid-container { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid-container { grid-template-columns: 1fr; } }
/* Repository Card */
.repo-card {
background-color: var(--bg-surface); border: 1px solid var(--border-default);
border-radius: var(--radius-md); padding: 16px; display: flex; flex-direction: column;
gap: 8px; transition: border-color 0.15s, background 0.15s;
animation: card-enter 0.3s ease-out both;
}
.repo-card:hover { border-color: rgba(88, 166, 255, 0.4); background-color: var(--bg-card); }
.repo-card.highlight { border-color: var(--accent-blue); box-shadow: 0 0 0 1px var(--accent-blue); }
.repo-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.repo-name-box { display: flex; align-items: center; gap: 6px; min-width: 0; }
.repo-name { font-size: 15px; font-weight: 600; color: var(--accent-blue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repo-visibility { font-size: 10px; padding: 0 6px; border: 1px solid var(--border-default); border-radius: 10px; color: var(--text-dim); line-height: 1.6; }
.repo-desc { font-size: 13px; color: var(--text-muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.repo-homepage { display: inline-block; font-size: 12px; color: var(--accent-blue); text-decoration: none; margin-top: 4px; word-break: break-all; }
.repo-homepage:hover { text-decoration: underline; }
.repo-meta-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--text-dim); margin-top: auto; }
.lang-box { display: inline-flex; align-items: center; gap: 4px; }
.lang-dot { width: 10px; height: 10px; border-radius: 50%; }
.stat-box { display: inline-flex; align-items: center; gap: 3px; }
.repo-topics { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.topic-tag { font-size: 11px; padding: 2px 8px; background-color: rgba(88, 166, 255, 0.08); border: 1px solid rgba(88, 166, 255, 0.2); border-radius: 10px; color: var(--accent-blue); }
/* Issue Card */
.issue-card {
background-color: var(--bg-surface); border: 1px solid var(--border-default);
border-radius: var(--radius-md); padding: 12px 16px; display: flex; gap: 10px;
margin-bottom: 8px; transition: border-color 0.15s, background 0.15s;
}
.issue-card:hover { border-color: rgba(88, 166, 255, 0.3); background-color: var(--bg-card); }
.issue-icon { flex-shrink: 0; margin-top: 2px; }
.issue-icon.open { color: var(--accent-green); }
.issue-icon.closed { color: var(--accent-purple); }
.issue-content { flex: 1; min-width: 0; }
.issue-title-area { display: flex; align-items: flex-start; gap: 6px; flex-wrap: wrap; }
.issue-title { font-size: 14px; font-weight: 600; color: var(--text-main); }
.issue-labels { display: flex; gap: 4px; flex-wrap: wrap; }
.issue-label { font-size: 10px; padding: 0 6px; border-radius: 10px; line-height: 1.6; font-weight: 500; }
.issue-details { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.issue-repo { color: var(--accent-blue); font-weight: 500; }
/* Empty e Loading States */
.empty-box { text-align: center; padding: 60px 16px; color: var(--text-dim); font-size: 14px; }
.skeleton-box { height: 120px; background-color: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); position: relative; overflow: hidden; }
.skeleton-box::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(139, 148, 158, 0.08), transparent); animation: shimmer 1.5s infinite; }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes card-enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
/* ==========================================================================
FOOTER E TOAST
========================================================================== */
.site-footer { border-top: 1px solid var(--border-subtle); padding: 20px 0; font-size: 12px; color: var(--text-dim); margin-top: auto; }
.footer-container { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.footer-ver { font-family: var(--font-mono); color: var(--accent-blue); font-weight: 600; }
.footer-clock { font-family: var(--font-mono); color: var(--text-muted); }
.toast-msg {
position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 100px);
background-color: var(--bg-card); border: 1px solid var(--border-default);
border-radius: var(--radius-md); padding: 8px 16px; font-size: 13px;
box-shadow: 0 10px 30px rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.2s, transform 0.2s;
z-index: 1000; pointer-events: none;
}
.toast-msg.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation: none !important; transition: none !important; }
}
</style>
</head>
<body>
<a class="skip-link" href="#main-content">Vai ai contenuti principali</a>
<!-- HEADER -->
<header class="site-header">
<div class="container header-inner">
<a href="https://github.com/PiBOH" target="_blank" class="brand" rel="noopener">
<svg viewBox="0 0 16 16" width="22" height="22" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>
<span>PiBOH</span>
</a>
<div class="nav-tabs" role="navigation" aria-label="Sezioni">
<button class="tab-btn active" data-target="repos-view">Repository <span id="count-repos" class="badge">0</span></button>
<button class="tab-btn" data-target="issues-view">Issues <span id="count-issues" class="badge">0</span></button>
</div>
<div class="sync-status" id="indicator-sync" data-state="syncing" aria-live="polite">
<span class="sync-dot"></span>
<span id="label-sync">Connessione...</span>
</div>
</div>
</header>
<!-- MAIN -->
<main id="main-content" class="main-content container">
<!-- AVVISI API RATE LIMIT -->
<div id="api-alert" class="alert-box" style="display: none;">
<svg viewBox="0 0 16 16" width="20" height="20" fill="currentColor" style="flex-shrink: 0;"><path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.39c.66 1.235-.23 2.813-1.637 2.813H2.012C.605 15.25-.285 13.672.376 12.437zM8 12a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm-.75-7.25v4.5a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-1.5 0z"/></svg>
<span id="api-alert-text">Attenzione: Rate limit pubblico di GitHub superato o errore di rete. Visualizzazione in modalità offline / limitata.</span>
</div>
<!-- PROFILO UTENTE -->
<section class="profile-section" aria-label="Profilo utente GitHub">
<div class="profile-avatar">
<img id="usr-avatar" class="avatar-img" src="https://github.com/PiBOH.png?size=240" alt="Avatar di PiBOH" width="160" height="160">
</div>
<div class="profile-data">
<h1 id="usr-name" class="profile-name">PiBOH</h1>
<p id="usr-login" class="profile-handle">@PiBOH</p>
<p id="usr-bio" class="profile-bio">Acquisizione informazioni dal profilo in corso...</p>
<div class="profile-stats">
<span class="stat-item"><svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M2 5.5a3.5 3.5 0 1 1 5.898 2.549 5.507 5.507 0 0 1 3.034 4.084.75.75 0 1 1-1.482.235 4.001 4.001 0 0 0-7.9 0 .75.75 0 0 1-1.482-.236A5.507 5.507 0 0 1 3.102 8.05 3.49 3.49 0 0 1 2 5.5z"/></svg> <strong id="usr-followers">0</strong> followers</span>
<span>·</span>
<span class="stat-item"><strong id="usr-following">0</strong> following</span>
<span>·</span>
<span class="stat-item"><svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8A2.5 2.5 0 0 1 2 11.5v-9z"/></svg> <strong id="usr-repos">0</strong> repository pubblici</span>
</div>
<div id="usr-meta" class="profile-meta"></div>
<a id="usr-link" class="btn" href="https://github.com/PiBOH" target="_blank" rel="noopener">
<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>
Apri su GitHub
</a>
</div>
</section>
<!-- REPOSITORIES VIEW -->
<section id="repos-view">
<div class="content-header">
<h2 class="content-title">Elenco Repository</h2>
<div class="search-input-wrapper">
<svg class="search-icon" viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M11.5 7a4.499 4.499 0 1 1-8.998 0A4.499 4.499 0 0 1 11.5 7zm-.82 4.74a6 6 0 1 1 1.06-1.06l3.04 3.04a.75.75 0 1 1-1.06 1.06l-3.04-3.04z"/></svg>
<input type="text" id="filter-q-repo" class="search-input" placeholder="Cerca repository per nome o bio...">
</div>
</div>
<div class="filter-bar">
<button class="filter-btn active" data-type="all">Tutti</button>
<button class="filter-btn" data-type="source">Sorgenti originali</button>
<button class="filter-btn" data-type="fork">Fork</button>
<button class="filter-btn" data-type="starred">Starred</button>
<select id="sort-sel-repo" class="sort-select" aria-label="Ordina repository">
<option value="updated">Ultimo aggiornamento</option>
<option value="stars">Stelle (decrescente)</option>
<option value="name">Nome (A-Z)</option>
</select>
</div>
<!-- Contenitore Grid. Mostra subito 6 skeleton predefiniti per garantire un feedback visivo istantaneo -->
<div id="grid-repos" class="grid-container" aria-live="polite">
<div class="skeleton-box"></div>
<div class="skeleton-box"></div>
<div class="skeleton-box"></div>
<div class="skeleton-box"></div>
<div class="skeleton-box"></div>
<div class="skeleton-box"></div>
</div>
<div id="empty-repos" class="empty-box" style="display: none;">
<p>Nessun repository trovato corrispondente ai criteri di ricerca attuali.</p>
</div>
</section>
<!-- ISSUES VIEW -->
<section id="issues-view" style="display: none;">
<div class="content-header">
<h2 class="content-title">Issues dell'utente</h2>
<div class="search-input-wrapper">
<svg class="search-icon" viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M11.5 7a4.499 4.499 0 1 1-8.998 0A4.499 4.499 0 0 1 11.5 7zm-.82 4.74a6 6 0 1 1 1.06-1.06l3.04 3.04a.75.75 0 1 1-1.06 1.06l-3.04-3.04z"/></svg>
<input type="text" id="filter-q-issue" class="search-input" placeholder="Cerca issue...">
</div>
</div>
<div class="filter-bar">
<button class="filter-btn active" data-state="all">Tutte</button>
<button class="filter-btn" data-state="open">Aperte</button>
<button class="filter-btn" data-state="closed">Chiuse</button>
<select id="sort-sel-issue" class="sort-select" aria-label="Ordina issues">
<option value="created">Più recenti</option>
<option value="updated">Ultima modifica</option>
<option value="comments">Più commentate</option>
</select>
</div>
<div id="list-issues" aria-live="polite">
<div class="skeleton-box" style="height: 60px; margin-bottom: 8px;"></div>
<div class="skeleton-box" style="height: 60px; margin-bottom: 8px;"></div>
</div>
<div id="empty-issues" class="empty-box" style="display: none;">
<p>Nessuna issue trovata o ricerca API non disponibile al momento.</p>
</div>
</section>
</main>
<!-- FOOTER -->
<footer class="site-footer">
<div class="container footer-container">
<div>© <span id="current-yr">2026</span> PiBOH · Dati pubblici erogati via GitHub REST API</div>
<div class="footer-ver">Website version 1.0.3a</div>
<div>🕐 Ora locale di PiBOH: <span id="fixed-clock" class="footer-clock">--:--:--</span></div>
<div>Stato sincronizzazione (auto-aggiornamento ogni 120s): <span id="footer-last-sync">In attesa...</span></div>
</div>
</footer>
<!-- NOTIFICA TOAST -->
<div id="app-toast" class="toast-msg" role="status" aria-live="polite"></div>
<!-- ==========================================================================
LOGICA JAVASCRIPT ULTRA-RESILIENTE
========================================================================== -->
<script>
(function() {
"use strict";
// --- IMPOSTAZIONI ---
const TARGET_USER = "PiBOH";
const GITHUB_API_BASE = "https://api.github.com";
const POLLING_INTERVAL_MS = 120000; // 120 secondi per alleggerire il Rate Limit pubblico
// --- REFERENZE DOM ---
const dom = {
avatar: document.getElementById("usr-avatar"),
name: document.getElementById("usr-name"),
login: document.getElementById("usr-login"),
bio: document.getElementById("usr-bio"),
followers: document.getElementById("usr-followers"),
following: document.getElementById("usr-following"),
reposCount: document.getElementById("usr-repos"),
meta: document.getElementById("usr-meta"),
profileLink: document.getElementById("usr-link"),
badgeRepos: document.getElementById("count-repos"),
badgeIssues: document.getElementById("count-issues"),
viewRepos: document.getElementById("repos-view"),
viewIssues: document.getElementById("issues-view"),
gridRepos: document.getElementById("grid-repos"),
emptyRepos: document.getElementById("empty-repos"),
listIssues: document.getElementById("list-issues"),
emptyIssues: document.getElementById("empty-issues"),
searchRepo: document.getElementById("filter-q-repo"),
sortRepo: document.getElementById("sort-sel-repo"),
searchIssue: document.getElementById("filter-q-issue"),
sortIssue: document.getElementById("sort-sel-issue"),
syncIndicator: document.getElementById("indicator-sync"),
syncLabel: document.getElementById("label-sync"),
apiAlertBox: document.getElementById("api-alert"),
apiAlertText: document.getElementById("api-alert-text"),
toast: document.getElementById("app-toast"),
year: document.getElementById("current-yr"),
clock: document.getElementById("fixed-clock"),
lastSyncFooter: document.getElementById("footer-last-sync")
};
// --- STATO APPLICAZIONE ---
let state = {
repos: [],
issues: [],
prevRepoIds: new Set(),
prevIssueIds: new Set(),
avatarUrlMemo: "",
repoFilterType: "all",
repoSortKey: "updated",
repoSearchQuery: "",
issueFilterState: "all",
issueSortKey: "created",
issueSearchQuery: ""
};
// --- PALETTE LINGUAGGI GITHUB UFFICIALE ---
const languageColors = {
JavaScript: "#f1e05a", TypeScript: "#3178c6", Python: "#3572A5", Java: "#b07219",
Go: "#00ADD8", Rust: "#dea584", Ruby: "#701516", PHP: "#4F5D95", Swift: "#F05138",
Kotlin: "#A97BFF", Dart: "#00B4AB", C: "#555555", "C++": "#f34b7d", "C#": "#178600",
HTML: "#e34c26", CSS: "#563d7c", SCSS: "#c6538c", Shell: "#89e051", Vue: "#41b883",
Svelte: "#ff3e00", Dockerfile: "#384d54"
};
// --- FUNZIONI DI SUPPORTO (PULITE E CHIARE) ---
function getLanguageColor(lang) {
return languageColors[lang] || "#8b949e";
}
function isColorLight(hexColor) {
if (!hexColor) return false;
const r = parseInt(hexColor.slice(0, 2), 16);
const g = parseInt(hexColor.slice(2, 4), 16);
const b = parseInt(hexColor.slice(4, 6), 16);
return (r * 299 + g * 587 + b * 114) / 1000 > 155;
}
function formatRelativeTime(dateString) {
if (!dateString) return "";
const diffMs = Date.now() - new Date(dateString).getTime();
const min = 60000, hour = 3600000, day = 86400000, week = 604800000, month = 2592000000;
if (diffMs < min) return "pochi istanti fa";
if (diffMs < hour) return `${Math.round(diffMs / min)} min fa`;
if (diffMs < day) return `${Math.round(diffMs / hour)} ore fa`;
if (diffMs < week) return `${Math.round(diffMs / day)} giorni fa`;
if (diffMs < month) return `${Math.round(diffMs / week)} sett fa`;
return new Date(dateString).toLocaleDateString("it-IT");
}
function formatCompactNumber(num) {
if (num >= 1000000) return (num / 1000000).toFixed(1) + "M";
if (num >= 1000) return (num / 1000).toFixed(1) + "k";
return String(num);
}
function sanitizeHtml(string) {
return String(string).replace(/[&<>"']/g, match => ({
"&": "&", "<": "<", ">": ">", '"': """, "'": "'"
})[match]);
}
let toastTimer = null;
function showToastNotification(message, durationMs = 3500) {
clearTimeout(toastTimer);
dom.toast.textContent = message;
dom.toast.classList.add("show");
toastTimer = setTimeout(() => dom.toast.classList.remove("show"), durationMs);
}
function setSyncIndicator(statusState, labelText) {
dom.syncIndicator.dataset.state = statusState;
dom.syncLabel.textContent = labelText;
}
function triggerApiAlert(errorObj, contextMessage, isCached = false) {
dom.apiAlertBox.style.display = "flex";
let msg = contextMessage;
if (errorObj && errorObj.status === 403) {
if (isCached) {
msg = "Attenzione: Raggiunto il limite massimo di richieste (API Rate Limit GitHub) dal tuo indirizzo IP. Riprova tra un'ora oppure cambia connessione internet (MAX 60 API request per Hour). <b>⚠️ Nota: Il sito non è aggiornato in tempo reale perché hai raggiunto il limite di richieste API, quindi i contenuti visualizzati sono stati recuperati dalla memoria cache.</b>";
} else {
msg = "Attenzione: Raggiunto il limite massimo di richieste (API Rate Limit GitHub) dal tuo indirizzo IP. Riprova tra un'ora oppure cambia connessione internet.<br>(MAX 60 API request per Hour)";
}
} else if (errorObj && errorObj.status === 404) {
msg = `L'utente GitHub "${TARGET_USER}" non è stato trovato.`;
} else if (isCached) {
msg += "<br><br><b>⚠️ Nota: Il sito non è aggiornato in tempo reale. I contenuti visualizzati sono stati recuperati dalla memoria cache.</b>";
}
dom.apiAlertText.innerHTML = msg;
console.warn(`[GitHub Portfolio] Avviso API scatenato:`, errorObj);
}
// --- COMUNICAZIONE API ROBUSTA CON CACHE DI FALLBACK ---
async function fetchJsonRobust(endpointPath) {
const fullUrl = endpointPath.startsWith("http") ? endpointPath : GITHUB_API_BASE + endpointPath;
let cache = null;
try { cache = await caches.open("github-portfolio-v1"); } catch(e) {}
try {
const response = await fetch(fullUrl, {
headers: { "Accept": "application/vnd.github.v3+json" }
});
if (!response.ok) {
const errorObj = new Error(`Richiesta fallita con stato ${response.status}`);
errorObj.status = response.status;
if (cache) {
const cachedRes = await cache.match(fullUrl);
if (cachedRes) {
errorObj.cachedData = await cachedRes.json();
}
}
throw errorObj;
}
if (cache) { cache.put(fullUrl, response.clone()); }
return await response.json();
} catch (networkOrHttpErr) {
if (cache && !networkOrHttpErr.cachedData) {
const cachedRes = await cache.match(fullUrl);
if (cachedRes) {
networkOrHttpErr.cachedData = await cachedRes.json();
}
}
throw networkOrHttpErr;
}
}
// Per ottimizzare ed evitare il blocco per Rate Limit, richiediamo solo la prima pagina per i repo.
// PiBOH e la stragrande maggioranza degli account personali rientrano nei 100 elementi.
async function fetchUserDataRobust() {
return fetchJsonRobust(`/users/${TARGET_USER}`);
}
async function fetchPublicReposRobust() {
return fetchJsonRobust(`/users/${TARGET_USER}/repos?per_page=100&sort=updated`);
}
async function fetchPublicIssuesRobust() {
// La Search API ha limiti ferrei (10 req/min). Gestiamo eventuali fallback in modo elegante
return fetchJsonRobust(`/search/issues?q=author:${TARGET_USER}+is:issue&per_page=100&sort=created&order=desc`);
}
// --- RENDER COMPONENTI ---
function renderUserProfile(userData) {
if (!userData) return;
dom.name.textContent = userData.name || userData.login;
dom.login.textContent = "@" + userData.login;
dom.bio.textContent = userData.bio || "Nessuna biografia inserita dall'utente.";
dom.followers.textContent = formatCompactNumber(userData.followers);
dom.following.textContent = formatCompactNumber(userData.following);
dom.reposCount.textContent = formatCompactNumber(userData.public_repos);
dom.badgeRepos.textContent = formatCompactNumber(userData.public_repos);
dom.profileLink.href = sanitizeHtml(userData.html_url);
// Aggiornamento immagine con preloader per evitare flash bianchi
if (userData.avatar_url && userData.avatar_url !== state.avatarUrlMemo) {
dom.avatar.classList.add("loading");
const preloaderImg = new Image();
preloaderImg.onload = () => {
dom.avatar.src = preloaderImg.src;
dom.avatar.classList.remove("loading");
};
preloaderImg.onerror = () => dom.avatar.classList.remove("loading");
preloaderImg.src = userData.avatar_url + "?size=240";
state.avatarUrlMemo = userData.avatar_url;
}
// Costruzione campi Meta flessibile
let metaBlocks = "";
if (userData.company) {
metaBlocks += `<span class="meta-item"><svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M1.75 16A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0h8.5C11.216 0 12 .784 12 1.75v12.5c0 .085-.006.168-.018.25h2.268a.25.25 0 0 0 .25-.25V8.285a.25.25 0 0 0-.111-.208l-1.055-.703a.75.75 0 1 1 .832-1.248l1.055.703c.487.325.779.871.779 1.456v5.965A1.75 1.75 0 0 1 14.25 16h-3.5a.75.75 0 0 1-.197-.026c-.099.017-.2.026-.303.026h-3a.75.75 0 0 1-.75-.75V14h-1v1.25a.75.75 0 0 1-.75.75h-3Z"/></svg> ${sanitizeHtml(userData.company)}</span>`;
}
if (userData.location) {
metaBlocks += `<span class="meta-item"><svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M8 0a6.5 6.5 0 0 1 4.596 11.596l-3.535 3.536a1.5 1.5 0 0 1-2.122 0l-3.535-3.536A6.5 6.5 0 0 1 8 0Zm0 1.5a5 5 0 0 0-3.536 8.536l3.536 3.536 3.536-3.536A5 5 0 0 0 8 1.5Zm0 3.5a2 2 0 1 1 0 4 2 2 0 0 1 0-4Z"/></svg> ${sanitizeHtml(userData.location)}</span>`;
}
if (userData.blog) {
const blogSafeUrl = userData.blog.startsWith("http") ? userData.blog : "https://" + userData.blog;
metaBlocks += `<span class="meta-item"><svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M7.775 3.275a.75.75 0 0 0 1.06 1.06l1.25-1.25a2 2 0 1 1 2.83 2.83l-2.5 2.5a2 2 0 0 1-2.83 0 .75.75 0 0 0-1.06 1.06 3.5 3.5 0 0 0 4.95 0l2.5-2.5a3.5 3.5 0 0 0-4.95-4.95l-1.25 1.25Z"/></svg> <a href="${sanitizeHtml(blogSafeUrl)}" target="_blank" rel="noopener">${sanitizeHtml(userData.blog)}</a></span>`;
}
if (userData.twitter_username) {
metaBlocks += `<span class="meta-item"><svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M12.6.75h2.454l-5.36 6.142L16 15.25h-4.937l-3.867-5.07-4.425 5.07H.316l5.733-6.57L0 .75h5.063l3.495 4.633L12.601.75Z"/></svg> <a href="https://twitter.com/${sanitizeHtml(userData.twitter_username)}" target="_blank" rel="noopener">@${sanitizeHtml(userData.twitter_username)}</a></span>`;
}
dom.meta.innerHTML = metaBlocks;
}
function generateRepositoryCardDom(repoObj) {
const cardEl = document.createElement("article");
cardEl.className = "repo-card";
cardEl.dataset.repoId = repoObj.id;
const isFork = repoObj.fork;
const iconSvg = isFork
? `<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor" style="color: var(--text-dim);"><path d="M5 3.25a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Z"/></svg>`
: `<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor" style="color: var(--text-dim);"><path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 1 1 0-1.5h1.75v-2h-8A2.5 2.5 0 0 1 2 11.5v-9Z"/></svg>`;
const languageBlock = repoObj.language
? `<span class="lang-box"><span class="lang-dot" style="background-color: ${getLanguageColor(repoObj.language)};"></span>${sanitizeHtml(repoObj.language)}</span>`
: "";
const topicsBlock = (repoObj.topics && repoObj.topics.length > 0)
? `<div class="repo-topics">${repoObj.topics.map(t => `<span class="topic-tag">${sanitizeHtml(t)}</span>`).join("")}</div>`
: "";
cardEl.innerHTML = `
<div class="repo-header">
<div class="repo-name-box">
${iconSvg}
<a href="${sanitizeHtml(repoObj.html_url)}" target="_blank" rel="noopener" class="repo-name">${sanitizeHtml(repoObj.name)}</a>
</div>
<span class="repo-visibility">${repoObj.private ? "Private" : "Public"}</span>
</div>
${repoObj.description ? `<p class="repo-desc">${sanitizeHtml(repoObj.description)}</p>` : ""}
${repoObj.homepage ? `<a href="${sanitizeHtml(repoObj.homepage)}" target="_blank" rel="noopener" class="repo-homepage"><svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor" style="vertical-align: middle; margin-right: 4px;"><path d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"/></svg>${sanitizeHtml(repoObj.homepage)}</a>` : ""}
<div class="repo-meta-footer">
${languageBlock}
${repoObj.stargazers_count ? `<span class="stat-box"><svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Z"/></svg> ${formatCompactNumber(repoObj.stargazers_count)}</span>` : ""}
${repoObj.forks_count ? `<span class="stat-box"><svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M5 3.25a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Z"/></svg> ${formatCompactNumber(repoObj.forks_count)}</span>` : ""}
<span>${formatRelativeTime(repoObj.updated_at)}</span>
</div>
${topicsBlock}
`;
return cardEl;
}
function renderFilteredRepositories() {
let filteredList = [...state.repos];
// Filtraggio per Tipo
if (state.repoFilterType === "source") {
filteredList = filteredList.filter(item => !item.fork);
} else if (state.repoFilterType === "fork") {
filteredList = filteredList.filter(item => item.fork);
} else if (state.repoFilterType === "starred") {
filteredList = filteredList.filter(item => (item.stargazers_count || 0) > 0);
}
// Filtraggio testuale
if (state.repoSearchQuery) {
const q = state.repoSearchQuery.toLowerCase();
filteredList = filteredList.filter(item =>
String(item.name).toLowerCase().includes(q) ||
(item.description && String(item.description).toLowerCase().includes(q))
);
}
// Ordinamento
if (state.repoSortKey === "stars") {
filteredList.sort((a, b) => (b.stargazers_count || 0) - (a.stargazers_count || 0));
} else if (state.repoSortKey === "name") {
filteredList.sort((a, b) => String(a.name).localeCompare(String(b.name)));
} else {
// predefinito: last updated
filteredList.sort((a, b) => new Date(b.updated_at || 0).getTime() - new Date(a.updated_at || 0).getTime());
}
dom.gridRepos.innerHTML = "";
if (filteredList.length === 0) {
dom.emptyRepos.style.display = "block";
} else {
dom.emptyRepos.style.display = "none";
filteredList.forEach(repoObj => {
dom.gridRepos.appendChild(generateRepositoryCardDom(repoObj));
});
}
}
function generateIssueCardDom(issueObj) {
const issueEl = document.createElement("article");
issueEl.className = "issue-card";
const isOpen = issueObj.state === "open";
const iconSvgDom = isOpen
? `<svg class="issue-icon open" viewBox="0 0 16 16" width="16" height="16" fill="currentColor"><path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"/><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0Z"/></svg>`
: `<svg class="issue-icon closed" viewBox="0 0 16 16" width="16" height="16" fill="currentColor"><path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"/></svg>`;
const repoContextName = issueObj.repository_url ? issueObj.repository_url.split("/").slice(-2).join("/") : "";
let labelsDomString = "";
if (issueObj.labels && issueObj.labels.length > 0) {
labelsDomString = `<div class="issue-labels">${issueObj.labels.map(lbl => {
const bgColor = lbl.color ? "#" + lbl.color : "#8b949e";
const fgColor = isColorLight(lbl.color) ? "#24292f" : "#ffffff";
return `<span class="issue-label" style="background-color: ${bgColor}; color: ${fgColor};">${sanitizeHtml(lbl.name)}</span>`;
}).join("")}</div>`;
}
issueEl.innerHTML = `
${iconSvgDom}
<div class="issue-content">
<div class="issue-title-area">
<a href="${sanitizeHtml(issueObj.html_url)}" target="_blank" rel="noopener" class="issue-title">${sanitizeHtml(issueObj.title)}</a>
${labelsDomString}
</div>
<div class="issue-details">
<a href="${sanitizeHtml((issueObj.repository_url || "").replace("api.github.com/repos", "github.com"))}" target="_blank" rel="noopener" class="issue-repo">${sanitizeHtml(repoContextName)}</a>
<span>#${issueObj.number}</span>
<span>${isOpen ? "Aperta" : "Chiusa"} ${formatRelativeTime(isOpen ? issueObj.created_at : issueObj.closed_at)}</span>
${issueObj.comments ? `<span><svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor" style="margin-right:2px;"><path d="M1 2.75A.75.75 0 0 1 1.75 2h12.5a.75.75 0 1 1 0 1.5H1.75A.75.75 0 0 1 1 2.75Z"/></svg>${issueObj.comments}</span>` : ""}
</div>
</div>
`;
return issueEl;
}
function renderFilteredIssues() {
let filteredIssues = [...state.issues];
if (state.issueFilterState === "open") {
filteredIssues = filteredIssues.filter(item => item.state === "open");
} else if (state.issueFilterState === "closed") {
filteredIssues = filteredIssues.filter(item => item.state === "closed");
}
if (state.issueSearchQuery) {
const qText = state.issueSearchQuery.toLowerCase();
filteredIssues = filteredIssues.filter(item =>
String(item.title).toLowerCase().includes(qText) ||
(item.body && String(item.body).toLowerCase().includes(qText))
);
}
if (state.issueSortKey === "updated") {
filteredIssues.sort((a, b) => new Date(b.updated_at || 0).getTime() - new Date(a.updated_at || 0).getTime());
} else if (state.issueSortKey === "comments") {
filteredIssues.sort((a, b) => (b.comments || 0) - (a.comments || 0));
} else {
// predefinito: created
filteredIssues.sort((a, b) => new Date(b.created_at || 0).getTime() - new Date(a.created_at || 0).getTime());
}
dom.listIssues.innerHTML = "";
if (filteredIssues.length === 0) {
dom.emptyIssues.style.display = "block";
} else {
dom.emptyIssues.style.display = "none";
filteredIssues.forEach(issueObj => {
dom.listIssues.appendChild(generateIssueCardDom(issueObj));
});
}
}
// --- MOTORE DI SINCRONIZZAZIONE GLOBALE ---
async function synchronizeEntirePortfolio() {
setSyncIndicator("syncing", "Sincronizzazione in corso...");
dom.apiAlertBox.style.display = "none"; // ripulisci avvisi precedenti
let isUsingCacheFallback = false;
try {
// 1. Carica Utente
let userData = null;
try {
userData = await fetchUserDataRobust();
renderUserProfile(userData);
} catch (err) {
if (err.cachedData) {
isUsingCacheFallback = true;
triggerApiAlert(err, "Impossibile recuperare il profilo utente in tempo reale.", true);
setSyncIndicator("error", "Modalità Cache");
renderUserProfile(err.cachedData);
} else {
triggerApiAlert(err, "Impossibile recuperare il profilo utente. Riprova più tardi.");
setSyncIndicator("error", "Errore Rete/API");
return; // Interrompe il flusso principale se non c'è nemmeno la cache
}
}
// 2. Carica Repository
try {
const reposDataList = await fetchPublicReposRobust();
if (reposDataList && Array.isArray(reposDataList)) {
const currentFetchedIds = new Set(reposDataList.map(item => item.id));
if (state.prevRepoIds.size > 0) {
const addedRepos = reposDataList.filter(r => !state.prevRepoIds.has(r.id));
if (addedRepos.length > 0) showToastNotification(`🆕 Aggiunto repository: ${addedRepos[0].name}`);
}
state.prevRepoIds = currentFetchedIds;
state.repos = reposDataList;
dom.badgeRepos.textContent = formatCompactNumber(reposDataList.length);
renderFilteredRepositories();
}
} catch (repoErr) {
if (repoErr.cachedData && Array.isArray(repoErr.cachedData)) {
isUsingCacheFallback = true;
triggerApiAlert(repoErr, "Impossibile recuperare l'elenco dei repository in tempo reale.", true);
setSyncIndicator("error", "Modalità Cache");
state.repos = repoErr.cachedData;
dom.badgeRepos.textContent = formatCompactNumber(repoErr.cachedData.length);
renderFilteredRepositories();
} else {
triggerApiAlert(repoErr, "Impossibile recuperare l'elenco dei repository.");
}
}
// 3. Carica Issues
try {
const issuesResponseContainer = await fetchPublicIssuesRobust();
const issuesDataList = (issuesResponseContainer && issuesResponseContainer.items) ? issuesResponseContainer.items : [];
const currentFetchedIssueIds = new Set(issuesDataList.map(item => item.id));
if (state.prevIssueIds.size > 0) {
const addedIssues = issuesDataList.filter(iss => !state.prevIssueIds.has(iss.id));
if (addedIssues.length > 0) showToastNotification(`🆕 Nuova Issue rilevata: #${addedIssues[0].number}`);
}
state.prevIssueIds = currentFetchedIssueIds;
state.issues = issuesDataList;
dom.badgeIssues.textContent = formatCompactNumber(issuesDataList.length);
if (dom.viewIssues.style.display !== "none") {
renderFilteredIssues();
}
} catch (issueErr) {
if (issueErr.cachedData && issueErr.cachedData.items) {
isUsingCacheFallback = true;
triggerApiAlert(issueErr, "Impossibile recuperare le issue in tempo reale.", true);
setSyncIndicator("error", "Modalità Cache");
state.issues = issueErr.cachedData.items;
dom.badgeIssues.textContent = formatCompactNumber(issueErr.cachedData.items.length);
if (dom.viewIssues.style.display !== "none") {
renderFilteredIssues();
}
} else {
console.warn("[GitHub Portfolio] Limitazione API sulla ricerca Issues riscontrata.", issueErr);
dom.emptyIssues.style.display = "block";
dom.emptyIssues.innerHTML = "<p>Risultati issues non disponibili al momento per restrizioni di rate limit temporaneo.</p>";
dom.listIssues.innerHTML = "";
}
}
// Conclusione
const timestampString = new Date().toLocaleTimeString("it-IT", { timeZone: "Europe/Rome" });
if (isUsingCacheFallback) {
dom.lastSyncFooter.textContent = `Memoria Cache (ultimo accesso prima del blocco)`;
} else {
dom.lastSyncFooter.textContent = `Avvenuta con successo alle ${timestampString}`;
setSyncIndicator("live", "Sistema Allineato");
}
} catch (criticalFailure) {
console.error("[GitHub Portfolio] Collasso totale della sincronizzazione:", criticalFailure);
setSyncIndicator("error", "Fallimento Generale");
triggerApiAlert(criticalFailure, "Un errore inaspettato impedisce di mostrare correttamente i contenuti.");
}
}
// --- OROLOGIO INTERNO DI ROMA ---
function updateFixedRomaClock() {
const now = new Date();
const formatter = new Intl.DateTimeFormat("it-IT", {
timeZone: "Europe/Rome",
weekday: "short", day: "2-digit", month: "short", year: "numeric",
hour: "2-digit", minute: "2-digit", second: "2-digit",
hour12: false
});
dom.clock.textContent = formatter.format(now);
}
// --- GESTIONE DEGLI EVENTI UTENTE ---
function setupEventListeners() {
// Navigazione tra tab
const tabButtons = document.querySelectorAll(".tab-btn");
tabButtons.forEach(btnEl => {
btnEl.addEventListener("click", () => {
tabButtons.forEach(x => x.classList.remove("active"));
btnEl.classList.add("active");
const targetViewId = btnEl.dataset.target;
if (targetViewId === "repos-view") {
dom.viewRepos.style.display = "block";
dom.viewIssues.style.display = "none";
} else {
dom.viewRepos.style.display = "none";
dom.viewIssues.style.display = "block";
renderFilteredIssues(); // Esegue rendering sul momento per garanzia
}
});
});
// Filtri e ricerca Repository
let searchTimerRepo = null;
dom.searchRepo.addEventListener("input", () => {
clearTimeout(searchTimerRepo);
searchTimerRepo = setTimeout(() => {
state.repoSearchQuery = dom.searchRepo.value.trim();
renderFilteredRepositories();
}, 200);
});
const filterBtnsRepo = dom.viewRepos.querySelectorAll(".filter-btn");
filterBtnsRepo.forEach(btnEl => {
btnEl.addEventListener("click", () => {
filterBtnsRepo.forEach(x => x.classList.remove("active"));
btnEl.classList.add("active");
state.repoFilterType = btnEl.dataset.type;
renderFilteredRepositories();
});
});
dom.sortRepo.addEventListener("change", () => {
state.repoSortKey = dom.sortRepo.value;
renderFilteredRepositories();
});
// Filtri e ricerca Issues
let searchTimerIssue = null;
dom.searchIssue.addEventListener("input", () => {
clearTimeout(searchTimerIssue);
searchTimerIssue = setTimeout(() => {
state.issueSearchQuery = dom.searchIssue.value.trim();
renderFilteredIssues();
}, 200);
});
const filterBtnsIssue = dom.viewIssues.querySelectorAll(".filter-btn");
filterBtnsIssue.forEach(btnEl => {
btnEl.addEventListener("click", () => {
filterBtnsIssue.forEach(x => x.classList.remove("active"));
btnEl.classList.add("active");
state.issueFilterState = btnEl.dataset.state;
renderFilteredIssues();
});
});