first fersion of algo finished
This commit is contained in:
parent
4b59391a36
commit
2813577c4c
32
sortt.js
32
sortt.js
@ -20,6 +20,10 @@ window.sortt=function(normsort,revsort,isdefault){
|
|||||||
if (!(typeof isdefault === 'boolean')) isdefault = false;
|
if (!(typeof isdefault === 'boolean')) isdefault = false;
|
||||||
|
|
||||||
// parse URL
|
// parse URL
|
||||||
|
/* script check if url has already a sort=
|
||||||
|
NO: if sort=“” indikates default (with * prefix) set url_sort=
|
||||||
|
YES: set url_sort variable
|
||||||
|
*/
|
||||||
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;
|
||||||
@ -28,8 +32,32 @@ window.sortt=function(normsort,revsort,isdefault){
|
|||||||
url_sort=url_sort.substr(0,url_sort.indexOf("&"));
|
url_sort=url_sort.substr(0,url_sort.indexOf("&"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// generate new URL
|
||||||
|
/* script check if url_sort and sort attribute is same
|
||||||
|
YES: check if reverse attribute exist -> YES: generate URL with reverse sort param and open
|
||||||
|
NO: generate URL with sort param and open
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
} else if (revsort != "") {
|
||||||
|
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 (url_sort != normsort) {
|
||||||
|
url_new = tmp.substr(0,window.location.search.indexOf("sort=")+5) + normsort + tmp;
|
||||||
|
} else if (revsort != "") {
|
||||||
|
url_new = tmp.substr(0,window.location.search.indexOf("sort=")+5) + revsort + tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.replace(url_new);
|
||||||
//window.location.replace("http://localhost:3000/admin/repos?sort=feweststars&q=&tab=");
|
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user