add func getArrow
this return a arrow char if colum header corelates with sort param in url
This commit is contained in:
parent
0ba4bb3e26
commit
35b566ed07
32
sortt.js
32
sortt.js
@ -45,6 +45,38 @@ window.sortt=function(normsort,revsort,isdefault){
|
|||||||
window.location.replace(url.href);
|
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 (url_sort === normsort) {
|
||||||
|
return arrow_down;
|
||||||
|
} else if (url_sort === revsort) {
|
||||||
|
return arrow_up;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//USE Functions
|
//USE Functions
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user