* only reload window if corect
* parse corectly if no sort= in search but other parameters
This commit is contained in:
6543 2019-08-27 18:48:23 +02:00
parent 9444d57e5d
commit 28eb5848ef
Signed by: 6543
GPG Key ID: A1CA74D27FD13271

View File

@ -25,6 +25,7 @@ window.sortt=function(normsort,revsort,isdefault){
url_sort=""; url_sort="";
if (window.location.search.indexOf("sort=") < 0) { if (window.location.search.indexOf("sort=") < 0) {
if ( isdefault ) url_sort = normsort; if ( isdefault ) url_sort = normsort;
url_sort = "";
} else { } else {
url_sort=window.location.search.substr(window.location.search.indexOf("sort=")+5); url_sort=window.location.search.substr(window.location.search.indexOf("sort=")+5);
if (url_sort.indexOf("&") >= 0) url_sort=url_sort.substr(0,url_sort.indexOf("&")); if (url_sort.indexOf("&") >= 0) url_sort=url_sort.substr(0,url_sort.indexOf("&"));
@ -38,24 +39,33 @@ window.sortt=function(normsort,revsort,isdefault){
url_new = window.location.protocol + "//" + window.location.host + window.location.pathname; url_new = window.location.protocol + "//" + window.location.host + window.location.pathname;
if (window.location.search.length == 0) { if (window.location.search.length == 0) {
if (url_sort != normsort) { if (url_sort != normsort) {
url_new += "?sort=" + normsort window.location.replace(url_new + "?sort=" + normsort);
} else if (revsort != "") { } else if (revsort != "") {
url_new += "?sort=" + revsort window.location.replace(url_new + "?sort=" + revsort);
} }
} else { } else {
tmp = window.location.search.substr(window.location.search.indexOf("sort=")+5); if (window.location.search.indexOf("sort=") >= 0) {
if (tmp.indexOf("&") >= 0) { tmp = window.location.search.substr(window.location.search.indexOf("sort=")+5);
tmp = tmp.substr(tmp.indexOf("&")); if (tmp.indexOf("&") >= 0) {
} else { tmp = tmp.substr(tmp.indexOf("&"));
tmp = ""; } else {
tmp = "";
}
} }


if (url_sort != normsort) { if (window.location.search.indexOf("sort=") >= 0) {
url_new += window.location.search.substr(0,window.location.search.indexOf("sort=")+5) + normsort + tmp; if (url_sort != normsort) {
} else if (revsort != "") { window.location.replace(url_new + window.location.search.substr(0,window.location.search.indexOf("sort=")+5) + normsort + tmp);
url_new += window.location.search.substr(0,window.location.search.indexOf("sort=")+5) + revsort + tmp; } else if (revsort != "") {
window.location.replace(url_new + window.location.search.substr(0,window.location.search.indexOf("sort=")+5) + revsort + tmp);
}
} else {
if (url_sort != normsort) {
window.location.replace(url_new + window.location.search + "&sort=" + normsort);
} else if (revsort != "") {
window.location.replace(url_new + window.location.search + "&sort=" + revsort);
}
} }
} }


window.location.replace(url_new);
}; };