-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
1964 lines (1613 loc) · 72.4 KB
/
scripts.js
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
document.addEventListener("DOMContentLoaded", () => {
showSection("about-me");
fetch("project.html")
.then((response) => response.text())
.then((data) => {
document.getElementById("project-modal-placeholder").innerHTML = data;
});
fetchGitHubStats("shliamin");
async function fetchGitHubStats(username) {
try {
const response = await fetch(
`https://api.github.com/users/${username}/repos`
);
if (!response.ok) {
throw new Error("Network response was not ok");
}
const repos = await response.json();
let totalStars = 0;
let totalForks = 0;
let totalWatchers = 0;
repos.forEach((repo) => {
totalStars += repo.stargazers_count;
totalForks += repo.forks_count;
totalWatchers += repo.watchers_count;
});
const statsElement = document.getElementById("github-stats");
const stats = [
{
icon: "images/star-solid.svg",
label: "Stars on GitHub",
value: totalStars,
},
{
icon: "images/code-fork-solid.svg",
label: "Forks on GitHub",
value: totalForks,
},
{
icon: "images/eye-solid.svg",
label: "Watchers on GitHub",
value: totalWatchers,
},
];
stats.forEach((stat) => {
const item = document.createElement("div");
item.classList.add("github-stats-item");
const icon = document.createElement("img");
icon.src = stat.icon;
icon.alt = `${stat.label} Icon`;
icon.classList.add("github-stats-icon");
const detailContainer = document.createElement("div");
detailContainer.classList.add("github-stats-detail-container");
const detail = document.createElement("p");
detail.classList.add("github-stats-detail");
detail.id = "p-title";
detail.innerText = stat.value;
detail.style.padding = "0";
const label = document.createElement("p");
label.classList.add("github-stats-label");
label.innerText = stat.label;
label.style.fontSize = "13px";
detailContainer.appendChild(detail);
detailContainer.appendChild(label);
item.appendChild(icon);
item.appendChild(detailContainer);
statsElement.appendChild(item);
});
} catch (error) {
console.error("Error fetching GitHub stats:", error);
document.getElementById(
"github-stats"
).innerHTML = `<p>Error fetching GitHub stats</p>`;
}
}
// Pop-up functionality
const popupContainer = document.getElementById("popup-container");
const popupDocument = document.getElementById("popup-document");
const popupClose = document.getElementById("popup-close");
var languageSwitcher = document.querySelector(".language-switcher");
document.querySelectorAll(".popup-word").forEach((word) => {
word.addEventListener("click", function () {
const documentSrc = this.getAttribute("data-document");
popupDocument.setAttribute("src", documentSrc);
popupContainer.style.display = "block";
if (window.innerWidth <= 768) {
languageSwitcher.classList.add("hidden");
}
});
});
popupClose.addEventListener("click", function () {
popupContainer.style.display = "none";
popupDocument.setAttribute("src", "");
languageSwitcher.classList.remove("hidden");
});
window.addEventListener("click", function (event) {
if (event.target == popupContainer) {
popupContainer.style.display = "none";
popupDocument.setAttribute("src", "");
languageSwitcher.classList.remove("hidden");
}
});
// Handler for clicking on "My Work" text
document.querySelectorAll(".click-work").forEach((word) => {
word.addEventListener("click", function () {
const myWorkButton = document.querySelector(
".uk-button.uk-button-default[onclick=\"showSection('my-work')\"]"
);
if (myWorkButton) {
myWorkButton.click();
}
});
});
// Handler for clicking on "Our match (AI)" button
document.querySelector("#our-match-btn-en").addEventListener("click", function () {
// Open the section first
const ourMatchButton = document.querySelector(".uk-button.uk-button-default[onclick=\"showSection('our-fit')\"]");
if (ourMatchButton) {
ourMatchButton.click();
}
// Initialize the chart after the section is displayed
setTimeout(function () {
initializeChart();
}, 300); // Delay to ensure the section is fully visible before chart initialization
});
// Handler for clicking on "Contact" text
document.querySelectorAll(".click-contact").forEach((word) => {
word.addEventListener("click", function () {
const myWorkButton = document.querySelector(
".uk-button.uk-button-default[onclick=\"showSection('contact')\"]"
);
if (myWorkButton) {
myWorkButton.click();
}
});
});
// Handler for clicking on "News" text
document.querySelectorAll(".click-news").forEach((word) => {
word.addEventListener("click", function () {
const myWorkButton = document.querySelector(
".uk-button.uk-button-default[onclick=\"showSection('news')\"]"
);
if (myWorkButton) {
myWorkButton.click();
}
});
});
});
function showSection(sectionId) {
window.scrollTo({ top: 0, behavior: "smooth" });
const sections = document.querySelectorAll(".section");
const buttons = document.querySelectorAll(".sidebar nav ul li button");
sections.forEach((section) => {
section.classList.remove("active");
section.classList.add("hidden");
});
buttons.forEach((button) => {
button.classList.remove("active");
});
document.getElementById(sectionId).classList.add("active");
document.getElementById(sectionId).classList.remove("hidden");
document
.querySelector(`button[onclick="showSection('${sectionId}')"]`)
.classList.add("active");
}
function switchLanguage(lang) {
document.getElementById("btn-en").classList.remove("active");
document.getElementById("btn-de").classList.remove("active");
if (lang === "en") {
document.getElementById("btn-en").classList.add("active");
document.getElementById("content-en").style.display = "block";
document.getElementById("content-de").style.display = "none";
document.getElementById("welcome-en").style.display = "block";
document.getElementById("welcome-de").style.display = "none";
document.getElementById("new-opportunities-en").style.display = "block";
document.getElementById("new-opportunities-de").style.display = "none";
document.getElementById("current-location-en").style.display = "block";
document.getElementById("current-location-de").style.display = "none";
document.getElementById("schedule-meeting-en").style.display = "block";
document.getElementById("schedule-meeting-de").style.display = "none";
document.getElementById("certificates-title-en").style.display = "block";
document.getElementById("certificates-title-de").style.display = "none";
document.getElementById("books-title-en").style.display = "block";
document.getElementById("books-title-de").style.display = "none";
document.getElementById("degree-title-en").style.display = "block";
document.getElementById("degree-title-de").style.display = "none";
document.getElementById("notion-en").style.display = "block";
document.getElementById("notion-de").style.display = "none";
document.getElementById("p-title-medium-en").style.display = "block";
document.getElementById("p-title-medium-de").style.display = "none";
document.getElementById("p-title-linkedin-en").style.display = "block";
document.getElementById("p-title-linkedin-de").style.display = "none";
document.getElementById("p-title-github-en").style.display = "block";
document.getElementById("p-title-github-de").style.display = "none";
document.getElementById("p-title-x-en").style.display = "block";
document.getElementById("p-title-x-de").style.display = "none";
document.getElementById("p-title-hr-en").style.display = "block";
document.getElementById("p-title-hr-de").style.display = "none";
document.getElementById("p-title-udemy-en").style.display = "block";
document.getElementById("p-title-udemy-de").style.display = "none";
document.getElementById("ad-info-en").style.display = "block";
document.getElementById("ad-info-de").style.display = "none";
document.getElementById("prof-exp-en").style.display = "block";
document.getElementById("prof-exp-de").style.display = "none";
document.getElementById("edu-en").style.display = "block";
document.getElementById("edu-de").style.display = "none";
document.getElementById("Hobbies-en").style.display = "block";
document.getElementById("Hobbies-de").style.display = "none";
document.getElementById("hobby-2-en").style.display = "block";
document.getElementById("hobby-2-de").style.display = "none";
document.getElementById("karate-en").style.display = "block";
document.getElementById("karate-de").style.display = "none";
document.getElementById("hobby-1-en").style.display = "block";
document.getElementById("hobby-1-de").style.display = "none";
document.getElementById("hobby-description-en").style.display = "block";
document.getElementById("hobby-description-de").style.display = "none";
document.getElementById("three_months-en").style.display = "block";
document.getElementById("three_months-de").style.display = "none";
document.getElementById("two_years-en").style.display = "block";
document.getElementById("two_years-de").style.display = "none";
document.getElementById("three_months-2-en").style.display = "block";
document.getElementById("three_months-2-de").style.display = "none";
document.getElementById("six_months-en").style.display = "block";
document.getElementById("six_months-de").style.display = "none";
document.getElementById("six_months-2-en").style.display = "block";
document.getElementById("six_months-2-de").style.display = "none";
document.getElementById("four_years-en").style.display = "block";
document.getElementById("four_years-de").style.display = "none";
document.getElementById("three_months_3-en").style.display = "block";
document.getElementById("three_months_3-de").style.display = "none";
document.getElementById("three_years-en").style.display = "block";
document.getElementById("three_years-de").style.display = "none";
document.getElementById("one_year-en").style.display = "block";
document.getElementById("one_year-de").style.display = "none";
document.getElementById("one_year-2-en").style.display = "block";
document.getElementById("one_year-2-de").style.display = "none";
document.getElementById("eleven_years-en").style.display = "block";
document.getElementById("eleven_years-de").style.display = "none";
document.getElementById("eleven_years-2-en").style.display = "block";
document.getElementById("eleven_years-2-de").style.display = "none";
document.getElementById("eleven_years-3-en").style.display = "block";
document.getElementById("eleven_years-3-de").style.display = "none";
document.getElementById("sole-tech-exp-en").style.display = "block";
document.getElementById("sole-tech-exp-de").style.display = "none";
document.getElementById("software-htw-en").style.display = "block";
document.getElementById("software-htw-de").style.display = "none";
document.getElementById("htw-data-centre-fullstack-en").style.display = "block";
document.getElementById("htw-data-centre-fullstack-de").style.display = "none";
document.getElementById("IGIT-en").style.display = "block";
document.getElementById("IGIT-de").style.display = "none";
document.getElementById("RMS-en").style.display = "block";
document.getElementById("RMS-de").style.display = "none";
document.getElementById("htw-edu-en").style.display = "block";
document.getElementById("htw-edu-de").style.display = "none";
document.getElementById("edu-lewagon-en").style.display = "block";
document.getElementById("edu-lewagon-de").style.display = "none";
document.getElementById("bochum-edu-en").style.display = "block";
document.getElementById("bochum-edu-de").style.display = "none";
document.getElementById("studienkolleg-en").style.display = "block";
document.getElementById("studienkolleg-de").style.display = "none";
document.getElementById("language-edu-en").style.display = "block";
document.getElementById("language-edu-de").style.display = "none";
document.getElementById("school-en").style.display = "block";
document.getElementById("school-de").style.display = "none";
document.getElementById("mercedes-en").style.display = "block";
document.getElementById("mercedes-de").style.display = "none";
document.getElementById("HTW-HIWI-en").style.display = "block";
document.getElementById("HTW-HIWI-de").style.display = "none";
document.getElementById("htw-internship-en").style.display = "block";
document.getElementById("htw-internship-de").style.display = "none";
document.getElementById("IGIT-1-en").style.display = "block";
document.getElementById("IGIT-1-de").style.display = "none";
document.getElementById("rhenus-en").style.display = "block";
document.getElementById("rhenus-de").style.display = "none";
document.getElementById("cs-en").style.display = "block";
document.getElementById("cs-de").style.display = "none";
document.getElementById("lewagon-en").style.display = "block";
document.getElementById("lewagon-de").style.display = "none";
document.getElementById("ei-en").style.display = "block";
document.getElementById("ei-de").style.display = "none";
document.getElementById("kolleg-en").style.display = "block";
document.getElementById("kolleg-de").style.display = "none";
document.getElementById("eurasia-en").style.display = "block";
document.getElementById("eurasia-de").style.display = "none";
document.getElementById("school-1-en").style.display = "block";
document.getElementById("school-1-de").style.display = "none";
} else if (lang === "de") {
document.getElementById("btn-de").classList.add("active");
document.getElementById("content-en").style.display = "none";
document.getElementById("content-de").style.display = "block";
document.getElementById("welcome-en").style.display = "none";
document.getElementById("welcome-de").style.display = "block";
document.getElementById("new-opportunities-en").style.display = "none";
document.getElementById("new-opportunities-de").style.display = "block";
document.getElementById("current-location-en").style.display = "none";
document.getElementById("current-location-de").style.display = "block";
document.getElementById("schedule-meeting-en").style.display = "none";
document.getElementById("schedule-meeting-de").style.display = "block";
document.getElementById("certificates-title-en").style.display = "none";
document.getElementById("certificates-title-de").style.display = "block";
document.getElementById("books-title-en").style.display = "none";
document.getElementById("books-title-de").style.display = "block";
document.getElementById("degree-title-en").style.display = "none";
document.getElementById("degree-title-de").style.display = "block";
document.getElementById("notion-en").style.display = "none";
document.getElementById("notion-de").style.display = "block";
document.getElementById("p-title-medium-en").style.display = "none";
document.getElementById("p-title-medium-de").style.display = "block";
document.getElementById("p-title-linkedin-en").style.display = "none";
document.getElementById("p-title-linkedin-de").style.display = "block";
document.getElementById("p-title-github-en").style.display = "none";
document.getElementById("p-title-github-de").style.display = "block";
document.getElementById("p-title-x-en").style.display = "none";
document.getElementById("p-title-x-de").style.display = "block";
document.getElementById("p-title-hr-en").style.display = "none";
document.getElementById("p-title-hr-de").style.display = "block";
document.getElementById("p-title-udemy-en").style.display = "none";
document.getElementById("p-title-udemy-de").style.display = "block";
document.getElementById("ad-info-en").style.display = "none";
document.getElementById("ad-info-de").style.display = "block";
document.getElementById("prof-exp-en").style.display = "none";
document.getElementById("prof-exp-de").style.display = "block";
document.getElementById("edu-en").style.display = "none";
document.getElementById("edu-de").style.display = "block";
document.getElementById("Hobbies-en").style.display = "none";
document.getElementById("Hobbies-de").style.display = "block";
document.getElementById("hobby-2-en").style.display = "none";
document.getElementById("hobby-2-de").style.display = "block";
document.getElementById("karate-en").style.display = "none";
document.getElementById("karate-de").style.display = "block";
document.getElementById("hobby-1-en").style.display = "none";
document.getElementById("hobby-1-de").style.display = "block";
document.getElementById("hobby-description-en").style.display = "none";
document.getElementById("hobby-description-de").style.display = "block";
document.getElementById("three_months-en").style.display = "none";
document.getElementById("three_months-de").style.display = "block";
document.getElementById("two_years-en").style.display = "none";
document.getElementById("two_years-de").style.display = "block";
document.getElementById("three_months-2-en").style.display = "none";
document.getElementById("three_months-2-de").style.display = "block";
document.getElementById("six_months-en").style.display = "none";
document.getElementById("six_months-de").style.display = "block";
document.getElementById("six_months-2-en").style.display = "none";
document.getElementById("six_months-2-de").style.display = "block";
document.getElementById("four_years-en").style.display = "none";
document.getElementById("four_years-de").style.display = "block";
document.getElementById("three_months_3-en").style.display = "none";
document.getElementById("three_months_3-de").style.display = "block";
document.getElementById("three_years-en").style.display = "none";
document.getElementById("three_years-de").style.display = "block";
document.getElementById("one_year-en").style.display = "none";
document.getElementById("one_year-de").style.display = "block";
document.getElementById("one_year-2-en").style.display = "none";
document.getElementById("one_year-2-de").style.display = "block";
document.getElementById("eleven_years-en").style.display = "none";
document.getElementById("eleven_years-de").style.display = "block";
document.getElementById("eleven_years-2-en").style.display = "none";
document.getElementById("eleven_years-2-de").style.display = "block";
document.getElementById("eleven_years-3-en").style.display = "none";
document.getElementById("eleven_years-3-de").style.display = "block";
document.getElementById("sole-tech-exp-en").style.display = "none";
document.getElementById("sole-tech-exp-de").style.display = "block";
document.getElementById("software-htw-en").style.display = "none";
document.getElementById("software-htw-de").style.display = "block";
document.getElementById("htw-data-centre-fullstack-en").style.display = "none";
document.getElementById("htw-data-centre-fullstack-de").style.display = "block";
document.getElementById("IGIT-en").style.display = "none";
document.getElementById("IGIT-de").style.display = "block";
document.getElementById("RMS-en").style.display = "none";
document.getElementById("RMS-de").style.display = "block";
document.getElementById("htw-edu-en").style.display = "none";
document.getElementById("htw-edu-de").style.display = "block";
document.getElementById("edu-lewagon-en").style.display = "none";
document.getElementById("edu-lewagon-de").style.display = "block";
document.getElementById("bochum-edu-en").style.display = "none";
document.getElementById("bochum-edu-de").style.display = "block";
document.getElementById("studienkolleg-en").style.display = "none";
document.getElementById("studienkolleg-de").style.display = "block";
document.getElementById("language-edu-en").style.display = "none";
document.getElementById("language-edu-de").style.display = "block";
document.getElementById("school-en").style.display = "none";
document.getElementById("school-de").style.display = "block";
document.getElementById("mercedes-en").style.display = "none";
document.getElementById("mercedes-de").style.display = "block";
document.getElementById("HTW-HIWI-en").style.display = "none";
document.getElementById("HTW-HIWI-de").style.display = "block";
document.getElementById("htw-internship-en").style.display = "none";
document.getElementById("htw-internship-de").style.display = "block";
document.getElementById("IGIT-1-en").style.display = "none";
document.getElementById("IGIT-1-de").style.display = "block";
document.getElementById("rhenus-en").style.display = "none";
document.getElementById("rhenus-de").style.display = "block";
document.getElementById("cs-en").style.display = "none";
document.getElementById("cs-de").style.display = "block";
document.getElementById("lewagon-en").style.display = "none";
document.getElementById("lewagon-de").style.display = "block";
document.getElementById("ei-en").style.display = "none";
document.getElementById("ei-de").style.display = "block";
document.getElementById("kolleg-en").style.display = "none";
document.getElementById("kolleg-de").style.display = "block";
document.getElementById("eurasia-en").style.display = "none";
document.getElementById("eurasia-de").style.display = "block";
document.getElementById("school-1-en").style.display = "none";
document.getElementById("school-1-de").style.display = "block";
}
}
window.addEventListener("scroll", function () {
var languageSwitcher = document.querySelector(".language-switcher");
if (window.scrollY > 0) {
languageSwitcher.classList.add("hidden");
} else {
languageSwitcher.classList.remove("hidden");
}
});
// News
function truncateText(text, maxLength, newsLink = null) {
if (text.length > maxLength) {
if (newsLink) {
return (
text.slice(0, maxLength) +
`... <a href="${newsLink}" target="_blank" class="read-more">Read more</a>`
);
} else {
return text.slice(0, maxLength) + "...";
}
} else {
return text;
}
}
function getBadgeClass(category) {
switch (category.toLowerCase()) {
case "update":
return "badge-update";
case "milestone":
return "badge-milestone";
case "project":
return "badge-project";
case "news":
return "badge-news";
default:
return "badge-default";
}
}
document.addEventListener("DOMContentLoaded", () => {
const newsList = document.getElementById("news-list");
const authorFilter = document.getElementById("author-filter");
let newsData = [];
let authors = new Set();
axios
.get("news.json")
.then((response) => {
newsData = response.data;
displayNews(newsData);
populateAuthorFilter(newsData);
})
.catch((error) => {
console.error("Error loading news:", error);
});
function formatDate(dateString) {
const options = { day: "2-digit", month: "long", year: "numeric" };
return new Date(dateString).toLocaleDateString("en-GB", options);
}
function displayNews(filteredData) {
filteredData.sort((a, b) => new Date(b.date) - new Date(a.date));
newsList.innerHTML = "";
filteredData.forEach((newsItem) => {
const newsElement = document.createElement("li");
newsElement.classList.add("news-item");
let badgeClass;
switch (newsItem.category.toLowerCase()) {
case "update":
badgeClass = "badge-update";
break;
case "milestone":
badgeClass = "badge-milestone";
break;
case "project":
badgeClass = "badge-project";
break;
case "news":
badgeClass = "badge-news";
break;
default:
badgeClass = "badge-default";
break;
}
let titleContent = `<h3>${newsItem.title}</h3>`;
let content = truncateText(newsItem.content, 300);
if (newsItem.category.toLowerCase() === "news") {
const newsLink = newsItem.link;
titleContent = `<h3><a href="${newsLink}" target="_blank">${newsItem.title}</a></h3>`;
content = truncateText(newsItem.content, 300, newsLink);
}
newsElement.innerHTML = `
<div class="news-content">
<img src="${newsItem.image}" alt="${newsItem.title
}" class="news-image">
<div class="news-text">
<div class="news-title">
<span class="badge ${badgeClass}">${newsItem.category
}</span>
${titleContent}
</div>
<p class="news-meta"><small>by ${newsItem.author
} on ${formatDate(newsItem.date)}</small></p>
<p class="news-description">${content}</p>
</div>
</div>
`;
newsList.appendChild(newsElement);
});
}
function populateAuthorFilter(data) {
data.forEach((newsItem) => {
authors.add(newsItem.author);
});
authors.forEach((author) => {
const option = document.createElement("option");
option.value = author;
option.textContent = author;
authorFilter.appendChild(option);
});
}
const categoryFilter = document.getElementById("category-filter");
const dateStartFilter = document.getElementById("date-start-filter");
const dateEndFilter = document.getElementById("date-end-filter");
// Add event listeners for automatic filtering
categoryFilter.addEventListener("change", filterNews);
authorFilter.addEventListener("change", filterNews);
dateStartFilter.addEventListener("change", filterNews);
dateEndFilter.addEventListener("change", filterNews);
function filterNews() {
const selectedCategory = categoryFilter.value.toLowerCase();
const selectedAuthor = authorFilter.value;
const selectedStartDate = new Date(dateStartFilter.value);
const selectedEndDate = new Date(dateEndFilter.value);
selectedEndDate.setHours(23, 59, 59, 999);
let filteredData = newsData;
if (selectedCategory !== "all") {
filteredData = filteredData.filter((newsItem) => {
const mainCategory = newsItem.category.toLowerCase().trim();
const subCategory = newsItem.subcategory
? newsItem.subcategory.toLowerCase().trim()
: "";
return (
mainCategory === selectedCategory ||
`${mainCategory}:${subCategory}` === selectedCategory ||
(selectedCategory === "news:all" && mainCategory === "news")
);
});
}
if (selectedAuthor !== "all") {
filteredData = filteredData.filter(
(newsItem) => newsItem.author === selectedAuthor
);
}
if (dateStartFilter.value && dateEndFilter.value) {
filteredData = filteredData.filter((newsItem) => {
const newsDate = new Date(newsItem.date);
return newsDate >= selectedStartDate && newsDate <= selectedEndDate;
});
}
if (
!dateStartFilter.value &&
!dateEndFilter.value &&
selectedCategory === "all" &&
selectedAuthor === "all"
) {
filteredData = newsData;
}
displayNews(filteredData);
}
});
document.querySelectorAll(".button-docs").forEach((button) => {
button.addEventListener("click", function () {
this.classList.add("clicked");
});
});
function adjustMargin() {
const screenWidth = window.innerWidth;
if (screenWidth < 500) {
const marginLeft = screenWidth + 100;
const firstButton = document.querySelector(".button-docs:first-child");
if (firstButton) {
firstButton.style.marginLeft = marginLeft + "px";
}
} else {
}
}
window.addEventListener("load", adjustMargin);
window.addEventListener("resize", adjustMargin);
document.addEventListener("DOMContentLoaded", function () {
let certificates = []; // To store the fetched data
fetch("certificates.json")
.then((response) => response.json())
.then((data) => {
certificates = data;
updateCategoryCounts(certificates); // Update dropdown with counts
displayCertificates(certificates); // Initially display all certificates
})
.catch((error) => console.error("Error fetching certificates:", error));
const container = document.querySelector(".achievement-carousel");
const filterDropdown = document.getElementById(
"category-filter-certificates"
);
// Function to display certificates in the carousel
function displayCertificates(certificates) {
if (!container) {
console.error("Container not found!");
return;
}
// Clear the current items
container.innerHTML = "";
// Sort certificates by date in descending order
certificates.sort((a, b) => new Date(b.date) - new Date(a.date));
certificates.forEach((certificate) => {
const achievementItem = document.createElement("div");
achievementItem.classList.add("achievement-item");
achievementItem.style.cssText =
"position: relative; min-width: 120px; flex-shrink: 0;";
const anchor = document.createElement("a");
anchor.href = certificate.link;
anchor.target = "_blank"; // Open in a new tab
const image = document.createElement("img");
image.src = certificate.image;
image.alt = certificate.name + " Thumbnail";
// Use width and height from the JSON data
image.style.width = certificate.width + "px";
image.style.height = certificate.height + "px";
image.style.cssText +=
"box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease;";
anchor.appendChild(image);
achievementItem.appendChild(anchor);
container.appendChild(achievementItem);
});
// Update the count in the dropdown for the current selected category
updateDropdownLabel(certificates.length);
}
// Function to update the dropdown label with the number of certificates
function updateDropdownLabel(count) {
const selectedCategory =
filterDropdown.options[filterDropdown.selectedIndex];
selectedCategory.textContent = `${selectedCategory.value} (${count})`;
}
// Function to update category counts in the dropdown
function updateCategoryCounts(certificates) {
const allCount = certificates.length;
const udemyCount = certificates.filter(
(certificate) => certificate.category === "Udemy"
).length;
const hackerRankCount = certificates.filter(
(certificate) => certificate.category === "HackerRank"
).length;
const testdomeCount = certificates.filter(
(certificate) => certificate.category === "Testdome"
).length;
const workCount = certificates.filter(
(certificate) => certificate.category === "Work"
).length;
const educationCount = certificates.filter(
(certificate) => certificate.category === "Education"
).length;
filterDropdown.options[0].textContent = `All Categories (${allCount})`;
filterDropdown.options[1].textContent = `Udemy (${udemyCount})`;
filterDropdown.options[2].textContent = `HackerRank (${hackerRankCount})`;
filterDropdown.options[3].textContent = `Testdome (${testdomeCount})`;
filterDropdown.options[4].textContent = `Work (${workCount})`;
filterDropdown.options[5].textContent = `Education (${educationCount})`;
}
// Event listener for the filter dropdown
filterDropdown.addEventListener("change", function () {
const selectedCategory = filterDropdown.value;
// Filter the certificates based on the selected category
const filteredCertificates =
selectedCategory === "All Categories"
? certificates
: certificates.filter(
(certificate) => certificate.category === selectedCategory
);
// Redisplay the filtered certificates
displayCertificates(filteredCertificates);
});
});
document.addEventListener("DOMContentLoaded", function () {
let certificates = []; // To store the fetched data
fetch("certificates.json")
.then((response) => response.json())
.then((data) => {
certificates = data;
updateTechnologyFilter(certificates); // Initialize technology filter with counts
displayCertificates(certificates); // Initially display all certificates
})
.catch((error) => console.error("Error fetching certificates:", error));
const container = document.querySelector(".achievement-carousel");
const technologyDropdown = document.getElementById("technology-filter-certificates");
// Function to display certificates in the carousel
function displayCertificates(certificates) {
if (!container) {
console.error("Container not found!");
return;
}
// Clear the current items
container.innerHTML = "";
// Sort certificates by date in descending order
certificates.sort((a, b) => new Date(b.date) - new Date(a.date));
certificates.forEach((certificate) => {
const achievementItem = document.createElement("div");
achievementItem.classList.add("achievement-item");
achievementItem.style.cssText =
"position: relative; min-width: 120px; flex-shrink: 0;";
const anchor = document.createElement("a");
anchor.href = certificate.link;
anchor.target = "_blank"; // Open in a new tab
const image = document.createElement("img");
image.src = certificate.image;
image.alt = certificate.name + " Thumbnail";
// Use width and height from the JSON data
image.style.width = certificate.width + "px";
image.style.height = certificate.height + "px";
image.style.cssText +=
"box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease;";
anchor.appendChild(image);
achievementItem.appendChild(anchor);
container.appendChild(achievementItem);
});
}
// Separate function to update the technology filter dropdown with counts
function updateTechnologyFilter(certificates) {
const technologyCounts = {}; // Object to store technology counts
// Count occurrences of each technology
certificates.forEach((certificate) => {
if (certificate.technology && Array.isArray(certificate.technology)) { // Ensure `technology` is an array
certificate.technology.forEach((tech) => {
technologyCounts[tech] = (technologyCounts[tech] || 0) + 1;
});
}
});
// Populate the technology dropdown with counts
technologyDropdown.innerHTML = `<option value="All Technologies">All Technologies (${certificates.length})</option>`;
Object.keys(technologyCounts).forEach((tech) => {
const option = document.createElement("option");
option.value = tech;
option.textContent = `${tech} (${technologyCounts[tech]})`;
technologyDropdown.appendChild(option);
});
}
// Function to filter certificates by selected technology
function filterByTechnology() {
const selectedTechnology = technologyDropdown.value;
const filteredCertificates =
selectedTechnology === "All Technologies"
? certificates
: certificates.filter(
(certificate) =>
certificate.technology && certificate.technology.includes(selectedTechnology)
);
// Redisplay the filtered certificates
displayCertificates(filteredCertificates);
}
// Event listener for the technology filter dropdown
technologyDropdown.addEventListener("change", filterByTechnology);
});
document.addEventListener("DOMContentLoaded", function () {
let books = []; // Store fetched data about books
fetch("books.json")
.then((response) => response.json())
.then((data) => {
books = data;
updateDropdownCounts(); // Update dropdown with book counts
displayBooks(books); // Initially display all books
})
.catch((error) => console.error("Error fetching books:", error));
const container = document.querySelector(".books-carousel");
const filterDropdown = document.getElementById("category-filter-books");
// Function to display books in the carousel
function displayBooks(books) {
if (!container) {
console.error("Container not found!");
return;
}
container.innerHTML = ""; // Clear the current items
books.sort((a, b) => a.title.localeCompare(b.title)); // Optional sorting
books.forEach((book) => {
const bookItem = document.createElement("div");
bookItem.classList.add("book-item");
bookItem.style.cssText =
"position: relative; min-width: 120px; flex-shrink: 0;";
const anchor = document.createElement("a");
anchor.href = book.link;
anchor.target = "_blank";
const image = document.createElement("img");
image.src = book.coverImage;
image.alt = book.title + " Cover";
image.style.width = "120px";
image.style.height = "180px";
image.style.cssText +=
"box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease;";
anchor.appendChild(image);
bookItem.appendChild(anchor);
container.appendChild(bookItem);
});
}
// Function to update dropdown with book counts
function updateDropdownCounts() {
const categoryCounts = {
"Technical": 0,
"Business & Leadership": 0,
"Innovation & Startups": 0,
"Personal Development": 0,
"Philosophy": 0,
"Biography": 0
};
books.forEach((book) => {
if (categoryCounts[book.genre] !== undefined) {
categoryCounts[book.genre]++;
}
});
// Add total count for "All" option
const allBooksCount = books.length;
// Update dropdown options with counts
document.querySelector(
'option[value="All-genres"]'
).textContent = `All genres (${allBooksCount})`;
for (const category in categoryCounts) {
const option = document.querySelector(`option[value="${category}"]`);
if (option) {
option.textContent = `${category} (${categoryCounts[category]})`;
}
}
}
// Event listener for the filter dropdown
filterDropdown.addEventListener("change", function () {
const selectedCategory = filterDropdown.value;
// Filter books by selected genre/category
const filteredBooks =
selectedCategory === "All-genres"
? books
: books.filter((book) => book.genre === selectedCategory);
// Redisplay the filtered books
displayBooks(filteredBooks);
});
});
// Function to detect language
function detectLanguage(text) {
// Convert text to lowercase for easier comparison
const lowerText = text.toLowerCase();
// English-specific characters and words
const englishPattern = /[a-z]/;
const commonEnglishWords = ['the', 'and', 'is', 'are', 'you'];
// German-specific characters and words
const germanPattern = /[äöüß]/;
const commonGermanWords = ['der', 'und', 'ist', 'sie', 'das'];
// Count occurrences of patterns and words
let englishScore = 0;
let germanScore = 0;
// Check for English characters and words
if (englishPattern.test(lowerText)) englishScore++;
commonEnglishWords.forEach(word => {
if (lowerText.includes(word)) englishScore++;
});