-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
executable file
·105 lines (85 loc) · 4.24 KB
/
index.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
(async () => {
// gives the download link for a given branch once the Everest version list was fetched, or null if no build was found
const getLinkForBranch = (versionList, branch) => {
const matchingVersions = versionList.filter(version => version.branch === branch);
if (matchingVersions.length !== 0) {
return matchingVersions[0];
}
return null;
};
// === Fetch link to Everest
{
// a static file on this website indicates to Everest and Olympus where the Everest versions list is provided,
// so load the URL from there as well...
const updaterUrlFetch = await fetch("/everestupdater.txt");
if (updaterUrlFetch.ok) {
// ... then call it.
const updaterUrl = await updaterUrlFetch.text();
const versionListFetch = await fetch(updaterUrl.trim() + "?supportsNativeBuilds=true");
if (versionListFetch.ok) {
const versionList = await versionListFetch.json();
const stable = getLinkForBranch(versionList, "stable").mainDownload;
const beta = getLinkForBranch(versionList, "beta").mainDownload;
const dev = getLinkForBranch(versionList, "dev").mainDownload;
// if all versions have an existing build...
if (stable !== null && beta !== null && dev !== null) {
// set the links to their artifacts
document.getElementById("latest-stable-link").href = stable;
document.getElementById("latest-beta-link").href = beta;
document.getElementById("latest-dev-link").href = dev;
// remove the line saying "Click the '1 published' button under 'Related', then 'main' to download it." since those are now direct links.
var artifactInstructions = document.getElementById("artifact-instructions");
artifactInstructions.parentNode.removeChild(artifactInstructions);
}
}
}
}
// === Fetch link to Olympus
{
const updaterUrlFetch = await fetch("/olympusupdater.txt");
if (updaterUrlFetch.ok) {
// ... then call it.
const updaterUrl = await updaterUrlFetch.text();
const versionListFetch = await fetch(updaterUrl.trim());
if (versionListFetch.ok) {
const versionList = await versionListFetch.json();
const stable = getLinkForBranch(versionList, "stable");
if (stable !== null) {
// set the links to the latest stable
document.getElementById("olympus-macos-latest-link").href = stable.macosDownload;
document.getElementById("olympus-linux-latest-link").href = stable.linuxDownload;
// remove the line saying "Click the '5 published' button under 'Related', then '...main' to download it." since those are now direct links.
const artifactInstructionsMacOS = document.getElementById("olympus-macos-artifact-instructions");
artifactInstructionsMacOS.parentNode.removeChild(artifactInstructionsMacOS);
const artifactInstructionsLinux = document.getElementById("olympus-linux-artifact-instructions");
artifactInstructionsLinux.parentNode.removeChild(artifactInstructionsLinux);
}
}
}
}
})();
{
// handling for the macOS instructions foldable section
const fold = document.getElementById("mac-instructions-fold");
const icon = document.getElementById("mac-instructions-fold-icon");
let folded = false;
const toggle = () => {
if (folded) {
// unfold
icon.innerText = "-";
fold.style.display = "block";
folded = false;
} else {
// fold
icon.innerText = "+";
fold.style.display = "none";
folded = true;
}
};
document.getElementById("mac-instructions-fold-trigger").addEventListener("click", e => {
e.preventDefault();
toggle();
});
// the section is unfolded by default in the HTML, but we want it folded by default if JS is enabled
toggle();
}