This repository has been archived on 2020-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
gitea_sortt/sortt.js

40 lines
1.0 KiB
JavaScript

/*
Sortt
@License MIT
@Author 6543
Credits to Stuart Langridge, http://www.kryogenix.org/code/browser/sortt/ and its contributors
*/
//safe url sort param global
//creat global function with main routine
window.sortt=function(normsort,revsort,isdefault){
//sortTable [normsort] (revsort) (isdefault)
//normsort is needet
if (typeof normsort === 'undefined') return false;
//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("&"));
}
};