-
Notifications
You must be signed in to change notification settings - Fork 23
/
main.js
21 lines (18 loc) · 929 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fetch('https://api.github.com/repos/code4community/git-tutorial/git/trees/master')
.then(response => response.json())
.then(data => {
const imagesUrl = data.tree.find(element => element.path === 'images').url
fetch(imagesUrl)
.then(response => response.json())
.then(data => {
const filenames = data.tree.map(element => element.path)
const body = document.getElementsByTagName('body')[0]
filenames.forEach(filename => {
body.innerHTML += "<div class=\"head-container\"><img class=\"head\" src=\"images/" + filename + "\"/></div>"
})
const people = document.getElementsByClassName("head-container");
for (let person of people) {
person.style["animation-delay"] = -Math.floor(Math.random() * 1000) + "s"
}
})
})