|
|
| Рядок 1: |
Рядок 1: |
| <html> | | <!DOCTYPE html> |
| | <html lang="uk"> |
| <head> | | <head> |
| | <meta charset="UTF-8"> |
| | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>MC Онлайн Гравці</title> | | <title>MC Онлайн Гравці</title> |
| <style> | | <style> |
| | body { |
| | font-family: 'Helvetica Neue', Arial, sans-serif; |
| | margin: 0; |
| | padding: 0; |
| | background-color: #f8f9fa; |
| | color: #202122; |
| | } |
| | .mw-body { |
| | padding: 2em; |
| | max-width: 960px; |
| | margin: 0 auto; |
| | background-color: #ffffff; |
| | border: 1px solid #a2a9b1; |
| | border-radius: 4px; |
| | } |
| | .mw-headline { |
| | font-size: 1.5em; |
| | margin-bottom: 0.5em; |
| | border-bottom: 1px solid #a2a9b1; |
| | padding-bottom: 0.3em; |
| | } |
| #widget { | | #widget { |
| padding: 1em; | | padding: 1em; |
| Рядок 52: |
Рядок 76: |
| </div> | | </div> |
|
| |
|
| <script>
| |
| const SERVER_IP = "play.bastion16.co.ua"; // Замініть на вашу IP-адресу або домен
| |
|
| |
| const fetchServerStatus = async () => {
| |
| try {
| |
| console.log("Виконую запит до mcstatus.io...");
| |
| const response = await fetch(`https://api.mcstatus.io/v2/status/java/${SERVER_IP}`);
| |
| if (!response.ok) throw new Error(`HTTP помилка! Статус: ${response.status}`);
| |
| const data = await response.json();
| |
| console.log("Отримані дані:", data);
| |
|
| |
| const motdElement = document.getElementById("motd");
| |
| motdElement.innerHTML = data.motd?.html?.join(" ") || "Сервер без MOTD";
| |
|
| |
| const playerCountElement = document.getElementById("playerCount");
| |
| playerCountElement.innerText = `Гравців онлайн: ${data.players?.online || 0}`;
| |
|
| |
| const playersElement = document.getElementById("players");
| |
| playersElement.innerHTML = "";
| |
|
| |
| if (data.players?.online > 0 && data.players.list?.length > 0) {
| |
| data.players.list.forEach(player => {
| |
| const playerName = player.name_raw || player.name;
| |
| const playerSkinURL = `https://mineskin.eu/helm/${playerName}/24.png`;
| |
|
| |
| const listItem = document.createElement("li");
| |
| const img = document.createElement("img");
| |
| const span = document.createElement("span");
| |
|
| |
| img.src = playerSkinURL;
| |
| img.alt = playerName;
| |
| span.textContent = playerName;
| |
|
| |
| listItem.appendChild(img);
| |
| listItem.appendChild(span);
| |
| playersElement.appendChild(listItem);
| |
| });
| |
| } else {
| |
| playersElement.innerHTML = "<li>Немає гравців онлайн</li>";
| |
| }
| |
|
| |
| const serverIconElement = document.getElementById("server-icon");
| |
| if (data.icon) {
| |
| serverIconElement.src = data.icon;
| |
| serverIconElement.style.display = "block";
| |
| } else {
| |
| serverIconElement.style.display = "none";
| |
| }
| |
| } catch (error) {
| |
| console.error("Помилка під час отримання статусу сервера:", error);
| |
| document.getElementById("motd").innerText = "Не вдалося завантажити MOTD";
| |
| document.getElementById("playerCount").innerText = "Не вдалося завантажити дані";
| |
| document.getElementById("players").innerHTML = "<li>Помилка завантаження</li>";
| |
| }
| |
| };
| |
|
| |
| fetchServerStatus();
| |
| setInterval(fetchServerStatus, 30000); // Оновлення кожні 30 секунд
| |
| </script>
| |
| </body> | | </body> |
| </html> | | </html> |