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>
<div class="container">
<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>
</body>
<script>
@ -16,23 +16,18 @@ let loading = document.getElementById("loading");
let stats = document.getElementById("stats");
async function pingServer() {
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()
stats.innerHTML = `
<tr>
<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>
</tr>
<tr>
<td><code>ping</code> ${doc.ping}</td>
<td><code>roundtrip</code> ${doc.roundtrip}</td>
<td><code>time</code> ${doc.time}</td>
</tr>`;
loading.remove();
} 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()
setInterval(pingServer, 1000 * 60);