add url parsing to sortt function

This commit is contained in:
6543 2019-08-27 17:16:17 +02:00
parent fe10eabff8
commit 7833ab0dcf
Signed by: 6543
GPG Key ID: A1CA74D27FD13271

View File

@ -7,15 +7,7 @@
*/

//safe url sort param global
window.sortt_url=window.location.search;
if (window.sortt_url.indexOf("sort=") < 0) {
//no sort url argument found
window.sortt_url="";

} else {
window.sortt_url=window.sortt_url.substr(window.sortt_url.indexOf("sort=")+5);
window.sortt_url=window.sortt_url.substr(0,window.sortt_url.indexOf("&"));
}
//creat global function with main routine
window.sortt=function(normsort,revsort,isdefault){
//sortTable [normsort] (revsort) (isdefault)
@ -26,8 +18,22 @@ window.sortt=function(normsort,revsort,isdefault){
//default values of optinal parameters
if (typeof revsort === 'undefined') revsort = "";
if (typeof isdefault === 'undefined') isdefault = false;
if (!(typeof isdefault === 'boolean')) isdefault = false;

// look at ReadMe
console.log("sortTable() normsort:\"" + normsort + "\" revsort:\"" + revsort + "\" sortdefault:\"" + sortdefault + "\"");

// parse URL
url_sort="";
if (window.location.search.indexOf("sort=") < 0) {
if ( isdefault ) url_sort = normsort;
} else {
url_sort=window.location.search.substr(window.location.search.indexOf("sort=")+5);
url_sort=url_sort.substr(0,url_sort.indexOf("&"));
}





};