From ff9f350b5ef4e2e7c3918a29e5fcfd92e59df9f6 Mon Sep 17 00:00:00 2001 From: senza <maximesenzamici@gmail.com> Date: Fri, 11 Mar 2022 03:24:07 +0100 Subject: [PATCH] update displays : handle '?' or '&' in qstring --- united4earth/static/js/main.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/united4earth/static/js/main.js b/united4earth/static/js/main.js index cae1a8e13..9597a1c0e 100644 --- a/united4earth/static/js/main.js +++ b/united4earth/static/js/main.js @@ -461,7 +461,8 @@ function checkFormValidity(formClickEvent,form) { Refresh Solid Display datasrc =*/ function refreshSolidDisplaySrc(form,displayId) { - //console.log("refreshing display, form",form,"display id ",displayId); + queryParameters = {'new':'?','add':'&'} + defaultQueryParameter = queryParameters['new'] //get source of the form let formSrc = form.dataset.src; //break it into URL in order to only select domain & uri for later on @@ -475,7 +476,7 @@ function refreshSolidDisplaySrc(form,displayId) { //make a URL of it const displaySourceUrl = new URL(displaySource); //refresh the source with reconstructed URL to + cache break - displayId.dataset.src = displaySourceUrl.origin + displaySourceUrl.pathname + "?" + Math.random(); + displayId.dataset.src = displaySourceUrl.origin + displaySourceUrl.pathname + defaultQueryParameter + Math.random(); } //if it's a representative form, refresh counter else if (form.id == "representative-email-form") { @@ -484,7 +485,10 @@ function refreshSolidDisplaySrc(form,displayId) { if (emailCounter) { setTimeout(() => { emailCounterDataSrc = emailCounter.dataset.src - emailCounter.dataset.src = emailCounterDataSrc + "?" + Math.random(); + if (emailCounterDataSrc.includes('?')) { + defaultQueryParameter = queryParameters['add'] + } + emailCounter.dataset.src = emailCounterDataSrc + defaultQueryParameter + Math.random(); }, 1500); } } @@ -502,7 +506,10 @@ function refreshSolidDisplaySrc(form,displayId) { //console.log("updating display url",formPath,sibDisplayPath); if (sibDisplayPath == formPath){ //if it does, refresh it - sibDisplay.dataset.src = formSrc + "?" + Math.random() ; + if (formSrc.includes('?')) { + defaultQueryParameter = queryParameters['add'] + } + sibDisplay.dataset.src = formSrc + defaultQueryParameter + Math.random() ; } } }); -- GitLab