-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
executable file
·175 lines (143 loc) · 6.01 KB
/
script.js
File metadata and controls
executable file
·175 lines (143 loc) · 6.01 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
var aktuell = 0;
var indikatoren = [];
var pages = [];
var timestampold = new Date();
document.addEventListener('DOMContentLoaded', () => {
init();
const fontsNoticeButton = document.getElementById('fontsNoticeButton');
if (fontsNoticeButton) {
fontsNoticeButton.addEventListener('click', () => {
document.getElementById('fontsNotice').style.display = 'none';
});
}
setInterval(automatic, 5000);
});
async function init() {
await Promise.all([
fetchSponsors(),
loadTabContent(),
loadSlideshow()
]);
if (typeof ScrollReveal !== 'undefined') {
ScrollReveal().reveal('.animationRight', { origin: 'right', distance: '50px', duration: 500 });
ScrollReveal().reveal('.animationLeft', { origin: 'left', distance: '50px', duration: 500 });
ScrollReveal().reveal('.animationBottom', { origin: 'bottom', distance: '50px', duration: 500 });
}
}
async function fetchSponsors() {
const container = document.getElementById('containerSponsors');
if (!container) return;
try {
const response = await fetch('content/sponsors.json');
const sponsors = await response.json();
let cardsHtml = sponsors.map(s => {
let descriptionHtml = s.description ? `<p class="card-description">${s.description}</p>` : "";
let ctaHtml = s.cta ? `<p class="card-description" style="margin-top: 15px; margin-bottom: 15px; font-style: italic;">${s.cta}</p>` : "";
return `
<div class="card card--sponsor animationRight">
<div class="card-head">
<img src="${s.logo}" alt="${s.name}" class="card-logo" />
<h3 class="card-headline">${s.name}</h3>
</div>
${descriptionHtml}
${ctaHtml}
<a href="${s.url}" class="card-button" target="_blank">Learn more</a>
</div>`;
}).join('');
container.innerHTML = cardsHtml + container.innerHTML;
} catch (error) {
console.error("Fehler beim Laden der Sponsoren:", error);
}
}
async function loadTabContent() {
try {
const [rewardsRes, eventsRes, membersRes] = await Promise.all([
fetch('content/rewards.json'),
fetch('content/events.json'),
fetch('content/members.json')
]);
const rewards = await rewardsRes.json();
const events = await eventsRes.json();
const members = await membersRes.json();
const rewardsList = document.querySelector('#rewards ul');
if (rewardsList) {
rewardsList.innerHTML = rewards.map(item => `
<li><span>${item.title}</span><br />${item.desc}</li>
`).join('');
}
const eventsList = document.querySelector('#events ul');
if (eventsList) {
eventsList.innerHTML = events.map(event => {
const liAttr = event.status === "live" ? 'id="liveLi"' : '';
const spanAttr = event.status === "live" ? 'id="liveSpan"' : '';
return `<li ${liAttr}><span ${spanAttr}>${event.date}</span><br />${event.name}</li>`;
}).join('');
}
const membersList = document.querySelector('#members ul');
if (membersList) {
membersList.innerHTML = members.map(m => `
<li><span>${m.role}</span><br />${m.name}</li>
`).join('');
}
} catch (error) {
console.error("Fehler beim Laden der Tab-Inhalte:", error);
}
}
async function loadSlideshow() {
const slideshowContainer = document.querySelector('.slideshowelement');
if (!slideshowContainer) return;
try {
const response = await fetch('content/slideshow.json');
const images = await response.json();
const imagesHtml = images.map((img, index) => `
<div class="slideshowpage ${index === 0 ? 'aktiv' : ''}">
<img src="${img.src}" alt="${img.alt}" />
</div>
`).join('');
const pointsHtml = images.map((_, index) => `
<li class="point ${index === 0 ? 'aktiv' : ''}" onclick="jump(${index})">•</li>
`).join('');
slideshowContainer.innerHTML = `
${imagesHtml}
<a class="arrow arrow-left" onclick="switchPage(-1)"><span>❮</span></a>
<a class="arrow arrow-right" onclick="switchPage(1)"><span>❯</span></a>
<ol class="points-list">${pointsHtml}</ol>
`;
pages = document.getElementsByClassName("slideshowpage");
indikatoren = document.getElementsByClassName("point");
aktuell = 0;
} catch (error) {
console.error("Slideshow konnte nicht geladen werden:", error);
}
}
function switchPage(anzahl) {
if (pages.length === 0) return;
var neu = aktuell + anzahl;
if (neu < 0) neu = pages.length - 1;
if (neu > pages.length - 1) neu = 0;
jump(neu);
}
function jump(neu) {
if (!pages || pages.length === 0) return;
indikatoren[aktuell].classList.remove("aktiv");
pages[aktuell].classList.remove("aktiv");
indikatoren[neu].classList.add("aktiv");
pages[neu].classList.add("aktiv");
aktuell = neu;
timestampold = new Date();
}
function automatic() {
if (pages.length === 0) return;
const diff = new Date() - timestampold;
if (diff >= 15000) {
switchPage(1);
}
}
function opentab(tabname) {
var tablinks = document.getElementsByClassName('tab-link');
var tabcontents = document.getElementsByClassName('tab-content');
for (let tablink of tablinks) tablink.classList.remove('active-link');
for (let tabcontent of tabcontents) tabcontent.classList.remove('active-tab');
event.currentTarget.classList.add('active-link');
document.getElementById(tabname).classList.add('active-tab');
}