From 75f600d20083be4bf39608e12be8f6823ff0841c Mon Sep 17 00:00:00 2001 From: bordun Date: Sat, 1 May 2021 16:15:09 +0200 Subject: [PATCH] docs: fancy download links --- resources/docs/download.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/resources/docs/download.md b/resources/docs/download.md index 8150ffe0..e6df6c79 100644 --- a/resources/docs/download.md +++ b/resources/docs/download.md @@ -20,6 +20,14 @@ function text(id, str) { el.textContent = str } +var names = { + 'amd64': 'GNU/Linux Debian (64-bit)', + 'linux-x64': 'GNU/Linux (64-bit)', + 'node': 'Node.js', + 'osx': 'MacOS', + 'win32-x64': 'Windows (64-bit)' +} + function reqListener () { var data = JSON.parse(this.responseText) @@ -30,9 +38,16 @@ function reqListener () { var list = document.createElement('ul') for (var i in data.assets) { var item = document.createElement('li'), - link = document.createElement('a') + link = document.createElement('a'), + name = data.assets[i].name - link.textContent = data.assets[i].name + ' (' + (data.assets[i].size / 1024 / 1024).toFixed(1) + 'M)' + try { + name = names[name.match(/[0-9]+\.[0-9]+\.[0-9]+\-([^\.]+)/)[1]] + } catch(e) { + console.log(e) + } + + link.innerHTML = ' ' + name + ' (' + (data.assets[i].size / 1024 / 1024).toFixed(0) + 'M)' link.href = data.assets[i].browser_download_url item.appendChild(link) @@ -67,6 +82,16 @@ html { margin-left: .8rem; margin-right: .6rem; } +li { + list-style: none; +} +li i { + margin-right: 10px +} +.download-size { + color: var(--md-typeset-color); + opacity: 0.5; +}