summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2021-02-08 04:19:29 -0500
committerDaniel Micay <danielmicay@gmail.com>2021-02-08 04:27:25 -0500
commit7b0fda4129e0c7a89e3ed9f3f6f699e536f77c1d (patch)
tree9b4df24ee910778ac7ac850588d09c4b67383e96 /static
parent07326f706bcf67e56c7de6af5edc369af6daf4ca (diff)
keep releases listing dynamically updated
Diffstat (limited to 'static')
-rw-r--r--static/js/releases.js60
-rw-r--r--static/releases.html2
2 files changed, 36 insertions, 26 deletions
diff --git a/static/js/releases.js b/static/js/releases.js
index 482f8ac5..7416ce0c 100644
--- a/static/js/releases.js
+++ b/static/js/releases.js
@@ -4,41 +4,51 @@ const baseUrl = "https://releases.grapheneos.org/";
const versionBaseUrl = "https://github.com/GrapheneOS/platform_manifest/releases/tag/";
const devices = ["redfin", "bramble", "sunfish", "coral", "flame", "bonito", "sargo", "crosshatch", "blueline", "taimen", "walleye"];
const channels = ["stable", "beta"];
+const delayMs = 1000 * 60 * 5;
-for (const channel of channels) {
- for (const device of devices) {
- fetch(baseUrl + device + "-" + channel).then(response => {
- if (!response.ok) {
- return Promise.reject();
- }
- return response.text();
- }).then(text => {
- const metadata = text.trim().split(" ");
+async function updateReleases() {
+ const requests = [];
- const factoryFilename = device + "-factory-" + metadata[0] + ".zip";
- const factoryUrl = baseUrl + factoryFilename;
+ for (const channel of channels) {
+ for (const device of devices) {
+ requests.push(fetch(baseUrl + device + "-" + channel).then(response => {
+ if (!response.ok) {
+ return Promise.reject();
+ }
+ return response.text();
+ }).then(text => {
+ const metadata = text.trim().split(" ");
- const updateFilename = device + "-ota_update-" + metadata[0] + ".zip";
- const updateUrl = baseUrl + updateFilename;
+ const factoryFilename = device + "-factory-" + metadata[0] + ".zip";
+ const factoryUrl = baseUrl + factoryFilename;
- const tag = metadata[2] + "." + metadata[0];
+ const updateFilename = device + "-ota_update-" + metadata[0] + ".zip";
+ const updateUrl = baseUrl + updateFilename;
- const release = document.getElementById(device + "-" + channel);
- const links = release.getElementsByTagName("a");
+ const tag = metadata[2] + "." + metadata[0];
- links[1].innerText = tag;
- links[1].setAttribute("href", versionBaseUrl + tag);
+ const release = document.getElementById(device + "-" + channel);
+ const links = release.getElementsByTagName("a");
- links[2].innerText = factoryFilename;
- links[2].setAttribute("href", factoryUrl);
+ links[1].innerText = tag;
+ links[1].setAttribute("href", versionBaseUrl + tag);
- links[3].innerText = factoryFilename + ".sig";
- links[3].setAttribute("href", factoryUrl + ".sig");
+ links[2].innerText = factoryFilename;
+ links[2].setAttribute("href", factoryUrl);
- links[4].innerText = updateFilename;
- links[4].setAttribute("href", updateUrl);
- });
+ links[3].innerText = factoryFilename + ".sig";
+ links[3].setAttribute("href", factoryUrl + ".sig");
+
+ links[4].innerText = updateFilename;
+ links[4].setAttribute("href", updateUrl);
+ }));
+ }
}
+
+ await Promise.allSettled(requests);
+ setTimeout(updateReleases, delayMs);
}
+updateReleases();
+
// @license-end
diff --git a/static/releases.html b/static/releases.html
index 6f8a81f4..c5e26785 100644
--- a/static/releases.html
+++ b/static/releases.html
@@ -27,7 +27,7 @@
<link rel="stylesheet" href="/grapheneos.css?29"/>
<link rel="manifest" href="/manifest.webmanifest"/>
<link rel="license" href="/LICENSE.txt"/>
- <script type="module" src="/js/releases.js?13"></script>
+ <script type="module" src="/js/releases.js?14"></script>
<script type="module" src="/js/redirect.js?9"></script>
</head>
<body>