diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 25f55209..cae375a2 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -6,7 +6,7 @@ function dbg(msg) { ebi('path').innerHTML = msg; } -makeSortable(ebi('files')); +makeSortable(ebi('files'), reload_mp); // extract songs + add play column @@ -1349,9 +1349,19 @@ function ev_row_tgl(e) { } +function reload_mp() { + if (mp && mp.au) { + mp.au.pause(); + mp.au = null; + } + widget.close(); + mp = init_mp(); +} + + function reload_browser(not_mp) { filecols.set_style(); - makeSortable(ebi('files')); + makeSortable(ebi('files'), reload_mp); var parts = get_evpath().split('/'); var rm = document.querySelectorAll('#path>a+a+a'); @@ -1375,14 +1385,8 @@ function reload_browser(not_mp) { oo[a].textContent = hsz; } - if (!not_mp) { - if (mp && mp.au) { - mp.au.pause(); - mp.au = null; - } - widget.close(); - mp = init_mp(); - } + if (!not_mp) + reload_mp(); if (window['up2k']) up2k.set_fsearch(); diff --git a/copyparty/web/util.js b/copyparty/web/util.js index d6f58f94..c519c3ba 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -128,7 +128,7 @@ function sortTable(table, col) { }); for (i = 0; i < tr.length; ++i) tb.appendChild(tr[vl[i][1]]); } -function makeSortable(table) { +function makeSortable(table, cb) { var th = table.tHead, i; th && (th = th.rows[0]) && (th = th.cells); if (th) i = th.length; @@ -137,6 +137,8 @@ function makeSortable(table) { th[i].onclick = function (e) { ev(e); sortTable(table, i); + if (cb) + cb(); }; }(i)); }