From 3e5f48b66fd17630fbfa767b764330e13d6fac68 Mon Sep 17 00:00:00 2001 From: amadmate <82boma1bif@hft-stuttgart.de> Date: Tue, 18 Jan 2022 17:00:09 +0100 Subject: [PATCH] change method --- public/js/connectToAPI.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/public/js/connectToAPI.js b/public/js/connectToAPI.js index 96c395b..9a07f1a 100644 --- a/public/js/connectToAPI.js +++ b/public/js/connectToAPI.js @@ -424,26 +424,26 @@ function timeout(ms, promise) { function pageLoad() { if (window.location.hash === "#load-bau1") { - loadAndZoomToTileset(tilesetURLb1); + fetchTileset(tilesetURLb1); }if (window.location.hash === "#load-bau2") { - loadAndZoomToTileset(tilesetURLb2); - }if (window.location.hash === "#load-bau4") { - loadAndZoomToTileset(tilesetURLb4); - }if (window.location.hash === "#load-bau5") { - loadAndZoomToTileset(tilesetURLb5); - }if (window.location.hash === "#load-bau6") { - loadAndZoomToTileset(tilesetURLb6); - }if (window.location.hash === "#load-bau7") { - loadAndZoomToTileset(tilesetURLb7); - }if (window.location.hash === "#load-bau8") { - loadAndZoomToTileset(tilesetURLb8); - } + fetchTileset(tilesetURLb2); + }if (window.location.hash === "#load-bau4") { + fetchTileset(tilesetURLb4); + }if (window.location.hash === "#load-bau5") { + fetchTileset(tilesetURLb5); + }if (window.location.hash === "#load-bau6") { + fetchTileset(tilesetURLb6); + }if (window.location.hash === "#load-bau7") { + fetchTileset(tilesetURLb7); + }if (window.location.hash === "#load-bau8") { + fetchTileset(tilesetURLb8); + } } //fetching the tileset and handling the connection -async function fetchTileset(){ - timeout(1000, fetch(tilesetURL)).then((response)=>{ - loadAndZoomToTileset(tilesetURL); +async function fetchTileset(tileset){ + timeout(1000, fetch(tileset)).then((response)=>{ + loadAndZoomToTileset(tileset); }).catch((error)=>{ //catching the error(no connection)/ timeout and displaying an alert for the user //var errorString = error["stack"]+"\n"+error["message"]; // formatting the error array swal({text:"Could not connect to Server. Using now: local data",icon:"info" } ); -- GitLab