diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2021-12-05 09:54:15 -0500 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2021-12-05 09:54:15 -0500 |
| commit | 91603e5506a8af4cd32ef32130db68fac7f08fbf (patch) | |
| tree | d8ee65d810ac42fd0f8c4d473ec586aeed36e97c /static/js | |
| parent | 7da9a2aa29f7343e0db4e3fc4794d9ac7e548d3f (diff) | |
add utility function to simplify releases.js
Diffstat (limited to 'static/js')
| -rw-r--r-- | static/js/releases.js | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/static/js/releases.js b/static/js/releases.js index b99b7d3d..d0a2f83f 100644 --- a/static/js/releases.js +++ b/static/js/releases.js @@ -6,6 +6,11 @@ const devices = ["raven", "oriole", "barbet", "redfin", "bramble", "sunfish", "c const channels = ["stable", "beta"]; const delayMs = 1000 * 60 * 5; +function updateLink(link, text, url) { + link.innerText = text; + link.setAttribute("href", url); +} + async function updateReleases() { const requests = []; @@ -30,17 +35,10 @@ async function updateReleases() { const release = document.getElementById(device + "-" + channel); const links = release.getElementsByTagName("a"); - links[1].innerText = tag; - links[1].setAttribute("href", versionBaseUrl + tag); - - links[2].innerText = factoryFilename; - links[2].setAttribute("href", factoryUrl); - - links[3].innerText = factoryFilename + ".sig"; - links[3].setAttribute("href", factoryUrl + ".sig"); - - links[4].innerText = updateFilename; - links[4].setAttribute("href", updateUrl); + updateLink(links[1], tag, versionBaseUrl + tag); + updateLink(links[2], factoryFilename, factoryUrl); + updateLink(links[3], factoryFilename + ".sig", factoryUrl + ".sig"); + updateLink(links[4], updateFilename, updateUrl); })); } } |
