From 8707ae9e3937b38dcc1de87aecbe3f119ebd81c5 Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange Date: Mon, 22 Jan 2024 10:06:54 -0600 Subject: [PATCH] I lied to your face and you show love Why do you reward me with your love? --- views/domain/scripts/data_get_domain.js | 56 +++++++++++++++++++-- views/projects/scripts/data_get_projects.js | 1 + 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/views/domain/scripts/data_get_domain.js b/views/domain/scripts/data_get_domain.js index 281c3c4..0a4cc5d 100644 --- a/views/domain/scripts/data_get_domain.js +++ b/views/domain/scripts/data_get_domain.js @@ -1,10 +1,51 @@ const data_get = document.getElementById("data_get"); + +function check_uptime(event, url) { + const outElement = event.target; + const startTime = performance.now(); + let status, time, timer; + outElement.disabled = true; + fetch_ask(url, { mode: "no-cors", cache: "no-cache" }) + .then((res) => { + const endTime = performance.now(); + time = ((endTime - startTime) / 1000).toFixed(2); + outElement.innerHTML = `Check Status (${time}s)`; + }) + .catch((err) => { + const endTime = performance.now(); + time = ((endTime - startTime) / 1000).toFixed(2); + outElement.innerHTML = `Check Status (${time}s - Error)`; + }) + .finally(() => { + window.cancelAnimationFrame(timer); + outElement.disabled = false; + }); + function timeCounter() { + const curTime = performance.now(); + time = (curTime - startTime) / 1000; + if (time >= 5) + outElement.innerHTML = `Check Status (${time.toFixed( + 2 + )}s - Taking longer than usual)`; + else outElement.innerHTML = `Check Status (${time.toFixed(2)}s - Waiting)`; + timer = window.requestAnimationFrame(timeCounter); + } + timer = window.requestAnimationFrame(timeCounter); +} + fetch_ask("https://blog.abtmtr.link/api/collections/paste/posts/domain") .then((x) => x.json()) .then((paste) => { const data = JSON.parse(paste.data.body); - data_get.innerHTML = data.reduce( - (html, subdomain) => + data.push({ + name: "Broken Link", + description: ["Broken on purpose. Get to testing!"], + url: "https://xyz.abtmtr.link/", + src: "https://cdn.abtmtr.link/88x31/abtmtr_link.png", + }); + data_get.innerHTML = data.reduce((html, subdomain) => { + const id = `${subdomain.name.replaceAll(".", "")}-uptime`; + return ( html + `

${ subdomain.name @@ -12,7 +53,12 @@ fetch_ask("https://blog.abtmtr.link/api/collections/paste/posts/domain") ${subdomain.description.map((x) => `

${x}

`).join("")} ${subdomain.name}`, - "" - ); + }" /> +

+ +

` + ); + }, ""); }); diff --git a/views/projects/scripts/data_get_projects.js b/views/projects/scripts/data_get_projects.js index 5e4c837..b5f193d 100644 --- a/views/projects/scripts/data_get_projects.js +++ b/views/projects/scripts/data_get_projects.js @@ -1,4 +1,5 @@ const data_get = document.getElementById("data_get"); + fetch_ask("./public/projects.json") .then((x) => x.json()) .then((projects) => {