feat: Add refresh button to latency check
All checks were successful
Build Docker / Build_Docker (push) Successful in 36s

This commit is contained in:
Nathan Woodburn 2024-10-09 21:09:13 +11:00
parent d393e01a91
commit 7296e5bc45
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -188,7 +188,10 @@
<th>Region</th>
<th>Region ID</th>
<th># of nodes</th>
<th>Latency</th>
<th>Latency&nbsp;<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 24 24" width="1em" fill="currentColor" id="refresh-ping" style="color: rgb(255,255,255);">
<path d="M0 0h24v24H0z" fill="none"></path>
<path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"></path>
</svg></th>
</tr>
</thead>
<tbody>
@ -257,10 +260,19 @@ function pingServer(id) {
});
});
}
function runPingTest() {
const regions = ["au", "eu", "na", "as", "ap"];
const pingPromises = regions.map(region => pingServer(region));
regions.forEach(region => {
const spanId = `${region}-ping`;
const spanElement = document.getElementById(spanId);
if (spanElement) {
spanElement.textContent = "Pinging..."; // Show Pinging... while waiting for results
}
});
Promise.all(pingPromises)
.then(results => {
console.log("Ping results:", results);
@ -281,6 +293,15 @@ Promise.all(pingPromises)
.catch(error => {
console.error("Error pinging servers:", error);
});
}
runPingTest();
// Add event listener to the refresh link
document.getElementById('refresh-ping').addEventListener('click', function (event) {
event.preventDefault(); // Prevent the default link behavior
runPingTest(); // Re-run the ping test
});
</script>
</div>