Merge branch 'feature-add-arrow' into develop
This commit is contained in:
commit
9c23f35a9b
35
sortt.js
35
sortt.js
@ -44,6 +44,41 @@ window.sortt=function(normsort,revsort,isdefault){
|
||||
window.location.replace(url.href);
|
||||
};
|
||||
|
||||
//create global function with main routine
|
||||
function getArrow(normsort,revsort,isdefault){
|
||||
//sortt [normsort] (revsort) (isdefault)
|
||||
|
||||
//arrows
|
||||
var arrow_down = '⯆'; // U+2BC6
|
||||
var arrow_up = '⯅'; // U+2BC5
|
||||
|
||||
//normsort is needed
|
||||
if (!(normsort)) return false;
|
||||
|
||||
//default values of optinal parameters
|
||||
if (!(revsort)) revsort = "";
|
||||
|
||||
//get sort param from url
|
||||
let url_sort = (new URL(window.location)).searchParams.get("sort");
|
||||
|
||||
if ((url_sort === null) && isdefault) {
|
||||
//if sort is sorted as default add arrow tho this table header
|
||||
if (isdefault) return arrow_down;
|
||||
} else {
|
||||
//if sort arg is in url test if it corelates with colum header sort arguments
|
||||
if (url_sort === normsort) {
|
||||
//the table is sorted with this header normal
|
||||
return arrow_down;
|
||||
} else if (url_sort === revsort) {
|
||||
//the table is sorted with this header reverse
|
||||
return arrow_up;
|
||||
} else {
|
||||
//the table is NOT sorted with this header
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//USE Functions
|
||||
|
||||
|
Reference in New Issue
Block a user