default.js: add parseUrl

Users were seeing outdated content due to browser caching. To resolve
this issue, a unique random value is now added to the end of each URL
every time the page is loaded, forcing the browser to retrieve the
latest version of the page from the server.  By implementing this
solution, users will be able to see the most recent content without any
delay caused by outdated cache files.
This commit is contained in:
Milan
2023-03-23 22:15:12 +01:00
parent 3b79d20142
commit b4da29dd36
3 changed files with 20 additions and 2 deletions

View File

@@ -78,14 +78,28 @@ function contains(s,t){
}
function updateContainer(id, url, callback){
//alert(id+":"+url);
if (id==null) return;
if ($("#"+id).length==0) return;
url = parseUrl(url);
$("#"+id).load(url, callback);
}
function load(url){
window.location=url;
window.location = parseUrl(url);
}
function parseUrl(uri){
if (uri.startsWith("/")) {
uri = window.location.origin + uri;
} else if (!uri.startsWith("http")) {
var path = window.location.pathname.replace(/\/$/, "");
path = path.split("/");
path.pop();
uri = window.location.origin + path.join("/") + "/" + uri;
}
var url = new URL(uri);
url.searchParams.append("_", Date.now());
return url.toString();
}
function postContainer(url, parameters, callback){

View File

@@ -83,6 +83,8 @@ function updateEventSelection(resultElemId){
}
var elem=$("#selectEvent").parent();
url = parseUrl(url);
console.log(url);
$(elem).load(url);
}

View File

@@ -36,7 +36,9 @@ function updateSeriesSelection(resultElemId){
url+="&selectProjectStudio=1";
}
url = parseUrl(url);
var elem=$("#selectSeries").parent();
console.log(url);
$(elem).load(url);
}