Repository navigation
Expand file tree
/
Copy pathchangelog-loader.js
More file actions
704 lines (639 loc) · 24.9 KB
/
Copy pathchangelog-loader.js
File metadata and controls
704 lines (639 loc) · 24.9 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
// ===================================
// CONFIGURAZIONE DEL POST IN EVIDENZA
// ===================================
// Qui puoi scegliere quale post in evidenzia mostrare in homepage.
window.featuredPostConfig = {
file: 'Voidblock/7.3.0/je-26.1.2-26.3-7.3.2_stable.md',
description: 'Il Wilderness Bound Drop è arrivato: esplora le tre nuove isole autunnali, con tanti blocchi decorativi, un nuovo letto esplorativo e i cuscini, dove finalmente ti puoi sedere in Minecraft!!!'
};
// ===================================
// LISTA DEI CHANGELOG DISPONIBILI
// ===================================
// Ogni oggetto rappresenta un post o un changelog che può essere visualizzato nella griglia e nella homepage.
window.changelogList = [
// Post Rilasciati
{
title: 'JE-26.1.2>26.3-7.3.2-Voidblock:7.3.2',
date: '17.10.2026',
image: 'images/posts/Voidblock/7.3.0/je-26.1.2-26.3-7.3.2_rc1.png',
file: 'Voidblock/7.3.0/je-26.1.2-26.3-7.3.2_stable.md',
tags: ['stable'],
visible: true
},
{
title: 'JE-26.1.2>26.3-7.3.2-Voidblock:RELEASE_CANDIDATE-1',
date: '10.10.2026',
image: 'images/posts/Voidblock/7.3.0/je-26.1.2-26.3-7.3.2_rc1.png',
file: 'Voidblock/7.3.0/je-26.1.2-26.3-7.3.2_rc1.md',
tags: ['release-candidate'],
visible: true
},
{
title: 'JE-26.2-7.3.1-Voidblock:7.3.1',
date: '21.07.2026',
image: 'images/posts/Voidblock/7.3.0/je-26.1-26.2-7.3.1_rc1.png',
file: 'Voidblock/7.3.0/je-26.1-26.2-7.3.1_stable.md',
tags: ['stable'],
visible: true
},
{
title: 'JE-26.2-7.3.1-Voidblock:RELEASE_CANDIDATE-1',
date: '15.07.2026',
image: 'images/posts/Voidblock/7.3.0/je-26.1-26.2-7.3.1_rc1.png',
file: 'Voidblock/7.3.0/je-26.1-26.2-7.3.1_rc1.md',
tags: ['release-candidate'],
visible: true
},
{
title: 'JE-26.1-7.3.0-Voidblock:7.3.0',
date: '24.03.2026',
image: 'images/posts/Voidblock/7.3.0/je-26.1-7.3.0_stable.png',
file: 'Voidblock/7.3.0/je-26.1-7.3.0_stable.md',
tags: ['stable'],
visible: true
},
{
title: 'JE-26.1-7.3.0-Voidblock:RELEASE_CANDIDATE-1',
date: '19.03.2026',
image: 'images/posts/Voidblock/7.3.0/je-26.1-7.3.0_pre1.png',
file: 'Voidblock/7.3.0/je-26.1-7.3.0_rc1.md',
tags: ['release-candidate'],
visible: true
},
{
title: 'JE-26.1-7.3.0-Voidblock:PRE_RELEASE-1',
date: '24.02.2026',
image: 'images/posts/Voidblock/7.3.0/je-26.1-7.3.0_pre1.png',
file: 'Voidblock/7.3.0/je-26.1-7.3.0_pre1.md',
tags: ['pre-release'],
visible: true
},
{
title: 'JE-1.21>1.21.11-7.2.X-Voidblock:7.2.0',
date: '10.01.2026',
image: 'images/posts/Voidblock/7.2.X_LTS/je-1.21.11-7.2.0_rc1.png',
file: 'Voidblock/7.2.X_LTS/je-1.21.11-7.2.0_stable.md',
tags: ['lts','stable','maintenance'],
visible: true
},
{
title: 'JE-1.21>1.21.11-7.2.0-Voidblock:RELEASE_CANDIDATE-1_LTS',
date: '03.01.2026',
image: 'images/posts/Voidblock/7.2.X_LTS/je-1.21.11-7.2.0_rc1.png',
file: 'Voidblock/7.2.X_LTS/je-1.21.11-7.2.0_rc1.md',
tags: ['release-candidate'],
visible: true
},
{
title: 'Roadmap e Cambio di Versioni di Minecraft',
date: '23.12.2025',
image: 'images/posts/Website/new-versions-mc.jpg',
file: 'Website/minecraft-versions-system.md',
tags: ['minecraft-news'],
visible: true
},
{
title: 'JE-1.21>1.21.10-7.1.0-Voidblock:7.1.0',
date: '22.11.2025',
image: 'images/posts/Voidblock/7.1.0/je-1.21.10-7.1.0_rc1.png',
file: 'Voidblock/7.1.0/je-1.21.10-7.1.0_stable.md',
tags: ['stable'],
visible: true
},
{
title: 'JE-1.21>1.21.10-7.1.0-Voidblock:RELEASE_CANDIDATE-1',
date: '12.11.2025',
image: 'images/posts/Voidblock/7.1.0/je-1.21.10-7.1.0_rc1.png',
file: 'Voidblock/7.1.0/je-1.21.10-7.1.0_rc1.md',
tags: ['release-candidate'],
visible: true
},
{
title: 'JE-1.21>1.21.10-7.1.0-Voidblock:PRE_RELEASE-1',
date: '25.10.2025',
image: 'images/posts/Voidblock/7.1.0/je-1.21.10-7.1.0_pre1.png',
file: 'Voidblock/7.1.0/je-1.21.10-7.1.0_pre1.md',
tags: ['pre-release'],
visible: true
},
{
title: 'JE-1.21>1.21.10-7.1.0-Voidblock:BUILDING:07.10.2025a',
date: '07.10.2025',
image: 'images/posts/Voidblock/7.1.0/je-1.21.9-7.1.0_dev1.png',
file: 'Voidblock/7.1.0/je-1.21.9-7.1.0_dev1.md',
tags: ['building'],
visible: true
},
{
title: 'JE-1.21>1.21.9-7.1.0-Voidblock:BUILDING:19.09.2025a',
date: '19.09.2025',
image: 'images/posts/Voidblock/7.1.0/je-1.21.9-7.1.0_dev0.png',
file: 'Voidblock/7.1.0/je-1.21.9-7.1.0_dev0.md',
tags: ['building'],
visible: true,
maintenanceVersions: [
{
version: 'JE-1.21>1.21.9-7.1.0-Voidblock:BUILDING:19.09.2025b',
date: '19.09.2025',
file: 'Voidblock/7.1.0/je-1.21.9-7.1.0_dev0b.md',
visible: true
}
],
useCorrectiveStyle: true
},
{
title: 'JE-1.21>1.21.9-7.0.3-Voidblock:7.0.3',
date: '06.09.2025',
image: 'images/posts/Voidblock/7.0.0/je-1.21-1.21.5_7.0.1_stable.png',
file: 'Voidblock/7.0.0/je-1.21-1.21.5_7.0.3_stable.md',
tags: ['stable','maintenance'],
visible: true
},
{
title: 'JE-1.21>1.21.9-7.0.2-Voidblock:7.0.2',
date: '14.08.2025',
image: 'images/posts/Voidblock/7.0.0/je-1.21-1.21.5_7.0.1_stable.png',
file: 'Voidblock/7.0.0/je-1.21-1.21.5_7.0.2_stable.md',
tags: ['stable','maintenance'],
visible: true
},
{
title: 'JE-1.21>1.21.5-7.0.1-Voidblock:7.0.1',
date: '09.07.2025',
image: 'images/posts/Voidblock/7.0.0/je-1.21-1.21.5_7.0.1_stable.png',
file: 'Voidblock/7.0.0/je-1.21-1.21.5_7.0.1_stable.md',
tags: ['stable','maintenance'],
visible: true
},
{
title: 'JE-1.21>1.21.5-7.0.0-Voidblock:7.0.0',
date: '30.06.2025',
image: 'images/posts/Voidblock/Logo Voidblock 7.0.0.png',
file: 'Voidblock/7.0.0/je-1.21-1.21.5_7.0.0_stable.md',
tags: ['stable'],
visible: true
},
{
title: 'JE-1.21>1.21.5-7.0.0-Voidblock:RELEASE_CANDIDATE 2',
date: '16.06.2025',
image: 'images/posts/Voidblock/Logo Voidblock 7.0.0.png',
file: 'Voidblock/7.0.0/je-1.21-1.21.5_7.0.0_rc2.md',
tags: ['release-candidate'],
visible: true
},
{
title: 'JE-1.21>1.21.5-7.0.0-Voidblock:RELEASE_CANDIDATE 1',
date: '27.05.2025',
image: 'images/posts/Voidblock/Logo Voidblock 7.0.0.png',
file: 'Voidblock/7.0.0/je-1.21-1.21.5_7.0.0_rc1.md',
tags: ['release-candidate'],
visible: true
},
{
title: 'JE-1.21>1.21.5-7.0.0-Voidblock:PRE-RELEASE 1',
date: '20.05.2025',
image: 'images/posts/Voidblock/7.0.0/je-1.21-1.21.5_7.0.0_pre1.png',
file: 'Voidblock/7.0.0/je-1.21-1.21.5_7.0.0_pre1.md',
tags: ['pre-release'],
visible: true
},
{
title: 'JE-1.21>1.21.5-7.0.0-Voidblock:BUILDING:29.04.2025a',
date: '29.04.2025',
image: 'images/posts/Voidblock/7.0.0/je-1.21-1.21.5-7.0.0_dev1.png',
file: 'Voidblock/7.0.0/je-1.21-1.21.5-7.0.0_dev1.md',
tags: ['building'],
visible: true
},
{
title: 'JE-1.21>1.21.5-7.0.0-Voidblock:BUILDING:23.04.2025a',
date: '23.04.2025',
image: 'images/posts/Voidblock/7.0.0/je-1.21-1.21.5-7.0.0_dev0.png',
file: 'Voidblock/7.0.0/je-1.21-1.21.5-7.0.0_dev0.md',
tags: ['building'],
visible: true
},
{
title: 'JE-1.21>1.21.4-6.1.0-Skyblock_Classic_Edition:6.1.0',
date: '15.04.2025',
image: 'images/posts/Voidblock/6.1.0/je-1.21.4-6.1.0_pre1.png',
file: 'Voidblock/6.1.0/je-1.21.4-6.1.0_stable.md',
tags: ['stable'],
visible: true
},
{
title: 'JE-1.21>1.21.4-6.1.0-Skyblock_Classic_Edition:PRE-RELEASE 1',
date: '29.03.2025',
image: 'images/posts/Voidblock/6.1.0/je-1.21.4-6.1.0_pre1.png',
file: 'Voidblock/6.1.0/je-1.21.4-6.1.0_pre1.md',
tags: ['pre-release'],
visible: true
},
{
title: 'Nuova Era!',
date: '24.03.2025',
image: 'images/posts/Website/welcome!.png',
file: 'Website/benvenuti.md',
tags: ['website','minecraft-news'],
visible: true
},
{
title: 'Migrazione al Nuovo Sito Web',
date: '24.03.2025',
image: 'images/posts/Website/alba.png',
file: 'Website/migrazione.md',
tags: ['website'],
visible: true
},
{
title: 'JE-1.21>1.21.4-6.1.0-Skyblock_Classic_Edition:BUILDING:22.02.2025a',
date: '22.02.2025',
image: 'images/posts/Voidblock/6.1.0/je-1.21.4-6.1.0_dev0.png',
file: 'Voidblock/6.1.0/je-1.21.4-6.1.0_dev0.md',
tags: ['building'],
visible: true
},
{
title: 'JE-1.21/1.21.1-6.0.0-Skyblock_Classic_Edition:6.0.0',
date: '12.01.2025',
image: 'images/posts/Voidblock/6.0.0/je-1.21-1.21.1-6.0.0_stable.png',
file: 'Voidblock/6.0.0/je-1.21-1.21.1-6.0.0_stable.md',
tags: ['stable'],
visible: true
},
{
title: 'JE-1.21/1.21.1-6.0.0-Skyblock_Classic_Edition:RELEASE-CANDIDATE-2',
date: '12.01.2025',
image: 'images/posts/Voidblock/6.0.0/je-1.21-1.21.1-6.0.0_stable.png',
file: 'Voidblock/6.0.0/je-1.21-1.21.1-6.0.0_rc2.md',
tags: ['release-candidate'],
visible: true
},
{
title: 'JE-1.20.6-5.3.X-Skyblock_Classic_Edition:5.3.0_LTS Maintenance Update - LTS',
date: '27.09.2024',
image: 'images/posts/Voidblock/5.3.X_LTS/je-1.20.6-5.3.0_LTS_stable.png',
file: 'Voidblock/5.3.X_LTS/je-1.20.6-5.3.0_LTS_stable.md',
tags: ['lts','stable','maintenance'],
visible: true,
maintenanceVersions: [
{
version: '5.3.1_LTS',
date: '29.12.2024',
file: 'Voidblock/5.3.X_LTS/je-1.20.6-5.3.1_LTS.md',
visible: true
},
{
version: '5.3.2_LTS',
date: '29.07.2025',
file: 'Voidblock/5.3.X_LTS/je-1.20.6-5.3.2_LTS.md',
visible: true
}
]
},
// Post in Lavorazione (drafts)
{
title: 'JE-1.20.6-1.0.0-Edge:BUILDING:23.10.2024a - Draft',
date: '???',
image: 'images/drafts/draft.png',
file: 'Edge/je-1.20.6-1.0.0_dev0.md',
tags: ['building','drafts'],
visible: false
},
{
title: 'JE-1.17.1-1.0.0-Apocalisse:BUILDING:16.10.2022a - Draft',
date: '???',
image: 'images/posts/Apocalisse/first.png',
file: 'Apocalisse/je-1.17.1-1.0.0_dev0.md',
tags: ['building','drafts'],
visible: false
},
{
title: 'JE-1.20.4-Dimension_Infinity:BUILDING:12.12.2023a - Draft',
date: '???',
image: 'images/drafts/draft.png',
file: 'Dimension_Infinity/je-1.20.6-1.0.0_dev0.md',
tags: ['building','drafts'],
visible: false
},
{
title: 'JE-1.20.2-Dungeoncraft:BUILDING:30.08.2023a - Draft',
date: '???',
image: 'images/drafts/draft.png',
file: 'Dungeoncraft/je-1.20.6-1.0.0_dev0.md',
tags: ['building','drafts'],
visible: false
},
{
title: 'JE-1.19.4-Infernicus:BUILDING:18.10.2023a - Draft',
date: '???',
image: 'images/drafts/draft.png',
file: 'Infernicus/je-1.19.4-1.0.0_dev0.md',
tags: ['building','drafts'],
visible: false
},
{
title: 'JE-1.19.4-BowShot:BUILDING:07.03.2023a - Draft',
date: '???',
image: 'images/drafts/draft.png',
file: 'BowShot/je-1.19.4-1.0.0_dev0.md',
tags: ['building','drafts'],
visible: false
},
// Drafts Template
{
title: 'Draft',
date: '???',
image: 'images/drafts/draft.png',
file: 'draft.md',
tags: ['drafts'],
visible: false
},
// Changelog Template
{
file: 'changelog-template.md', // Nome del file markdown
date: '03.10.2000', // Formato data
title: 'Changelog Template', // Titolo visualizzato
image: 'images/posts/changelog.png', // URL immagine
tags: ['lts','stable','maintenance','release-candidate','pre-release','building','website','minecraft-news','changelog-doc','drafts'], // Aggiunti i tag
visible: true,
maintenanceVersions: [
{
version: 'Test Changelog',
date: '04.10.2000',
file: 'drafts/test.md',
visible: false
}
],
useCorrectiveStyle: true
}
];
// ===================================
// CARICAMENTO DELLA LISTA DEI CHANGELOG
// ===================================
// Questa funzione inizializza la homepage: carica la griglia, imposta i filtri e mostra il post in evidenza.
function loadChangelogList() {
const changelogGrid = document.getElementById('changelog-grid');
if (!changelogGrid) return;
changelogGrid.innerHTML = ''; // Pulisci la griglia
// Filtra i changelog visibili
const visibleChangelogs = getVisibleChangelogs();
// Crea una card per ogni changelog visibile
visibleChangelogs.forEach(changelog => {
const card = createChangelogCard(changelog);
changelogGrid.appendChild(card);
});
// Inizializza i filtri tag
initializeTagFilters();
// Genera il calendario
generateChangelogCalendar();
// Mostra il post in evidenza nella homepage
renderFeaturedPost();
}
// ===================================
// FUNZIONI DI UTILITÀ
// ===================================
// Funzione per troncare il testo in modo pulito nelle card.
function truncateText(text, maxLength = 60) {
if (text.length <= maxLength) return text;
return text.substring(0, maxLength - 3) + '...';
}
function getVisibleChangelogs() {
return window.changelogList.filter(changelog => changelog.visible);
}
// Funzione per trovare il changelog da mostrare come post in evidenza nella homepage.
function getFeaturedChangelog() {
const targetFile = window.featuredPostConfig?.file;
const visibleChangelogs = getVisibleChangelogs();
if (targetFile) {
const directMatch = visibleChangelogs.find(changelog => changelog.file === targetFile);
if (directMatch) return directMatch;
}
return visibleChangelogs.find(changelog => changelog.file && changelog.file !== 'changelog-template.md') || null;
}
// Funzione per costruire il blocco del post in evidenza nella homepage.
function renderFeaturedPost() {
const container = document.getElementById('featured-post-section');
if (!container) return;
const featured = getFeaturedChangelog();
if (!featured) {
container.innerHTML = '';
return;
}
const defaultImage = 'https://placehold.co/600x400/1a1a1a/ffffff/png?text=No+Image';
const tagsHtml = featured.tags ?
`<div class="featured-post-tags">
${featured.tags.slice(0, 4).map(tag => `<span class="tag ${tag}">${tag}</span>`).join('')}
</div>` : '';
container.innerHTML = `
<a class="featured-post-card" href="view-changelog.html?file=${featured.file}">
<div class="featured-badge">Ultima versione disponibile</div>
<div class="featured-post-content">
<div class="featured-post-image">
<img src="${featured.image || defaultImage}" alt="${featured.title}" onerror="this.src='${defaultImage}'">
</div>
<div class="featured-post-info">
<h3>${featured.title}</h3>
<p class="featured-post-date">📅 ${featured.date}</p>
<p class="featured-post-description">${window.featuredPostConfig?.description || ''}</p>
${tagsHtml}
<p class="featured-post-cta">Clicca qui per vedere il changelog completo.</p>
</div>
</div>
</a>
`;
}
// ===================================
// CREAZIONE DELLE CARD DEI CHANGELOG
// ===================================
// Funzione per creare una singola card del changelog nella griglia principale.
function createChangelogCard(changelog) {
const card = document.createElement('a');
card.href = `view-changelog.html?file=${changelog.file}`; // Link alla pagina del changelog
card.className = 'changelog-card';
const defaultImage = 'https://placehold.co/600x400/1a1a1a/ffffff/png?text=No+Image';
// Limita i tag mostrati a 3 e aggiungi un indicatore se ce ne sono di più
const tagsHtml = changelog.tags ?
`<div class="changelog-tags">
${changelog.tags.slice(0, 3).map(tag => `<span class="tag ${tag}">${tag}</span>`).join('')}
${changelog.tags.length > 3 ? `<span class="tag more-tags">+${changelog.tags.length - 3}</span>` : ''}
</div>` : '';
// Limita le versioni di manutenzione mostrate a 2 e aggiungi un indicatore se ce ne sono di più
let maintenanceHtml = '';
if (changelog.maintenanceVersions && changelog.maintenanceVersions.length > 0) {
const versionsToShow = changelog.maintenanceVersions.slice(0, 2);
const headerText = changelog.useCorrectiveStyle ? 'Versioni Correttive:' : 'Versioni di Manutenzione:';
maintenanceHtml = `
<div class="maintenance-versions">
<div class="maintenance-header">${headerText}</div>
<div class="maintenance-list">
${versionsToShow.map(v =>
`<div class="maintenance-item">
<span class="version">${v.version}</span>
<span class="date">${v.date}</span>
</div>`
).join('')}
${changelog.maintenanceVersions.length > 2 ?
`<div class="maintenance-item more-versions">
<span>+${changelog.maintenanceVersions.length - 2} altre versioni</span>
</div>` : ''}
</div>
</div>`;
}
card.innerHTML = `
<div class="changelog-image">
<img src="${changelog.image || defaultImage}"
alt="${changelog.title}"
onerror="this.src='${defaultImage}'">
</div>
${tagsHtml}
<h3 title="${changelog.title}">${truncateText(changelog.title)}</h3>
<p class="date">\u{1F4C5} ${changelog.date}</p>
${maintenanceHtml}
`;
return card;
}
// Funzione per cercare tra i changelog usando la barra di ricerca.
function searchChangelogs(searchTerm) {
const activeTagElement = document.querySelector('.tag-filter.active');
const activeTag = activeTagElement ? activeTagElement.dataset.tag : 'all';
let results = getVisibleChangelogs();
// Applica prima il filtro per tag se non è "all"
if (activeTag !== 'all') {
results = results.filter(changelog =>
changelog.tags && changelog.tags.includes(activeTag)
);
}
// Poi applica il filtro di ricerca
results = results.filter(changelog =>
changelog.title.toLowerCase().includes(searchTerm.toLowerCase())
);
refreshChangelogGrid(results);
}
// Funzione per aggiornare la griglia dei changelog dopo un filtro o una ricerca.
function refreshChangelogGrid(changelogs) {
const grid = document.getElementById('changelog-grid');
grid.innerHTML = '';
changelogs.forEach(changelog => {
const card = createChangelogCard(changelog);
grid.appendChild(card);
});
}
// Funzione per copiare il link diretto di un changelog negli appunti.
function copyChangelogLink(file) {
const url = `${window.location.origin}/view-changelog.html?file=${file}`;
navigator.clipboard.writeText(url)
.then(() => alert('Link copiato negli appunti!'));
}
// Funzione per filtrare i changelog in base al tag selezionato.
function filterChangelogsByTag(tag) {
const results = getVisibleChangelogs()
.filter(changelog =>
changelog.tags && changelog.tags.includes(tag)
);
refreshChangelogGrid(results);
}
// Funzione per inizializzare i pulsanti dei filtri tag.
function initializeTagFilters() {
const tagFilters = document.querySelectorAll('.tag-filter');
tagFilters.forEach(filter => {
filter.addEventListener('click', () => {
// Rimuovi la classe active da tutti i filtri
tagFilters.forEach(f => f.classList.remove('active'));
// Aggiungi la classe active al filtro cliccato
filter.classList.add('active');
const tag = filter.dataset.tag;
if (tag === 'all') {
refreshChangelogGrid(getVisibleChangelogs());
} else {
filterChangelogsByTag(tag);
}
});
});
}
// ===================================
// CALENDARIO DEI CHANGELOG
// ===================================
// Funzione per generare il calendario dei changelog nella sidebar.
function generateChangelogCalendar() {
const calendarContainer = document.querySelector('.changelog-calendar');
if (!calendarContainer) return;
const groupedChangelogs = groupChangelogsByYearMonth(window.changelogList);
calendarContainer.innerHTML = '';
// Ordina gli anni in ordine decrescente
const years = Object.keys(groupedChangelogs).sort((a, b) => b - a);
years.forEach(year => {
const yearSection = document.createElement('div');
yearSection.className = 'calendar-year';
yearSection.innerHTML = `<h3 class="year-title">${year}</h3>`;
// Ordina i mesi in ordine decrescente
const months = Object.keys(groupedChangelogs[year]).sort((a, b) => b - a);
months.forEach(monthIndex => {
const monthLogs = groupedChangelogs[year][monthIndex];
const monthSection = document.createElement('div');
monthSection.className = 'calendar-month';
// Ordina i changelog per giorno in ordine decrescente
monthLogs.sort((a, b) => {
const dayA = parseInt(a.date.split('.')[0]);
const dayB = parseInt(b.date.split('.')[0]);
return dayB - dayA;
});
monthSection.innerHTML = `
<h4 class="month-title">${getMonthName(parseInt(monthIndex))}</h4>
<ul>
${monthLogs.map(log => {
const day = log.date.split('.')[0].padStart(2, '0');
return `
<li>
<span class="date">${day}</span>
<a href="view-changelog.html?file=${log.file}"
title="${log.title}">
${truncateText(log.title, 40)}
</a>
</li>
`;
}).join('')}
</ul>
`;
yearSection.appendChild(monthSection);
});
calendarContainer.appendChild(yearSection);
});
}
// Funzione per raggruppare i changelog per anno e mese nel calendario.
function groupChangelogsByYearMonth(changelogs) {
return changelogs
.filter(changelog => changelog.visible) // Filtra prima per visibilità
.reduce((groups, log) => {
// Parsing della data (formato: "DD.MM.YYYY")
const [day, month, year] = log.date.split('.');
// Converte mese da numero a indice (sottrae 1 perché i mesi partono da 0)
const monthIndex = parseInt(month) - 1;
// Crea gli oggetti anno e mese se non esistono
if (!groups[year]) {
groups[year] = {};
}
if (!groups[year][monthIndex]) {
groups[year][monthIndex] = [];
}
// Aggiungi il changelog al gruppo appropriato
groups[year][monthIndex].push({
...log,
dayNum: parseInt(day)
});
// Ordina i changelog del mese per data decrescente
groups[year][monthIndex].sort((a, b) => b.dayNum - a.dayNum);
return groups;
}, {});
}
// Funzione di utilità per ottenere il nome del mese dal suo indice numerico.
function getMonthName(monthIndex) {
const months = [
'Gennaio', 'Febbraio', 'Marzo', 'Aprile',
'Maggio', 'Giugno', 'Luglio', 'Agosto',
'Settembre', 'Ottobre', 'Novembre', 'Dicembre'
];
return months[monthIndex];
}
// Inizializza il caricamento quando il DOM è pronto
document.addEventListener('DOMContentLoaded', loadChangelogList);