-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontributor.js
66 lines (54 loc) · 2.22 KB
/
contributor.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
const interval = 0.5
let translations
const getTranslations = async _ => {
let i18nIndex = await fetch('data/contributor/i18n/index.json').then(res => res.json())
let fallback = i18nIndex.fallback, main = i18nIndex.languages.filter(x => x.id.indexOf(navigator.language) != -1)?.[0]?.file ?? fallback
let fallbackFile = await fetch(`data/contributor/i18n/${fallback}.json`).then(res => res.json())
let mainFile = await fetch(`data/contributor/i18n/${main}.json`).then(res => res.json())
translations = { ...fallbackFile, ...mainFile }
}
const resolve = key => translations[key] ?? key
window.onload = async _ => {
await getTranslations()
let contributor = await fetch('data/contributor/index.json').then(res => res.json())
let delay = 0
let t = document.createElement('h1')
t.className = 'fade-line'
t.style.animationDelay = `${delay}s`
t.innerText = resolve('title.main')
document.body.appendChild(t)
delay += interval
for (let { name, people } of contributor) {
let title = document.createElement('h2')
title.className = 'fade-line'
title.style.animationDelay = `${delay}s`
title.innerText = resolve(name)
document.body.appendChild(title)
delay += interval
let p = document.createElement('div')
p.className = 'container'
document.body.appendChild(p)
for (let { name, role, image } of people) {
let single = document.createElement('div')
single.className = 'fade-line single'
single.style.animationDelay = `${delay}s`
p.appendChild(single)
let header = document.createElement('div')
header.className = 'single-header'
single.appendChild(header)
let img = document.createElement('img')
img.src = image
img.title = resolve(name)
header.appendChild(img)
let h3 = document.createElement('h3')
h3.innerText = resolve(name)
header.appendChild(h3)
if (role) {
let r = document.createElement('p')
r.innerText = resolve(role)
single.appendChild(r)
}
}
delay += interval
}
}