mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 09:22:31 -06:00
faster sorting
This commit is contained in:
parent
b0b97a2648
commit
92bb00c6d2
|
@ -121,6 +121,8 @@ a,
|
||||||
#files tbody tr:last-child td {
|
#files tbody tr:last-child td {
|
||||||
padding-bottom: 1.3em;
|
padding-bottom: 1.3em;
|
||||||
border-bottom: .5em solid #444;
|
border-bottom: .5em solid #444;
|
||||||
|
}
|
||||||
|
#files tbody tr td:last-child {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
#files thead th[style] {
|
#files thead th[style] {
|
||||||
|
|
|
@ -606,7 +606,7 @@ function autoplay_blocked() {
|
||||||
}
|
}
|
||||||
ebi('srch_form').innerHTML = html.join('\n');
|
ebi('srch_form').innerHTML = html.join('\n');
|
||||||
|
|
||||||
var o = document.querySelectorAll('#op_search input[type="text"]');
|
var o = document.querySelectorAll('#op_search input');
|
||||||
for (var a = 0; a < o.length; a++) {
|
for (var a = 0; a < o.length; a++) {
|
||||||
o[a].oninput = ev_search_input;
|
o[a].oninput = ev_search_input;
|
||||||
}
|
}
|
||||||
|
@ -615,8 +615,11 @@ function autoplay_blocked() {
|
||||||
|
|
||||||
function ev_search_input() {
|
function ev_search_input() {
|
||||||
var v = this.value;
|
var v = this.value;
|
||||||
var chk = ebi(this.getAttribute('id').slice(0, -1) + 'c');
|
var id = this.getAttribute('id');
|
||||||
|
if (id.slice(-1) == 'v') {
|
||||||
|
var chk = ebi(id.slice(0, -1) + 'c');
|
||||||
chk.checked = ((v + '').length > 0);
|
chk.checked = ((v + '').length > 0);
|
||||||
|
}
|
||||||
clearTimeout(search_timeout);
|
clearTimeout(search_timeout);
|
||||||
search_timeout = setTimeout(do_search, 100);
|
search_timeout = setTimeout(do_search, 100);
|
||||||
}
|
}
|
||||||
|
@ -1158,7 +1161,6 @@ function reload_browser(not_mp) {
|
||||||
hsz = sz.replace(/\B(?=(\d{3})+(?!\d))/g, " ");
|
hsz = sz.replace(/\B(?=(\d{3})+(?!\d))/g, " ");
|
||||||
|
|
||||||
oo[a].textContent = hsz;
|
oo[a].textContent = hsz;
|
||||||
oo[a].setAttribute("sortv", sz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!not_mp) {
|
if (!not_mp) {
|
||||||
|
|
|
@ -99,22 +99,33 @@ function sortTable(table, col) {
|
||||||
th[a].className = th[a].className.replace(/ *sort-?1 */, " ");
|
th[a].className = th[a].className.replace(/ *sort-?1 */, " ");
|
||||||
th[col].className += ' sort' + reverse;
|
th[col].className += ' sort' + reverse;
|
||||||
var stype = th[col].getAttribute('sort');
|
var stype = th[col].getAttribute('sort');
|
||||||
tr = tr.sort(function (a, b) {
|
var vl = [];
|
||||||
if (!a.cells[col])
|
for (var a = 0; a < tr.length; a++) {
|
||||||
|
var cell = tr[a].cells[col];
|
||||||
|
if (!cell) {
|
||||||
|
vl.push([null, a]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var v = cell.getAttribute('sortv') || cell.textContent.trim();
|
||||||
|
if (stype == 'int') {
|
||||||
|
v = parseInt(v.replace(/[, ]/g, '')) || 0;
|
||||||
|
}
|
||||||
|
vl.push([v, a]);
|
||||||
|
}
|
||||||
|
vl.sort(function (a, b) {
|
||||||
|
a = a[0];
|
||||||
|
b = b[0];
|
||||||
|
if (a === null)
|
||||||
return -1;
|
return -1;
|
||||||
if (!b.cells[col])
|
if (b === null)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
var v1 = a.cells[col].getAttribute('sortv') || a.cells[col].textContent.trim();
|
|
||||||
var v2 = b.cells[col].getAttribute('sortv') || b.cells[col].textContent.trim();
|
|
||||||
if (stype == 'int') {
|
if (stype == 'int') {
|
||||||
v1 = parseInt(v1.replace(/,/g, '')) || 0;
|
return reverse * (a - b);
|
||||||
v2 = parseInt(v2.replace(/,/g, '')) || 0;
|
|
||||||
return reverse * (v1 - v2);
|
|
||||||
}
|
}
|
||||||
return reverse * (v1.localeCompare(v2));
|
return reverse * (a.localeCompare(b));
|
||||||
});
|
});
|
||||||
for (i = 0; i < tr.length; ++i) tb.appendChild(tr[i]);
|
for (i = 0; i < tr.length; ++i) tb.appendChild(tr[vl[i][1]]);
|
||||||
}
|
}
|
||||||
function makeSortable(table) {
|
function makeSortable(table) {
|
||||||
var th = table.tHead, i;
|
var th = table.tHead, i;
|
||||||
|
|
Loading…
Reference in a new issue