Шаблон:Онлайн: відмінності між версіями

Матеріал з Бастіон-16
Перейти до навігації Перейти до пошуку
Немає опису редагування
Мітка: Скасовано
Немає опису редагування
 
(Не показані 138 проміжних версій 2 користувачів)
Рядок 1: Рядок 1:
<!DOCTYPE html>
<html>
<html lang="uk">
<head>
<head>
     <meta charset="UTF-8">
     <script src="/resources/status.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>MC Онлайн Гравці</title>
     <title>MC Онлайн Гравці</title>
     <style>
     <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
        }
         #widget {
         #widget {
            border: 2px solid #333;
             padding: 1em;
             padding: 10px;
             box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            width: 300px;
            margin: 20px auto;
             background-color: #f9f9f9;
         }
         }
         #players {
         #players {
            font-weight: bold;
             list-style: none;
             list-style: none;
             padding: 0;
             padding: 0;
            margin: 0;
        }
        #players li {
            display: flex;
            align-items: center;
            padding: 5px 0;
            border-bottom: 1px solid #b1b3b6;
        }
        #players li:last-child {
            border-bottom: none;
        }
        #players img {
            width: 24px;
            height: 24px;
            margin-right: 10px;
            border-radius: 4px;
            border: 1px solid #a2a9b1;
        }
        #players a {
            text-decoration: none;
            color: #555;
        }
        #players a:hover {
            text-decoration: underline;
            color: #007bff;
        }
        .server-header {
            text-align: center;
            margin-bottom: 15px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }
        #playerCount {
            font-size: 1.2em;
            font-weight: bold;
            margin-left: 10px;
        }
        #server-icon {
            width: 64px;
            height: 64px;
            display: block;
            float: left;
        }
        .status-container {
            display: flex;
            align-items: center;
            justify-content: flex-start;
        }
        .status-indicator {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            margin-right: 10px;
            animation: pulse 1.5s infinite;
        }
        .status-online {
            background-color: #4caf50;
            box-shadow: 0 0 10px #4caf50;
        }
        .status-offline {
            background-color: #f44336;
            box-shadow: 0 0 10px #f44336;
        }
        .status-text {
            font-size: 1.2em;
            font-weight: bold;
        }
        .status-online-text {
            color: #4caf50;
        }
        .status-offline-text {
            color: #f44336;
        }
        @keyframes pulse {
            0%, 100% {
                transform: scale(1);
                opacity: 1;
            }
            50% {
                transform: scale(1.2);
                opacity: 0.7;
            }
        }
        #motd {
                font-size: 1.2em;
                font-weight: bold;
              font-weight: bold;
    color: #0056b3;
    background-color: #000000;
    padding: 20px 10px 10px 10px;
    /* border-radius: 4px; */
    margin-bottom: 1em;
          text-align: center;
            height: 34px;
        }
        #server-ip {
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            width: 21%;
            font-size: 1.2em; */
            margin: 1em 0 auto;
            padding: 10px;
            /* background-color: #f1f1f1; */
            /* border: 1px solid #ccc; */
            display: block;
            cursor: pointer;
            text-align: center;
            /* position: absolute; */
            top: 50%;
            background-color: #fff;
            color: #000;
          } 
        #server-ip:hover {
            background-color: #000;
            color: #fff;
        }
        #anketa {
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            width: 21%;
            font-size: 1.2em; */
            margin: 1em 0 auto;
            padding: 10px;
            /* background-color: #f1f1f1; */
            /* border: 1px solid #ccc; */
            display: block;
            cursor: pointer;
            text-align: center;
            /* position: absolute; */
            top: 50%;
            background-color: #fff;
            color: #000;
            text-decoration: none;
          } 
        #anketa:hover {
            background-color: #000;
            color: #fff;
        }
        .link-header {
            display: flex;
            align-items: center;
            justify-content: space-evenly;
         }
         }
     </style>
     </style>
</head>
</head>
<body>
<body>
    <div id="widget">
        <div id="widget">
        <h3>Онлайн гравці:</h3>
            <div class="server-header">
        <p id="playerCount">Завантаження...</p>
                <img id="server-icon" src="" alt="Іконка сервера">
        <ul id="players"></ul>
                <p id="motd" class="info">Завантаження MOTD...</p>
    </div>
            </div>
   
            <div class="link-header">
    <script>
            <p id="server-ip" onclick="copyToClipboard('play.bastion16.co.ua')">IP Сервера</p>
        const SERVER_IP = "play.bastion16.co.ua"; // Замініть на вашу IP-адресу або домен
             <a target=”_blank” href="https://bastion16.co.ua/anketa/survey" id="anketa">Анкета</a>
       
            <a target=”_blank” href="https://map.bastion16.co.ua/" id="anketa">Мапа</a>
        async function fetchServerStatus() {
            <a target=”_blank” href="https://t.me/bastionanketa_bot" id="anketa">Написати адміну</a>
             try {
            </div>
                let response = await fetch(`https://api.mcstatus.io/v2/status/java/${SERVER_IP}`);
            <div class="status-container">
                let data = await response.json();
                 <div id="status-indicator" class="status-indicator status-offline"></div>
               
                 <div id="status-text" class="status-text status-offline-text">Offline</div>
                document.getElementById("playerCount").innerText = `Гравців онлайн: ${data.players.online}`;
                 <p id="playerCount" class="info">Завантаження...</p>
                let playersList = document.getElementById("players");
             </div>
                playersList.innerHTML = "";
            <ul id="players"></ul>
               
         </div>
                if (data.players.online > 0 && data.players.list && data.players.list.length > 0) {
                    data.players.list.forEach(player => {
                        let li = document.createElement("li");
                        li.textContent = player.name_raw || player.name;
                        playersList.appendChild(li);
                    });
                } else {
                    let li = document.createElement("li");
                    li.textContent = "Немає гравців онлайн";
                    playersList.appendChild(li);
                 }
            } catch (error) {
                document.getElementById("playerCount").innerText = "Не вдалося завантажити дані";
                 let playersList = document.getElementById("players");
                playersList.innerHTML = "";
                 let li = document.createElement("li");
                li.textContent = "Помилка завантаження";
                playersList.appendChild(li);
             }
        }
          
        fetchServerStatus();
        setInterval(fetchServerStatus, 30000); // Оновлення кожні 30 секунд
    </script>
</body>
</body>
</html>
</html>

Поточна версія на 16:08, 20 вересня 2025

MC Онлайн Гравці

Іконка сервера

Завантаження MOTD...

Offline

Завантаження...