up
This commit is contained in:
@@ -32,4 +32,27 @@ async function loadLatestBuild() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadServerStatus() {
|
||||
const status = document.getElementById('server-status');
|
||||
try {
|
||||
const response = await fetch('/minecraft/api/status', {
|
||||
cache: 'no-store',
|
||||
signal: AbortSignal.timeout(10000),
|
||||
});
|
||||
if (!response.ok) throw new Error('Статус недоступен');
|
||||
const data = await response.json();
|
||||
if (data?.online === false) {
|
||||
status.textContent = 'Сервер недоступен';
|
||||
} else if (data?.online === true && Number.isSafeInteger(data.players?.online) && data.players.online >= 0) {
|
||||
status.textContent = `Игроков онлайн: ${data.players.online}`;
|
||||
} else {
|
||||
throw new Error('Неизвестный формат статуса');
|
||||
}
|
||||
} catch {
|
||||
status.textContent = 'Не удалось получить онлайн';
|
||||
}
|
||||
}
|
||||
|
||||
loadLatestBuild();
|
||||
loadServerStatus();
|
||||
setInterval(loadServerStatus, 5 * 60 * 1000);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
<h1>Твой следующий<br>мир начинается здесь.</h1>
|
||||
<p class="intro">Скачай сборку, импортируй её в Prism Launcher и заходи на сервер.</p>
|
||||
<p class="server">Адрес сервера <code>90.189.218.191:25565</code></p>
|
||||
<p id="server-status" role="status">Проверяем онлайн…</p>
|
||||
<a class="button secondary" href="https://telemost.yandex.ru/j/76726739040099?skip_app=1" target="_blank" rel="noopener noreferrer">Подключиться к Телемосту ↗</a>
|
||||
</header>
|
||||
|
||||
<div class="downloads">
|
||||
|
||||
Reference in New Issue
Block a user