a h1 script table tbody td th thead tr
https://fossil.one/ Repository List UTF-8 F26CA71A98DBF3F717AADC87AE61030D #document HTML visible HEAD #text BASE href META name viewport content width=device-width, initial-scale=1.0 TITLE BODY H1 align center Fossil Repositories TABLE border 0 class sortable data-init-sort 1 data-column-types txtxkxt THEAD TR TH  sort asc style cursor: pointer; Filename width 20  sort none Project Name Last Modified Login Group TBODY TD valign top A /crushv/transcode-sync/home target _blank crushv/transcode-sync.fossil Transcode n Sync data-sortkey 042df0ac 2.22 years /miso/home miso.fossil Miso 02cf4b5f 1.49 years /psteapp/home psteapp.fossil Pste App 0345cf84 1.74 years /schappi/shelltools/home schappi/shelltools.fossil Shell Tools 042cf9cb /toast/binbuilder/home toast/binbuilder.fossil Binary Builder 0355a70e 1.77 years /toast/cni-lua/home toast/cni-lua.fossil CNI Lua 04236443 2.20 years /toast/kot/home toast/kot.fossil Kot 025e0cbe 1.26 years /toast/rubberstamp/home toast/rubberstamp.fossil Rubberstamp 041bafbf 2.18 years /toast/static/home toast/static.fossil Static Websites 00175f6a 17.7 days /tt/truetactics/home tt/truetactics.fossil True Tactics 0359f64e 1.78 years SCRIPT function SortableTable(tableEl){
var columnTypes = tableEl.getAttribute("data-column-types");
var initSort = tableEl.getAttribute("data-init-sort");
this.tbody = tableEl.getElementsByTagName('tbody');
this.columnTypes = columnTypes;
if(tableEl.rows.length==0) return;
var ncols = tableEl.rows[0].cells.length;
for(var i = columnTypes.length; i<=ncols; i++){this.columnTypes += 't';}
this.sort = function (cell) {
var column = cell.cellIndex;
var sortFn;
switch( cell.sortType ){
case "n": sortFn = this.sortNumeric;  break;
case "N": sortFn = this.sortReverseNumeric;  break;
case "t": sortFn = this.sortText;  break;
case "T": sortFn = this.sortReverseText;  break;
case "k": sortFn = this.sortKey;  break;
case "K": sortFn = this.sortReverseKey;  break;
default:  return;
}
this.sortIndex = column;
var newRows = new Array();
for (j = 0; j < this.tbody[0].rows.length; j++) {
newRows[j] = this.tbody[0].rows[j];
}
if( this.sortIndex==Math.abs(this.prevColumn)-1 ){
newRows.reverse();
this.prevColumn = -this.prevColumn;
}else{
newRows.sort(sortFn);
this.prevColumn = this.sortIndex+1;
}
for (i=0;i<newRows.length;i++) {
this.tbody[0].appendChild(newRows[i]);
}
this.setHdrIcons();
}
this.setHdrIcons = function() {
for (var i=0; i<this.hdrRow.cells.length; i++) {
if( this.columnTypes[i]=='x' ) continue;
var sortType;
if( this.prevColumn==i+1 ){
sortType = 'asc';
}else if( this.prevColumn==(-1-i) ){
sortType = 'desc'
}else{
sortType = 'none';
}
var hdrCell = this.hdrRow.cells[i];
var clsName = hdrCell.className.replace(/\s*\bsort\s*\w+/, '');
clsName += ' sort ' + sortType;
hdrCell.className = clsName;
}
}
this.sortText = function(a,b) {
var i = thisObject.sortIndex;
aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
if(aa<bb) return -1;
if(aa==bb) return a.rowIndex-b.rowIndex;
return 1;
}
this.sortReverseText = function(a,b) {
var i = thisObject.sortIndex;
aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase();
if(aa<bb) return +1;
if(aa==bb) return a.rowIndex-b.rowIndex;
return -1;
}
this.sortNumeric = function(a,b) {
var i = thisObject.sortIndex;
aa = parseFloat(a.cells[i].textContent);
if (isNaN(aa)) aa = 0;
bb = parseFloat(b.cells[i].textContent);
if (isNaN(bb)) bb = 0;
if(aa==bb) return a.rowIndex-b.rowIndex;
return aa-bb;
}
this.sortReverseNumeric = function(a,b) {
var i = thisObject.sortIndex;
aa = parseFloat(a.cells[i].textContent);
if (isNaN(aa)) aa = 0;
bb = parseFloat(b.cells[i].textContent);
if (isNaN(bb)) bb = 0;
if(aa==bb) return a.rowIndex-b.rowIndex;
return bb-aa;
}
this.sortKey = function(a,b) {
var i = thisObject.sortIndex;
aa = a.cells[i].getAttribute("data-sortkey");
bb = b.cells[i].getAttribute("data-sortkey");
if(aa<bb) return -1;
if(aa==bb) return a.rowIndex-b.rowIndex;
return 1;
}
this.sortReverseKey = function(a,b) {
var i = thisObject.sortIndex;
aa = a.cells[i].getAttribute("data-sortkey");
bb = b.cells[i].getAttribute("data-sortkey");
if(aa<bb) return +1;
if(aa==bb) return a.rowIndex-b.rowIndex;
return -1;
}
var x = tableEl.getElementsByTagName('thead');
if(!(this.tbody && this.tbody[0].rows && this.tbody[0].rows.length>0)){
return;
}
if(x && x[0].rows && x[0].rows.length > 0) {
this.hdrRow = x[0].rows[0];
} else {
return;
}
var thisObject = this;
this.prevColumn = initSort;
for (var i=0; i<this.hdrRow.cells.length; i++) {
if( columnTypes[i]=='x' ) continue;
var hdrcell = this.hdrRow.cells[i];
hdrcell.sTable = this;
hdrcell.style.cursor = "pointer";
hdrcell.sortType = columnTypes[i] || 't';
hdrcell.onclick = function () {
this.sTable.sort(this);
return false;
}
}
this.setHdrIcons()
}
(function(){
var x = document.getElementsByClassName("sortable");
for(var i=0; i<x.length; i++){
new SortableTable(x[i]);
}
}())
