From 25d9f1314e0b50a6a8c83307b3adf13ce5ac9f79 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 7 Nov 2024 12:53:09 +1100 Subject: [PATCH] fix: Round ping to the nearest int --- public/index.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index 193b57f..0c506d8 100644 --- a/public/index.html +++ b/public/index.html @@ -235,7 +235,6 @@ resolve({ id, pingTime: null, error: "Error: Invalid server ID" }); return; } - console.log("Pinging server for " + id); const startTime = performance.now(); // Record the start time const serverUrl = `https://${id}.hnsdoh.com/dns-query?dns=CagBAAABAAAAAAAACHdvb2RidXJuAAABAAE=`; @@ -250,9 +249,11 @@ .then(response => { const endTime = performance.now(); // Record the end time const pingTime = endTime - startTime; // Calculate ping time + // Round the ping time to the nearest integer + const pingTimeRounded = Math.round(pingTime); // Resolve with the ID and ping time - resolve({ id, pingTime, error: null }); + resolve({ id, pingTime:pingTimeRounded, error: null }); }) .catch(error => { // Resolve with an error message instead of rejecting