-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlatest-loader.js
More file actions
41 lines (37 loc) · 1.39 KB
/
latest-loader.js
File metadata and controls
41 lines (37 loc) · 1.39 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
var converter = new showdown.Converter();
var latestVersionTag = document.getElementById("latest-version-tag"),
latestVersionBody = document.getElementById("latest-markdown-body"),
olderVersionDiv = document.getElementById("older-ver-div")
fetch("https://api.github.com/repos/xFN10x/bedrockR/releases/latest")
.then((res) => {
if (res.ok) {
return res.json();
}
})
.then((json) => {
console.log(json);
latestVersionTag.innerText = json.tag_name;
latestVersionBody.insertAdjacentHTML("afterbegin", converter.makeHtml(json.body))
});
fetch("https://api.github.com/repos/xFN10x/bedrockR/releases")
.then((res) => {
if (res.ok) {
return res.json();
}
})
.then((json) => {
console.log(json);
for (const release of json) {
if (json.indexOf(release) == 0) continue; // skips most recent release (its already showing)
olderVersionDiv.insertAdjacentHTML("beforeend", `<details>
<summary>${release.tag_name}</summary>
<div>${converter.makeHtml(release.body)}</div>
<button
style="width: -webkit-fill-available; height: 5rem"
onclick="location.href = '/download?release=${release.tag_name}'"
>
Download
</button>
</details>`)
}
});