diff --git a/copyparty/web/browser.css b/copyparty/web/browser.css index 4995ec63..70ec4a24 100644 --- a/copyparty/web/browser.css +++ b/copyparty/web/browser.css @@ -121,6 +121,8 @@ a, #files tbody tr:last-child td { padding-bottom: 1.3em; border-bottom: .5em solid #444; +} +#files tbody tr td:last-child { white-space: nowrap; } #files thead th[style] { diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 15cfd063..97c7a10d 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -606,7 +606,7 @@ function autoplay_blocked() { } 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++) { o[a].oninput = ev_search_input; } @@ -615,8 +615,11 @@ function autoplay_blocked() { function ev_search_input() { var v = this.value; - var chk = ebi(this.getAttribute('id').slice(0, -1) + 'c'); - chk.checked = ((v + '').length > 0); + var id = this.getAttribute('id'); + if (id.slice(-1) == 'v') { + var chk = ebi(id.slice(0, -1) + 'c'); + chk.checked = ((v + '').length > 0); + } clearTimeout(search_timeout); search_timeout = setTimeout(do_search, 100); } @@ -1158,7 +1161,6 @@ function reload_browser(not_mp) { hsz = sz.replace(/\B(?=(\d{3})+(?!\d))/g, " "); oo[a].textContent = hsz; - oo[a].setAttribute("sortv", sz); } if (!not_mp) { diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 2f3699fd..fdadabc3 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -99,22 +99,33 @@ function sortTable(table, col) { th[a].className = th[a].className.replace(/ *sort-?1 */, " "); th[col].className += ' sort' + reverse; var stype = th[col].getAttribute('sort'); - tr = tr.sort(function (a, b) { - if (!a.cells[col]) + var vl = []; + 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; - if (!b.cells[col]) + if (b === null) 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') { - v1 = parseInt(v1.replace(/,/g, '')) || 0; - v2 = parseInt(v2.replace(/,/g, '')) || 0; - return reverse * (v1 - v2); + return reverse * (a - b); } - 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) { var th = table.tHead, i;