docs: fancy download links
This commit is contained in:
parent
e0cd1bf163
commit
75f600d200
1 changed files with 27 additions and 2 deletions
|
|
@ -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 = '<i class="fa fa-download"></i> ' + name + ' <span class="download-size">(' + (data.assets[i].size / 1024 / 1024).toFixed(0) + 'M)</span>'
|
||||
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;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue