I lied to your face and you show love

Why do you reward me with your love?
This commit is contained in:
MeowcaTheoRange 2024-01-22 10:06:54 -06:00
parent db77ca5ccd
commit 8707ae9e39
2 changed files with 52 additions and 5 deletions

View file

@ -1,10 +1,51 @@
const data_get = document.getElementById("data_get"); 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") fetch_ask("https://blog.abtmtr.link/api/collections/paste/posts/domain")
.then((x) => x.json()) .then((x) => x.json())
.then((paste) => { .then((paste) => {
const data = JSON.parse(paste.data.body); const data = JSON.parse(paste.data.body);
data_get.innerHTML = data.reduce( data.push({
(html, subdomain) => 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 + html +
`<h1><a href="${subdomain.url}" target="_blank">${ `<h1><a href="${subdomain.url}" target="_blank">${
subdomain.name subdomain.name
@ -12,7 +53,12 @@ fetch_ask("https://blog.abtmtr.link/api/collections/paste/posts/domain")
${subdomain.description.map((x) => `<p>${x}</p>`).join("")} ${subdomain.description.map((x) => `<p>${x}</p>`).join("")}
<img src="${subdomain.src}" alt="${subdomain.name}" title="${ <img src="${subdomain.src}" alt="${subdomain.name}" title="${
subdomain.name subdomain.name
}" />`, }" />
"" <p>
<button
onclick="check_uptime(event, '${subdomain.url}')"
>Check Status</button>
<span id="${id}"></span></p>`
); );
}, "");
}); });

View file

@ -1,4 +1,5 @@
const data_get = document.getElementById("data_get"); const data_get = document.getElementById("data_get");
fetch_ask("./public/projects.json") fetch_ask("./public/projects.json")
.then((x) => x.json()) .then((x) => x.json())
.then((projects) => { .then((projects) => {