2018-03-15 15:12:18 +00:00
|
|
|
$(function () {
|
|
|
|
const instancesApi = 'https://instances.peertu.be/api/v1/instances'
|
|
|
|
const data = {
|
|
|
|
start: 0,
|
|
|
|
count: 100,
|
|
|
|
signup: true,
|
|
|
|
healthy: true
|
|
|
|
}
|
2018-03-15 15:36:41 +00:00
|
|
|
const instancesListElement = $('#instances-list')
|
2018-03-15 15:12:18 +00:00
|
|
|
|
2018-03-15 15:36:41 +00:00
|
|
|
$.get(instancesApi, data)
|
|
|
|
.done(function (res) {
|
|
|
|
const instances = res.data
|
2018-03-15 15:12:18 +00:00
|
|
|
|
2018-03-15 15:36:41 +00:00
|
|
|
const lis = []
|
|
|
|
instances.forEach(function (instance) {
|
|
|
|
const el = createInstanceElement(instance.host, instance.name, instance.shortDescription)
|
|
|
|
lis.push(el)
|
|
|
|
})
|
2018-03-15 15:12:18 +00:00
|
|
|
|
2018-03-15 15:36:41 +00:00
|
|
|
instancesListElement.append(lis)
|
|
|
|
})
|
|
|
|
.fail(function (err) {
|
|
|
|
$('#instances-list-error').css('display', 'block')
|
|
|
|
})
|
2018-03-15 15:12:18 +00:00
|
|
|
|
|
|
|
function createInstanceElement (host, name, description) {
|
|
|
|
const a = $('<a>', {
|
|
|
|
class: 'list-group-item',
|
|
|
|
href: 'https://' + host,
|
|
|
|
target: '_blank',
|
|
|
|
title: host
|
|
|
|
})
|
|
|
|
|
|
|
|
const h4 = $('<h4>', {
|
|
|
|
class: 'list-group-item-heading',
|
|
|
|
text: name
|
|
|
|
})
|
|
|
|
a.append(h4)
|
|
|
|
|
|
|
|
if (description) {
|
|
|
|
const p = $('<p>', {
|
|
|
|
class: 'list-group-item-text',
|
|
|
|
text: description
|
|
|
|
})
|
|
|
|
a.append(p)
|
|
|
|
}
|
|
|
|
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
})
|