/* Sortt @License MIT @Author 6543 */ //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; // 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 */ let url = new URL(window.location); let url_sort = url.searchParams.get("sort"); if ((url_sort === null) && isdefault) url_sort = normsort; // generate new URL /* script check if url_sort and sort attribute is same NO: generate URL with sort param YES: check if reverse attribute exist -> YES: generate URL with reverse sort param */ if (url_sort != normsort) { url.searchParams.delete("sort"); url.searchParams.append("sort",normsort); } else if (revsort != "") { url.searchParams.delete("sort"); url.searchParams.append("sort",revsort); } //open url window.location.replace(url.href); };