logo

demo

Unnamed repository; edit this file 'description' to name the repository.

sorttable.min.js (1491B)


      1 sorttable={done:!1,init:function(){if(!sorttable.done){sorttable.done=!0;var r=document.getElementsByClassName("sortable");Array.prototype.filter.call(r,function(r){"TABLE"==r.nodeName&&sorttable.t(r)})}},t:function(r){if(1==r.tHead.rows.length){headrow=r.tHead.rows[0].cells;for(var t=0;t<headrow.length;t++)headrow[t].classList.contains("sorttable_nosort")||(headrow[t].o=t,headrow[t].s=r.tBodies[0],headrow[t].addEventListener("click",sorttable.l),headrow[t].classList.add("made_sortable"))}},l:function(r){if(this.classList.contains("sorttable_sorted"))sorttable.reverse(this.s),this.classList.replace("sorttable_sorted","sorttable_sorted_reverse");else if(this.classList.contains("sorttable_sorted_reverse"))sorttable.reverse(this.s),this.classList.replace("sorttable_sorted_reverse","sorttable_sorted");else{theadRow=this.parentNode,theadRow.childNodes.forEach(function(r){r.classList.remove("sorttable_sorted_reverse","sorttable_sorted")}),row_array=[],col=this.o,rows=this.s.rows;for(var t=0;t<rows.length;t++)row_array[row_array.length]=[sorttable.i(rows[t].cells[col]),rows[t]];row_array.sort().reverse(),tb=this.s,row_array.forEach(function(r){tb.appendChild(r[1])}),delete row_array,this.classList.add("sorttable_sorted")}},i:function(r){return r.dataset.value?r.dataset.value:r.innerText},reverse:function(r){newrows=[];for(var t=0;t<r.rows.length;t++)newrows[newrows.length]=r.rows[t];for(t=newrows.length-1;0<=t;t--)r.appendChild(newrows[t]);delete newrows}},sorttable.init();