-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
97 lines (85 loc) · 3.84 KB
/
index.html
File metadata and controls
97 lines (85 loc) · 3.84 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MCSR Rules</title>
<meta name="description" content="The official ruleset for Minecraft Speedrunning.">
<link rel="stylesheet" href="styles.css">
<link rel="icon" type="image/png" sizes="128x128" href="assets/favicon.png"> <!-- website icon -->
<script>
document.addEventListener("DOMContentLoaded", () => {
document.getElementById("js").remove()
fetch("https://api.github.com/repos/Minecraft-Java-Edition-Speedrunning/rules/contents/pub/pdf")
.then(res => {
if (!res.ok) {
document.getElementById("newest").innerText = "github api failed :("
throw new Error("http error status: " + response.status);
}
return res.json();
})
.then(data => {
data.sort((a, b) => {
a = a.name; b = b.name;
b1 = !a.includes("beta"); b2 = !b.includes("beta")
if (b1 ^ b2) return b2 - b1 // boolean subtraction
return b.split(".")[0].split("_").at(-1).substring(1) - a.split(".")[0].split("_").at(-1).substring(1) // string subtraction
})
quicklink = document.getElementById("quicklink")
newest = data[0]
quicklink.href = "https://rawcdn.githack.com/Minecraft-Java-Edition-Speedrunning/rules/main/pub/pdf/" + newest.name
quicklink.innerText = newest.name
// opens the link in a new tab
quicklink.setAttribute("target", "_blank");
quicklink.setAttribute("rel", "noopener noreferrer");
// clear the placeholder "Loading releases.."
if (releases) releases.innerHTML = '';
for (ver of data) {
url = "https://rawcdn.githack.com/Minecraft-Java-Edition-Speedrunning/rules/main/pub/pdf/" + ver.name
changelog = "https://github.com/Minecraft-Java-Edition-Speedrunning/rules/releases/tag/" + ver.name.split(".")[0]
// create a list item element
const li = document.createElement("li");
if (!ver.name.includes("beta")) {
// release link and changelog link classes
li.innerHTML = `<a class="release-link" href="${url}" target="_blank" rel="noopener noreferrer">${ver.name}</a>`
+ `<span class="sep"> — </span>`
+ `<a class="changelog-link" href="${changelog}" target="_blank" rel="noopener noreferrer">Changelog</a>`;
} else {
// beta releases get .beta class styling
li.innerHTML = `<a class="release-link" href="${url}" target="_blank" rel="noopener noreferrer">${ver.name}</a>`
+ `<span class="sep"> </span>`
+ `<em class="beta">(beta)</em>`;
}
releases.appendChild(li);
}
})
})
</script>
</head>
<body>
<main class="page">
<header class="site-header">
<div class="brand">
<img src="assets/favicon.png" alt="MCSR Rules Logo" class="brand-icon" width="32" height="32">
<div>
<h1>MCSR Rules</h1>
<p class="subtitle">The official ruleset for Minecraft Speedrunning.</p>
</div>
</div>
</header>
<section class="content-area">
<h2 id="js">This site requires JavaScript!</h2>
<div class="current-line" id="newest">Current: <a id="quicklink">Loading..</a></div>
<div class="rules-list-wrap">
<h3 id="rules">All releases:</h3>
<ul id="releases" class="releases">
<li class="loading">Loading releases..</li>
</ul>
<p class="note">
The rules are maintained on GitHub at <a href="https://github.com/Minecraft-Java-Edition-Speedrunning/rules">Minecraft-Java-Edition-Speedrunning/rules</a>.<br>
Use <a href="./latest">/latest</a> to always redirect to the current rules release.
</p>
</div>
</section>
</main>
</body>
</html>