-
Notifications
You must be signed in to change notification settings - Fork 1
/
homepage.js
29 lines (24 loc) · 1.01 KB
/
homepage.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
const load_json = async url => {
const response = await fetch(url)
if (response.ok) {
const jsonValue = await response.json()
return Promise.resolve(jsonValue)
} else {
return []
}
}
const DEFAULT_ORGANIZERS = ['trojsten', 'p-mat', 'riesky', 'sezam', 'strom']
const DATA_URL_PREFIX = 'https://data.kockatykalendar.sk/'
let ORGANIZERS = load_json(`${DATA_URL_PREFIX}organizers.json`)
document.addEventListener('DOMContentLoaded', async () => {
ORGANIZERS = await ORGANIZERS
const orgs_html = DEFAULT_ORGANIZERS.reduce((html, org) => `${html}
<article class="border rounded-lg p-8 text-center shadow" style="border-color: ${ORGANIZERS[org].color}">
<a href="${ORGANIZERS[org].web}" target="_blank" rel="noreferrer">
<img src="${DATA_URL_PREFIX}${ORGANIZERS[org].icon}" alt="${ORGANIZERS[org].name}" class="h-24 mx-auto mb-4">
</a>
<h2 class="mb-2 font-bold text-2xl">${ORGANIZERS[org].name}</h2>
<p>${ORGANIZERS[org].info}</p>
</article>`, '')
document.getElementById('organizations').innerHTML = orgs_html
})