From 694f83921c5c43de47ce1b7298fbadcdd7a7a012 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Sun, 22 Dec 2024 04:52:16 +0200 Subject: AKFS get function from map hash --- src/js/arching-kaos-fetch.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/js/arching-kaos-fetch.js') diff --git a/src/js/arching-kaos-fetch.js b/src/js/arching-kaos-fetch.js index 5f27728..6cf1b76 100644 --- a/src/js/arching-kaos-fetch.js +++ b/src/js/arching-kaos-fetch.js @@ -65,4 +65,32 @@ export async function archingKaosFetchText( url, callback, params ){ request.open("GET", url); request.send(); } + +export function archingKaosFetchBlob( url, callback, params ){ + const request = new XMLHttpRequest(); + request.addEventListener("load", ()=>{ + var blob = request.response; + if(request.status !== 404){ + callback(blob, params); + } else { + archingKaosLog(`ERROR ${request.status} while loading ${url}`); + } + }); + request.addEventListener("error", ()=>{ + debugLog("An error occured."); + }); + request.addEventListener("progress", (event)=>{ + if (event.lengthComputable && progressPlaceholder()){ + httpProgressPlaceholder().value = (event.loaded / event.total) * 100; + } else { + httpProgressPlaceholder.value = 0; + debugLog("Supposingly zeroed progressPlaceholder"); + } + }); + request.addEventListener("abort", ()=>{ + debugLog("Request aborted."); + }); + request.open("GET", url); + request.send(); +} // @license-end -- cgit v1.2.3