bugfix:
* only reload window if corect * parse corectly if no sort= in search but other parameters
This commit is contained in:
parent
9444d57e5d
commit
28eb5848ef
34
sortt.js
34
sortt.js
@ -25,6 +25,7 @@ window.sortt=function(normsort,revsort,isdefault){
|
||||
url_sort="";
|
||||
if (window.location.search.indexOf("sort=") < 0) {
|
||||
if ( isdefault ) url_sort = normsort;
|
||||
url_sort = "";
|
||||
} else {
|
||||
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("&"));
|
||||
@ -38,24 +39,33 @@ window.sortt=function(normsort,revsort,isdefault){
|
||||
url_new = window.location.protocol + "//" + window.location.host + window.location.pathname;
|
||||
if (window.location.search.length == 0) {
|
||||
if (url_sort != normsort) {
|
||||
url_new += "?sort=" + normsort
|
||||
window.location.replace(url_new + "?sort=" + normsort);
|
||||
} else if (revsort != "") {
|
||||
url_new += "?sort=" + revsort
|
||||
window.location.replace(url_new + "?sort=" + revsort);
|
||||
}
|
||||
} else {
|
||||
tmp = window.location.search.substr(window.location.search.indexOf("sort=")+5);
|
||||
if (tmp.indexOf("&") >= 0) {
|
||||
tmp = tmp.substr(tmp.indexOf("&"));
|
||||
} else {
|
||||
tmp = "";
|
||||
if (window.location.search.indexOf("sort=") >= 0) {
|
||||
tmp = window.location.search.substr(window.location.search.indexOf("sort=")+5);
|
||||
if (tmp.indexOf("&") >= 0) {
|
||||
tmp = tmp.substr(tmp.indexOf("&"));
|
||||
} else {
|
||||
tmp = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (url_sort != normsort) {
|
||||
url_new += window.location.search.substr(0,window.location.search.indexOf("sort=")+5) + normsort + tmp;
|
||||
} else if (revsort != "") {
|
||||
url_new += window.location.search.substr(0,window.location.search.indexOf("sort=")+5) + revsort + tmp;
|
||||
if (window.location.search.indexOf("sort=") >= 0) {
|
||||
if (url_sort != normsort) {
|
||||
window.location.replace(url_new + window.location.search.substr(0,window.location.search.indexOf("sort=")+5) + normsort + 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);
|
||||
};
|
||||
|
Reference in New Issue
Block a user