-
-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathscript.js
34 lines (29 loc) · 1.1 KB
/
script.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
/* The contributors are loaded from a file instead of being fetched from the GitHub API.
* This is done to avoid rate limiting, since the GitHub API has a limit of 60 requests per hour.
* The contributors.json file is generated from the fetch-contributors.py script.
*/
const setup_contributors = () => {
const contributors = document.getElementById("contributors");
fetch("contributors.json")
.then((response) => response.json())
.then((data) => {
data.forEach((contributor) => {
const img = document.createElement("img");
img.src = contributor.avatar_url;
img.width = 64;
img.height = 64;
const a = document.createElement("a");
a.href = contributor.html_url;
a.appendChild(img);
const div = document.createElement("div");
div.appendChild(a);
contributors.appendChild(div);
});
})
.catch((error) => {
contributors.innerHTML = "Failed to load contributors";
contributors.className = "error";
console.error(error);
});
};
document.addEventListener("DOMContentLoaded", setup_contributors);