-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
58 lines (49 loc) · 1.67 KB
/
main.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
"use strict";
(function () {
const $_id = (id) => document.getElementById(id);
const RELEASE_URL = 'https://api.github.com/repos/vgmstream/vgmstream-releases/releases/tags/nightly'
function set_beta() {
let $temp = $_id('beta');
$temp.addEventListener('click', (event) => {
document.body.classList.toggle('beta');
});
}
function set_changelog() {
let changelog_done = false;
let changelog_error = false;
let $changelog_link = $_id('changelog-link');
let $changelog_body = $_id('changelog-body');
$changelog_link.addEventListener('click', (event) => {
// in case of github oddities don't prevent default
if (changelog_error) {
return;
}
event.preventDefault();
if (changelog_done) {
$changelog_body.classList.toggle('is-hidden');
return;
}
fetch(RELEASE_URL)
.then((res) => res.json())
.then((response) => {
changelog_error = false;
changelog_done = true;
if (response.body) {
let body_clean = response.body;
console.log(body_clean);
body_clean = body_clean.substring(body_clean.indexOf("###"));
body_clean = body_clean.substring(0, body_clean.indexOf("</details>"));
$changelog_body.textContent = body_clean;
$changelog_body.classList.toggle('is-hidden');
}
})
.catch((error) => {
changelog_error = true;
console.error('Error:', error);
});
});
}
//auto
set_beta();
set_changelog();
})();