From b3799613de5f3b60bbf5a71819989bdbde778d12 Mon Sep 17 00:00:00 2001 From: orbitaldot Date: Sun, 30 Jun 2024 15:32:58 +0200 Subject: [PATCH] update website --- website/freddit.net/index.html | 69 ++-------------------------------- website/freddit.net/src.js | 55 +++++++++++++++++++++++++++ website/freddit.net/style.css | 9 +++++ 3 files changed, 67 insertions(+), 66 deletions(-) create mode 100644 website/freddit.net/src.js create mode 100644 website/freddit.net/style.css diff --git a/website/freddit.net/index.html b/website/freddit.net/index.html index eed3225..693663c 100644 --- a/website/freddit.net/index.html +++ b/website/freddit.net/index.html @@ -1,28 +1,15 @@ - Freddit Freebuild - - + Freddit Freebuild + - - @@ -38,7 +25,6 @@ -
Copied! @@ -53,54 +39,5 @@ - - + \ No newline at end of file diff --git a/website/freddit.net/src.js b/website/freddit.net/src.js new file mode 100644 index 0000000..c2773a1 --- /dev/null +++ b/website/freddit.net/src.js @@ -0,0 +1,55 @@ +const mcapi = 'https://eu.mc-api.net/v3/server' + +const servers = [ + { + 'name': 'Freddit Freebuild', + 'address': 'play.freddit.net', + 'map_url': 'http://map.freddit.net' + }, + { + 'name': 'Freddit Survival', + 'address': 'survival.freddit.net', + 'map_url': 'https://survivalmap.freddit.net' + } +] + +const copyToClipboard = (text) => { + navigator.clipboard.writeText(text) + var toastEl = document.getElementById('copied-toast'); + var toast = new bootstrap.Toast(toastEl); + toast.show(); +} + +const serverStatusCardHTML = (server_name, server_address, status, map_url, players, version) => { + return ` +
+
+
+ Server icon + ${server_name} +
${status}
+ ${version ? `${version}` : ''} +
+
+

${players} player${players !== 1 ? 's' : ''} online

+ +
+ +
+
+ ` +} + +servers.forEach(server => { + $.get(mcapi + "/ping/" + server.address, function(data) { + if (data.error) { + $('#server-status').append(serverStatusCardHTML(server.name, server.address, 'offline', server.map_url, 0)) + return + } + $('#server-status').append(serverStatusCardHTML(server.name, server.address, 'online', server.map_url, data.players.online, data.version.name)) + }).fail(function() { + $('#server-status').append(serverStatusCardHTML(server.name, server.address, 'offline', server.map_url, 0)) + }) +}) \ No newline at end of file diff --git a/website/freddit.net/style.css b/website/freddit.net/style.css new file mode 100644 index 0000000..c9e5fac --- /dev/null +++ b/website/freddit.net/style.css @@ -0,0 +1,9 @@ +main { + max-width: 600px; + margin: 0 auto; + padding: 20px; +} +code { + border-radius: 4px; + padding: 2px 4px; +} \ No newline at end of file