diff --git a/web/admin.html b/web/admin.html index 00e2eaa..ab7c0a2 100755 --- a/web/admin.html +++ b/web/admin.html @@ -146,7 +146,7 @@
Published | What | Who | Last sang this song | Last dueted with performer |
---|---|---|---|---|
{{ .NiceDate }} | {{ .SongTitle }} | {{ .OtherSinger }} | {{ .NiceLastSungSong }} | {{ .NiceLastSungSinger }} | inside the header + while (--i >= 0) (function (i) { + var dir = 1; + + // Append click listener to sort + th[i].addEventListener('click', function () { + _this._sort(table, i, (dir = 1 - dir)); + }); + }(i)); + }, + _sort: function (table, col, reverse) { + var tb = table.tBodies[0], // use ` | ` to ignore `` and `` rows + tr = Array.prototype.slice.call(tb.rows, 0), // put rows into array + i; + + reverse = -((+reverse) || -1); + + // Sort rows + tr = tr.sort(function (a, b) { + // `-1 *` if want opposite order + return reverse * ( + // Using `.textContent.trim()` for test + a.cells[col].textContent.trim().localeCompare( + b.cells[col].textContent.trim() + ) + ); + }); + + for(i = 0; i < tr.length; ++i){ + // Append rows in new order + tb.appendChild(tr[i]); + } + } + }; + window.onload = function(){ + TableSorter.makeSortable(document.getElementById("dataTable")); + };