mirror of
https://git.alemi.dev/mumble-stats-api.git
synced 2024-11-22 16:04:49 +01:00
fix: improved widged example
This commit is contained in:
parent
a57afe0e3c
commit
0a0603a338
1 changed files with 5 additions and 10 deletions
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue