Compare commits
No commits in common. "c403bff0eca936a46cd159734248e08d636dd7a0" and "37aabb3dfcd981ff81e84c45e9663dcb51ee024d" have entirely different histories.
c403bff0ec
...
37aabb3dfc
|
@ -146,7 +146,7 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div style="width: 100%; overflow-y: scroll; display: none;" id="datapanel" class="controlpanel">
|
<div style="width: 100%; overflow-y: scroll; display: none;" id="datapanel" class="controlpanel">
|
||||||
<table id="dataTable">
|
<table>
|
||||||
<thead><tr><th>Published</th><th>What</th><th>Who</th><th>Last sang this song</th><th>Last dueted with performer</th></th></thead>
|
<thead><tr><th>Published</th><th>What</th><th>Who</th><th>Last sang this song</th><th>Last dueted with performer</th></th></thead>
|
||||||
{{ range .SongData }}
|
{{ range .SongData }}
|
||||||
<tr><td title="{{ .Date }}">{{ .NiceDate }}</td><td>{{ .SongTitle }}</td><td>{{ .OtherSinger }}</td><td title="{{ .LastSungSong }}">{{ .NiceLastSungSong }}</td><td title="{{ .LastSungSinger }}">{{ .NiceLastSungSinger }}</td></tr>
|
<tr><td title="{{ .Date }}">{{ .NiceDate }}</td><td>{{ .SongTitle }}</td><td>{{ .OtherSinger }}</td><td title="{{ .LastSungSong }}">{{ .NiceLastSungSong }}</td><td title="{{ .LastSungSinger }}">{{ .NiceLastSungSinger }}</td></tr>
|
||||||
|
@ -207,62 +207,6 @@
|
||||||
}
|
}
|
||||||
document.getElementById(self.id+"panel").style.display = "block"
|
document.getElementById(self.id+"panel").style.display = "block"
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Modified and more readable version of the answer by Paul S. to sort a table with ASC and DESC order
|
|
||||||
* with the <thead> and <tbody> structure easily.
|
|
||||||
*
|
|
||||||
* https://stackoverflow.com/a/14268260/4241030
|
|
||||||
*/
|
|
||||||
var TableSorter = {
|
|
||||||
makeSortable: function(table){
|
|
||||||
// Store context of this in the object
|
|
||||||
var _this = this;
|
|
||||||
var th = table.tHead, i;
|
|
||||||
th && (th = th.rows[0]) && (th = th.cells);
|
|
||||||
|
|
||||||
if (th){
|
|
||||||
i = th.length;
|
|
||||||
}else{
|
|
||||||
return; // if no `<thead>` then do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loop through every <th> 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 `<tbody>` to ignore `<thead>` and `<tfoot>` 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"));
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
</main>
|
</main>
|
||||||
<footer class="mastfoot mt-auto">
|
<footer class="mastfoot mt-auto">
|
||||||
|
|
Loading…
Reference in New Issue