Add stats information

This commit is contained in:
Chocobozzz 2018-03-16 11:32:58 +01:00
parent 9c8eebbcb9
commit 6ed5bd68dd
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 69 additions and 12 deletions

View file

@ -62,7 +62,7 @@ p {
}
.content p:last-child {
margin: 0 !important;
margin: 0;
}
/* Sections background */
@ -209,20 +209,45 @@ body .medias .container {
#instances-list .list-group-item {
height: 70px;
display: flex;
flex-direction: row;
justify-content: center;
}
#instances-list .list-group-item .left-div {
display: flex;
flex-direction: column;
justify-content: center;
flex-grow: 1;
}
#instances-list .list-group-item .right-div {
display: flex;
flex-direction: column;
justify-content: center;
width: 140px;
}
#instances-list .list-group-item .right-div li {
font-size: 0.8em;
font-weight: bold;
}
#instances-list .list-group-item .list-group-item-heading {
margin-bottom: 0;
}
#instances-list .list-group-item .instance-host {
display: inline-block;
margin-left: 5px;
}
#instances-list .list-group-item .list-group-item-text {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-top: 5px;
font-size: 0.8em;
}
.footer {

View file

@ -14,38 +14,70 @@ $(function () {
const lis = []
instances.forEach(function (instance) {
const el = createInstanceElement(instance.host, instance.name, instance.shortDescription)
const el = createInstanceElement(instance)
lis.push(el)
})
instancesListElement.append(lis)
})
.fail(function (err) {
.fail(function () {
$('#instances-list-error').css('display', 'block')
})
function createInstanceElement (host, name, description) {
function createInstanceElement (instance) {
const a = $('<a>', {
class: 'list-group-item',
href: 'https://' + host,
href: 'https://' + instance.host,
target: '_blank',
title: host
title: instance.host
})
const leftDiv = $('<div>', {
class: 'left-div'
})
const rightDiv = $('<div>', {
class: 'right-div'
})
const h4 = $('<h4>', {
class: 'list-group-item-heading',
text: name
class: 'list-group-item-heading'
})
a.append(h4)
const spanName = $('<span>', {
text: instance.name,
class: 'instance-name'
})
const spanHost = $('<small>', {
text: instance.host,
class: 'instance-host'
})
h4.append(spanName, spanHost)
leftDiv.append(h4)
if (description) {
if (instance.shortDescription) {
const p = $('<p>', {
class: 'list-group-item-text',
text: description
text: instance.shortDescription
})
a.append(p)
leftDiv.append(p)
}
if (instance.totalInstanceFollowers) {
const li = $('<li>', {
text: instance.totalInstanceFollowers + ' followers'
})
rightDiv.append(li)
}
if (instance.totalInstanceFollowing) {
const li = $('<li>', {
text: 'Follows ' + instance.totalInstanceFollowing + ' instances'
})
rightDiv.append(li)
}
a.append(leftDiv, rightDiv)
return a
}
})