fix: improved widged example

This commit is contained in:
əlemi 2024-02-17 04:35:34 +01:00
parent a57afe0e3c
commit 0a0603a338
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -7,7 +7,7 @@
<body> <body>
<div class="container"> <div class="container">
<h3 id="loading">loading...</h3> <h3 id="loading">loading...</h3>
<p><table id="stats" class="w-100 align"></table></p> <p style="margin:0"><table id="stats" class="w-100 align"></table></p>
</div> </div>
</body> </body>
<script> <script>
@ -16,23 +16,18 @@ let loading = document.getElementById("loading");
let stats = document.getElementById("stats"); let stats = document.getElementById("stats");
async function pingServer() { async function pingServer() {
try { try {
let res = await fetch("https://api.fantabos.co/mumble/ping") let res = await fetch("https://api.alemi.dev/mumble/ping?host=<<YOUR_SERVER_HERE>>")
let doc = await res.json() let doc = await res.json()
stats.innerHTML = ` stats.innerHTML = `
<tr> <tr>
<td><code>users</code> ${doc.users}/${doc.max_users}</td> <td><code>users</code> ${doc.users}/${doc.max_users}</td>
<td><code>bandwidth</code> ${doc.bandwidth}</td> <td><code>net</code> ${doc.bandwidth/1000}kbps ~ ${doc.latency}ms</td>
<td><code>version</code> ${doc.version}</td> <td><code>version</code> ${doc.version}</td>
</tr>
<tr>
<td><code>ping</code> ${doc.ping}</td>
<td><code>roundtrip</code> ${doc.roundtrip}</td>
<td><code>time</code> ${doc.time}</td>
</tr>`; </tr>`;
loading.remove();
} catch (e) { } catch (e) {
loading.innerHTML = `error reaching api: ${e}`; stats.innerHTML = `<tr><td><b>error reaching api</b>: <code>${e}</code></td></tr>`;
} }
loading.remove();
} }
pingServer() pingServer()
setInterval(pingServer, 1000 * 60); setInterval(pingServer, 1000 * 60);