SkateSpots/public/download/download.js
SkateSpots 06c1d644d9
Some checks are pending
Deploy to GitHub Pages / deploy (push) Waiting to run
release: 1.7.87
2026-11-02 16:57:04 +07:00

31 lines
1.1 KiB
JavaScript

/*
* The download page reads its version, APK URL and checksum from the latest
* Forgejo release. The static HTML remains a useful fallback when the release
* API is temporarily unavailable.
*/
(() => {
const link = document.querySelector('a.download');
const label = document.querySelector('#download-label');
const sha = document.querySelector('#download-sha256');
if (!link || !label) return;
const setLabel = (version, size) => {
const mb = size > 0 ? ` · ${Math.max(1, Math.round(size / 1000000))} MB` : '';
label.textContent = `Download SkateSpots-${version}.apk${mb}`;
};
fetch('/api/latest-release', { headers: { accept: 'application/json' } })
.then((res) => (res.ok ? res.json() : null))
.then((release) => {
if (!release || !release.version || !release.apkUrl) return;
link.href = release.apkUrl;
setLabel(release.version, Number(release.size) || 0);
if (sha && release.sha256) {
sha.textContent = release.sha256;
}
document.documentElement.dataset.latestRelease = release.version;
})
.catch(() => {
// Keep the static fallback already in the HTML.
});
})();