aboutsummaryrefslogtreecommitdiffstats
path: root/src/assets
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2022-05-31 06:29:15 +0300
committerManeraKai <manerakai@protonmail.com>2022-05-31 06:29:15 +0300
commit81d1e26aefd7c4ab9c70761494d8226032569426 (patch)
treec41437026d6c2adc7225d62be97d6025a9686d9c /src/assets
parentSmall refining #292 (diff)
downloadlibredirect-81d1e26aefd7c4ab9c70761494d8226032569426.zip
Optimizing and fixing bugs #286
Diffstat (limited to 'src/assets')
-rw-r--r--src/assets/javascripts/utils.js29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/assets/javascripts/utils.js b/src/assets/javascripts/utils.js
index f1f18d9f..e3dc2c96 100644
--- a/src/assets/javascripts/utils.js
+++ b/src/assets/javascripts/utils.js
@@ -261,18 +261,18 @@ async function ping(href) {
async function testLatency(element, instances) {
return new Promise(async resolve => {
let myList = {};
- for (const href of instances) await ping(href).then(m => {
- if (m) {
- myList[href] = m;
+ for (const href of instances) await ping(href).then(time => {
+ if (time) {
+ myList[href] = time;
let color;
- if (m <= 1000) color = "green"
- else if (m <= 2000) color = "orange"
+ if (time <= 1000) color = "green"
+ else if (time <= 2000) color = "orange"
else color = "red";
let text;
- if (m == 5000) text = '5000ms+'
- else if (m > 5000) text = `ERROR: ${m - 5000}`;
- else text = `${m}ms`;
+ if (time == 5000) text = '5000ms+'
+ else if (time > 5000) text = `ERROR: ${time - 5000}`;
+ else text = `${time}ms`;
element.innerHTML = `${href}:&nbsp;<span style="color:${color};">${text}</span>`;
}
})
@@ -405,16 +405,9 @@ function switchInstance(test) {
})
}
-function latency(name, frontend, document, location, splitNames) {
- let latencyElement;
- let latencyLabel;
- if (splitNames == true) {
- latencyElement = document.getElementById(`latency-${frontend}`);
- latencyLabel = document.getElementById(`latency-${frontend}-label`);
- } else {
- latencyElement = document.getElementById("latency");
- latencyLabel = document.getElementById("latency-label");
- }
+function latency(name, frontend, document, location) {
+ let latencyElement = document.getElementById(`latency-${frontend}`);
+ let latencyLabel = document.getElementById(`latency-${frontend}-label`);
latencyElement.addEventListener("click",
async () => {
let reloadWindow = () => location.reload();