sortable file list

This commit is contained in:
ed 2020-05-07 00:08:06 +02:00
parent 5b55d05a20
commit ee96005026
5 changed files with 37 additions and 4 deletions

View file

@ -104,10 +104,8 @@ in the `scripts` folder:
roughly sorted by priority
* sortable browser columns
* up2k handle filename too long
* up2k fails on empty files? alert then stuck
* unexpected filepath on dupe up2k
* drop onto folders
* look into android thumbnail cache file format
* support pillow-simd

View file

@ -68,7 +68,7 @@ a {
}
#files thead th:last-child {
background: #444;
border-radius: .7em 0 0 0;
border-radius: .7em .7em 0 0;
}
#files thead th:first-child {
background: #222;

View file

@ -34,6 +34,7 @@ window.onerror = function (msg, url, lineNo, columnNo, error) {
esc(String(error[find[a]])).replace(/\n/g, '<br />\n'));
}
document.body.style.fontSize = '0.8em';
document.body.style.padding = '0 1em 1em 1em';
hcroak(html.join('\n'));
};
@ -78,6 +79,39 @@ function ev(e) {
}
function sortTable(table, col) {
var tb = table.tBodies[0], // use `<tbody>` to ignore `<thead>` and `<tfoot>` rows
th = table.tHead.rows[0].cells,
tr = Array.prototype.slice.call(tb.rows, 0),
i, reverse = th[col].className == 'sort1' ? -1 : 1;
for (var a = 0, thl = th.length; a < thl; a++)
th[a].className = '';
th[col].className = 'sort' + reverse;
var stype = th[col].getAttribute('sort');
tr = tr.sort(function (a, b) {
var v1 = a.cells[col].textContent.trim();
var v2 = b.cells[col].textContent.trim();
if (stype == 'int') {
v1 = parseInt(v1.replace(/,/g, ''));
v2 = parseInt(v2.replace(/,/g, ''));
return reverse * (v1 - v2);
}
return reverse * (v1.localeCompare(v2));
});
for (i = 0; i < tr.length; ++i) tb.appendChild(tr[i]);
}
function makeSortable(table) {
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
while (--i >= 0) (function (i) {
th[i].addEventListener('click', function () { sortTable(table, i) });
}(i));
}
makeSortable(o('files'));
// extract songs + add play column
var mp = (function () {
var tracks = [];

View file

@ -34,6 +34,7 @@ window.onerror = function (msg, url, lineNo, columnNo, error) {
esc(String(error[find[a]])).replace(/\n/g, '<br />\n'));
}
document.body.style.fontSize = '0.8em';
document.body.style.padding = '0 1em 1em 1em';
hcroak(html.join('\n'));
};

View file

@ -101,7 +101,7 @@ grep -lE '\.full\.(js|css)' copyparty/web/* |
while IFS= read -r x; do sed -ri 's/\.full\.(js|css)/.\1/g' "$x"; done
[ $no_ogv ] &&
rm -rf copyparty/web/deps/{dynamicaudio,ogv}* copyparty/web/browser.js
rm -rf copyparty/web/deps/{dynamicaudio,ogv}*
echo creating tar
args=(--owner=1000 --group=1000)