From 8f41e2d58c0e894aaf93d2e21f5c37feecbe9209 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 28 May 2021 12:59:48 +0200 Subject: [PATCH] Add retry button which clears local storage if something goes wrong --- index.ts | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/index.ts b/index.ts index c6391f25b..ed7728501 100644 --- a/index.ts +++ b/index.ts @@ -73,21 +73,32 @@ const userLayoutParam = QueryParameters.GetQueryParameter("userlayout", "false", if (layoutToUse?.id === "cyclofix") { const legacy = QueryParameters.GetQueryParameter("layer-bike_shops", "true", "Legacy - keep De Fietsambassade working"); const correct = QueryParameters.GetQueryParameter("layer-bike_shop", "true", "Legacy - keep De Fietsambassade working") - if(legacy.data !== "true"){ - correct.setData(legacy.data) + if (legacy.data !== "true") { + correct.setData(legacy.data) } - console.log("layer-bike_shop toggles: legacy:",legacy.data, "new:", correct.data) + console.log("layer-bike_shop toggles: legacy:", legacy.data, "new:", correct.data) const legacyCafe = QueryParameters.GetQueryParameter("layer-bike_cafes", "true", "Legacy - keep De Fietsambassade working") const correctCafe = QueryParameters.GetQueryParameter("layer-bike_cafe", "true", "Legacy - keep De Fietsambassade working") - if(legacyCafe.data !== "true"){ + if (legacyCafe.data !== "true") { correctCafe.setData(legacy.data) } } const layoutFromBase64 = decodeURIComponent(userLayoutParam.data); -document.getElementById('centermessage').innerText = ''; +document.getElementById('centermessage').innerText = 'Initilai'; + +new Combine(["Initializing...
", + new FixedUiElement("If this message persist, something went wrong - click here to try again") + .SetClass("link-underline small") + .onClick(() => { + localStorage.clear(); + window.location.reload(true); + + })]) + .AttachTo("centermessage"); // Add an initialization and reset button if something goes wrong + document.getElementById("decoration-desktop").remove(); @@ -106,7 +117,7 @@ if (layoutFromBase64.startsWith("http")) { let parsed = data; if (typeof parsed == "string") { parsed = JSON.parse(data); - }else{ + } else { data = JSON.stringify(parsed) // De wereld op zijn kop } // Overwrite the id to the wiki:value @@ -147,8 +158,8 @@ if (layoutFromBase64.startsWith("http")) { } // Remove all context event listeners on mobile to prevent long presses window.addEventListener('contextmenu', (e) => { // Not compatible with IE < 9 - - if(e.target["nodeName"] === "INPUT"){ + + if (e.target["nodeName"] === "INPUT") { return; } e.preventDefault();