Skip to content

Commit

Permalink
map
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitaldot committed Jun 28, 2024
1 parent 99c78be commit d4b890a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions website/freddit.net/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
const mcapi = 'https://eu.mc-api.net/v3/server'

const servers = [
{'name': 'Freddit Freebuild', 'address': 'play.freddit.net'},
{'name': 'Freddit Survival', 'address': 'survival.freddit.net'}
{'name': 'Freddit Freebuild', 'address': 'play.freddit.net', 'map_url': 'https://map.freddit.net'},
{'name': 'Freddit Survival', 'address': 'survival.freddit.net', 'map_url': 'https://survivalmap.freddit.net'}

]

Expand All @@ -73,7 +73,7 @@
toast.show();
}

const serverStatusCardHTML = (server_name, server_address, status, players, version) => {
const serverStatusCardHTML = (server_name, server_address, status, map_url, players, version) => {
return `
<div class="col-md-4 p-2">
<div class="card">
Expand All @@ -85,6 +85,7 @@
</div>
<div class="card-body">
<p>${players} player${players !== 1 ? 's' : ''} online</p>
<button class="btn btn-sm btn-outline-primary" onclick="window.open('${map_url}')">Map</button>
</div>
<div class="card-footer" onclick="copyToClipboard('${server_address}')" style="cursor: pointer;">
<code>${server_address}</code>
Expand All @@ -97,12 +98,12 @@
servers.forEach(server => {
$.get(mcapi + "/ping/" + server.address, function(data) {
if (data.error) {
$('#server-status').append(serverStatusCardHTML(server.name, server.address, 'offline', 0))
$('#server-status').append(serverStatusCardHTML(server.name, server.address, 'offline', server.map_url, 0))
return
}
$('#server-status').append(serverStatusCardHTML(server.name, server.address, 'online', data.players.online, data.version.name))
$('#server-status').append(serverStatusCardHTML(server.name, server.address, 'online', data.players.online, server.map_url, data.version.name))
}).fail(function() {
$('#server-status').append(serverStatusCardHTML(server.name, server.address, 'offline', 0))
$('#server-status').append(serverStatusCardHTML(server.name, server.address, 'offline', server.map_url, 0))
})
})
</script>
Expand Down

0 comments on commit d4b890a

Please sign in to comment.