browser: reload music player on column-sort

so tracks play in the right order
This commit is contained in:
ed 2021-03-13 00:15:53 +01:00
parent 46b6abde3f
commit 0893f06919
2 changed files with 17 additions and 11 deletions

View file

@ -6,7 +6,7 @@ function dbg(msg) {
ebi('path').innerHTML = msg; ebi('path').innerHTML = msg;
} }
makeSortable(ebi('files')); makeSortable(ebi('files'), reload_mp);
// extract songs + add play column // 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) { function reload_browser(not_mp) {
filecols.set_style(); filecols.set_style();
makeSortable(ebi('files')); makeSortable(ebi('files'), reload_mp);
var parts = get_evpath().split('/'); var parts = get_evpath().split('/');
var rm = document.querySelectorAll('#path>a+a+a'); var rm = document.querySelectorAll('#path>a+a+a');
@ -1375,14 +1385,8 @@ function reload_browser(not_mp) {
oo[a].textContent = hsz; oo[a].textContent = hsz;
} }
if (!not_mp) { if (!not_mp)
if (mp && mp.au) { reload_mp();
mp.au.pause();
mp.au = null;
}
widget.close();
mp = init_mp();
}
if (window['up2k']) if (window['up2k'])
up2k.set_fsearch(); up2k.set_fsearch();

View file

@ -128,7 +128,7 @@ function sortTable(table, col) {
}); });
for (i = 0; i < tr.length; ++i) tb.appendChild(tr[vl[i][1]]); 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; var th = table.tHead, i;
th && (th = th.rows[0]) && (th = th.cells); th && (th = th.rows[0]) && (th = th.cells);
if (th) i = th.length; if (th) i = th.length;
@ -137,6 +137,8 @@ function makeSortable(table) {
th[i].onclick = function (e) { th[i].onclick = function (e) {
ev(e); ev(e);
sortTable(table, i); sortTable(table, i);
if (cb)
cb();
}; };
}(i)); }(i));
} }