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
Raw Normal View History

/*
Sortt
@License MIT
@Author 6543
Credits to Stuart Langridge, http://www.kryogenix.org/code/browser/sortt/ and its contributors
*/
2019-08-27 14:17:53 +00:00
//safe url sort param global
2019-08-27 15:16:17 +00:00
2019-08-27 14:17:53 +00:00
//creat global function with main routine
2019-08-27 14:35:45 +00:00
window.sortt=function(normsort,revsort,isdefault){
//sortTable [normsort] (revsort) (isdefault)
2019-08-27 14:17:53 +00:00
2019-08-27 14:35:45 +00:00
//normsort is needet
if (typeof normsort === 'undefined') return false;
2019-08-27 14:17:53 +00:00
2019-08-27 14:35:45 +00:00
//default values of optinal parameters
if (typeof revsort === 'undefined') revsort = "";
if (typeof isdefault === 'undefined') isdefault = false;
2019-08-27 15:16:17 +00:00
if (!(typeof isdefault === 'boolean')) isdefault = false;
2019-08-27 14:17:53 +00:00
// look at ReadMe
console.log("sortTable() normsort:\"" + normsort + "\" revsort:\"" + revsort + "\" sortdefault:\"" + sortdefault + "\"");
2019-08-27 15:16:17 +00:00
// 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("&"));
}
2019-08-27 14:17:53 +00:00
};