{"id":60,"date":"2026-01-17T16:58:59","date_gmt":"2026-01-17T22:58:59","guid":{"rendered":"https:\/\/www.dirtymindsinc.net\/?page_id=60"},"modified":"2026-01-17T18:21:59","modified_gmt":"2026-01-18T00:21:59","slug":"game-server-status","status":"publish","type":"page","link":"https:\/\/www.dirtymindsinc.net\/?page_id=60","title":{"rendered":"Game Server Status"},"content":{"rendered":"\n<div id=\"server-status\">\n  <div class=\"server-status-loading\">Loading server status&#8230;<\/div>\n<\/div>\n\n<style>\n  #server-status {\n    font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n    max-width: 400px;\n  }\n  #server-status .server-card {\n    padding: 16px;\n    border-radius: 8px;\n    background: #1a1a2e;\n    color: #eee;\n    margin-bottom: 12px;\n  }\n  #server-status .server-card:last-child { margin-bottom: 0; }\n  #server-status .status-online { color: #4ade80; }\n  #server-status .status-offline { color: #f87171; }\n  #server-status .server-name { font-size: 1.2em; font-weight: bold; margin-bottom: 8px; }\n  #server-status .server-info { display: flex; justify-content: space-between; margin: 4px 0; }\n  #server-status .server-info span:first-child { color: #9ca3af; }\n  #server-status .player-list { margin-top: 12px; border-top: 1px solid #374151; padding-top: 12px; }\n  #server-status .player-list-header { color: #9ca3af; font-size: 0.9em; margin-bottom: 8px; cursor: pointer; }\n  #server-status .player-list-header:hover { color: #eee; }\n  #server-status .player { display: flex; justify-content: space-between; font-size: 0.9em; padding: 4px 0; }\n  #server-status .player-name { color: #eee; }\n  #server-status .player-time { color: #9ca3af; }\n  #server-status .no-players { color: #6b7280; font-style: italic; font-size: 0.9em; }\n  #server-status .last-updated { font-size: 0.8em; color: #6b7280; margin-top: 8px; text-align: right; }\n<\/style>\n\n<script>\n(function() {\n  const API_URL = 'https:\/\/api.dirtymindsinc.net';  \/\/ Change this\n  const REFRESH_INTERVAL = 30000;  \/\/ Refresh every 30 seconds\n  const SERVERS = [\n    { host: '99.52.186.221', port: 2303, label: 'Server 1' },\n    { host: '99.52.186.221', port: 2403, label: 'Server 2' }\n  ];\n\n  function formatDuration(seconds) {\n    const hrs = Math.floor(seconds \/ 3600);\n    const mins = Math.floor((seconds % 3600) \/ 60);\n    if (hrs > 0) return `${hrs}h ${mins}m`;\n    return `${mins}m`;\n  }\n\n  function renderPlayerList(players) {\n    if (!players || players.length === 0) {\n      return '<div class=\"no-players\">No players online<\/div>';\n    }\n    return players\n      .sort((a, b) => b.duration - a.duration)\n      .map(p => `\n        <div class=\"player\">\n          <span class=\"player-name\">${p.name}<\/span>\n          <span class=\"player-time\">${formatDuration(p.duration)}<\/span>\n        <\/div>\n      `).join('');\n  }\n\n  function renderServer(server, status) {\n    const label = server.label || `${server.host}:${server.port}`;\n    if (status.online) {\n      return `\n        <div class=\"server-card\">\n          <div class=\"server-name\">${status.name || label}<\/div>\n          <div class=\"server-info\"><span>Status<\/span><span class=\"status-online\">\u25cf Online<\/span><\/div>\n          <div class=\"server-info\"><span>Players<\/span><span>${status.players}\/${status.max_players}<\/span><\/div>\n          <div class=\"server-info\"><span>Map<\/span><span>${status.map}<\/span><\/div>\n          <div class=\"player-list\">\n            <div class=\"player-list-header\">Players Online<\/div>\n            ${renderPlayerList(status.player_list)}\n          <\/div>\n        <\/div>\n      `;\n    } else {\n      return `\n        <div class=\"server-card\">\n          <div class=\"server-name\">${label}<\/div>\n          <div class=\"server-info\"><span>Status<\/span><span class=\"status-offline\">\u25cf Offline<\/span><\/div>\n        <\/div>\n      `;\n    }\n  }\n\n  function fetchStatus() {\n    fetch(`${API_URL}\/status\/bulk`, {\n      method: 'POST',\n      headers: { 'Content-Type': 'application\/json' },\n      body: JSON.stringify({ servers: SERVERS.map(s => ({ host: s.host, port: s.port })) })\n    })\n      .then(res => res.json())\n      .then(data => {\n        const container = document.getElementById('server-status');\n        const html = data.map((result, i) => renderServer(SERVERS[i], result.status)).join('');\n        const time = new Date().toLocaleTimeString();\n        container.innerHTML = html + `<div class=\"last-updated\">Last updated: ${time}<\/div>`;\n      })\n      .catch(() => {\n        document.getElementById('server-status').innerHTML =\n          '<div class=\"server-card\"><div class=\"status-offline\">Failed to load server status<\/div><\/div>';\n      });\n  }\n\n  fetchStatus();\n  setInterval(fetchStatus, REFRESH_INTERVAL);\n})();\n<\/script>\n\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Loading server status&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-60","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.dirtymindsinc.net\/index.php?rest_route=\/wp\/v2\/pages\/60","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dirtymindsinc.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.dirtymindsinc.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.dirtymindsinc.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dirtymindsinc.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=60"}],"version-history":[{"count":7,"href":"https:\/\/www.dirtymindsinc.net\/index.php?rest_route=\/wp\/v2\/pages\/60\/revisions"}],"predecessor-version":[{"id":70,"href":"https:\/\/www.dirtymindsinc.net\/index.php?rest_route=\/wp\/v2\/pages\/60\/revisions\/70"}],"wp:attachment":[{"href":"https:\/\/www.dirtymindsinc.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}