12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Online Players on Source of Mana</title>
- </head>
- <body>
- <h3>Online Players on Source of Mana (<span id="time"></span>):</h3>
- <table border="1" cellspacing="1">
- <thead>
- <tr>
- <th>Name</th>
- </tr>
- </thead>
- <tbody id="players"></tbody>
- </table>
- <p><span id="user-count"></span> users are online.</p>
- <script>
- const count = document.getElementById("user-count");
- const playerTable = document.getElementById("players");
- const updateTime = document.getElementById("time");
- function refresh() {
- fetch("./online.json")
- .then((response) => response.json())
- .then((players) => {
- updateTime.innerText = new Date().toLocaleString();
- count.innerText = players.length;
- // clear old entries
- playerTable.innerHTML = "";
- for (const player of players) {
- const td = document.createElement("td");
- td.innerText = player;
- const tr = document.createElement("tr");
- tr.appendChild(td);
- playerTable.appendChild(tr);
- }
- });
- }
- setInterval(refresh, 10 * 1000 /*milliseconds */);
- refresh()
- </script>
- </body>
- </html>
|