diff --git a/sortt.js b/sortt.js index d478b79..31aee0a 100644 --- a/sortt.js +++ b/sortt.js @@ -45,6 +45,38 @@ 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 (url_sort === normsort) { + return arrow_down; + } else if (url_sort === revsort) { + return arrow_up; + } else { + return false; + } + } +} + //USE Functions