/* * 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. }); })();