projects-jenz/server_info/html/servers_info.html
2026-02-13 21:48:37 +01:00

138 lines
5.2 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UNLOZE Server Status</title>
<style>
body { font-family: 'Segoe UI', sans-serif; background: #121212; color: #e0e0e0; padding: 20px; margin: 0; }
.container { max-width: 900px; margin: auto; }
.server-card {
background: #1e1e1e;
border-radius: 8px;
padding: 15px;
margin-bottom: 10px;
border-left: 5px solid #00ff41;
transition: background 0.2s;
}
.card-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.info-main { flex-grow: 1; }
.server-name { font-weight: bold; font-size: 1.1em; color: #00ff41; }
.server-sub { font-size: 0.9em; color: #aaa; }
.stats { text-align: right; min-width: 100px; margin-right: 15px; }
.players-count { font-size: 1.2em; font-weight: bold; color: #fff; }
.btn-connect {
background: #00ff41; color: #000; text-decoration: none;
padding: 8px 15px; border-radius: 4px; font-weight: bold; font-size: 0.8em;
}
/* Player List Styling */
.player-list-container {
display: none; /* Hidden by default */
margin-top: 15px;
padding-top: 15px;
border-top: 1px solid #333;
}
.player-table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
.player-table th { text-align: left; color: #00ff41; padding-bottom: 5px; border-bottom: 1px solid #333; }
.player-table td { padding: 5px 0; border-bottom: 1px solid #252525; }
.duration { color: #888; font-style: italic; }
</style>
</head>
<body>
<div class="container">
<div id="server-list">Loading servers...</div>
</div>
<script>
function formatTime(seconds) {
const h = Math.floor(seconds / 3600);
const m = Math.floor((seconds % 3600) / 60);
return h > 0 ? `${h}h ${m}m` : `${m}m`;
}
function togglePlayers(id) {
const el = document.getElementById(`players-${id}`);
el.style.display = el.style.display === 'block' ? 'none' : 'block';
sendHeight(); // Recalculate iframe height when expanding
}
async function loadServers() {
try {
const response = await fetch('servers.json');
const data = await response.json();
const listContainer = document.getElementById('server-list');
listContainer.innerHTML = '';
data.forEach((server, index) => {
const card = document.createElement('div');
card.className = 'server-card';
// Build Player Table rows
let playerRows = '';
if (server.player_infos && server.player_infos.length > 0) {
server.player_infos.forEach(p => {
playerRows += `
<tr>
<td>${p.name}</td>
<td>${p.score}</td>
<td class="duration">${formatTime(p.duration)}</td>
</tr>`;
});
} else {
playerRows = '<tr><td colspan="3" style="text-align:center; padding:10px;">No players online</td></tr>';
}
card.innerHTML = `
<div class="card-header" onclick="togglePlayers(${index})">
<div class="info-main">
<div class="server-name">${server.name}</div>
<div class="server-sub">Map: <strong>${server.map}</strong></div>
<div class="server-sub" style="color: #00ff41; font-family: monospace; margin-top: 4px;">
IP: ${server.ip}
</div>
</div>
<div class="stats">
<div class="players-count">${server.players}</div>
<div class="server-sub">Players Online</div>
</div>
<a href="steam://connect/${server.ip}" class="btn-connect" onclick="event.stopPropagation()">CONNECT</a>
</div>
<div class="player-list-container" id="players-${index}">
<table class="player-table">
<thead>
<tr><th>Player Name</th><th>Score</th><th>Time</th></tr>
</thead>
<tbody>${playerRows}</tbody>
</table>
</div>
`;
listContainer.appendChild(card);
});
sendHeight();
} catch (error) {
console.error('Error:', error);
}
}
function sendHeight() {
const height = document.body.scrollHeight + 40;
window.parent.postMessage({ type: 'setHeight', height: height }, '*');
}
loadServers();
setInterval(loadServers, 30000);
</script>
</body>
</html>