mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
play audio from grid when widget open
This commit is contained in:
parent
ec73094506
commit
229c3f5dab
|
@ -198,6 +198,8 @@ it does static images with Pillow and uses FFmpeg for video files, so you may wa
|
||||||
|
|
||||||
images named `folder.jpg` and `folder.png` become the thumbnail of the folder they're in
|
images named `folder.jpg` and `folder.png` become the thumbnail of the folder they're in
|
||||||
|
|
||||||
|
in the grid/thumbnail view, if the audio player panel is open, songs will start playing when clicked
|
||||||
|
|
||||||
|
|
||||||
## zip downloads
|
## zip downloads
|
||||||
|
|
||||||
|
|
|
@ -522,37 +522,38 @@ function get_np() {
|
||||||
|
|
||||||
// toggle player widget
|
// toggle player widget
|
||||||
var widget = (function () {
|
var widget = (function () {
|
||||||
var ret = {},
|
var r = {},
|
||||||
widget = ebi('widget'),
|
widget = ebi('widget'),
|
||||||
wtico = ebi('wtico'),
|
wtico = ebi('wtico'),
|
||||||
nptxt = ebi('nptxt'),
|
nptxt = ebi('nptxt'),
|
||||||
npirc = ebi('npirc'),
|
npirc = ebi('npirc'),
|
||||||
touchmode = false,
|
touchmode = false,
|
||||||
side_open = false,
|
|
||||||
was_paused = true;
|
was_paused = true;
|
||||||
|
|
||||||
ret.open = function () {
|
r.is_open = false;
|
||||||
if (side_open)
|
|
||||||
|
r.open = function () {
|
||||||
|
if (r.is_open)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
widget.className = 'open';
|
widget.className = 'open';
|
||||||
side_open = true;
|
r.is_open = true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
ret.close = function () {
|
r.close = function () {
|
||||||
if (!side_open)
|
if (!r.is_open)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
widget.className = '';
|
widget.className = '';
|
||||||
side_open = false;
|
r.is_open = false;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
ret.toggle = function (e) {
|
r.toggle = function (e) {
|
||||||
ret.open() || ret.close();
|
r.open() || r.close();
|
||||||
ev(e);
|
ev(e);
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
ret.paused = function (paused) {
|
r.paused = function (paused) {
|
||||||
if (was_paused != paused) {
|
if (was_paused != paused) {
|
||||||
was_paused = paused;
|
was_paused = paused;
|
||||||
ebi('bplay').innerHTML = paused ? '▶' : '⏸';
|
ebi('bplay').innerHTML = paused ? '▶' : '⏸';
|
||||||
|
@ -560,7 +561,7 @@ var widget = (function () {
|
||||||
};
|
};
|
||||||
wtico.onclick = function (e) {
|
wtico.onclick = function (e) {
|
||||||
if (!touchmode)
|
if (!touchmode)
|
||||||
ret.toggle(e);
|
r.toggle(e);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -591,7 +592,7 @@ var widget = (function () {
|
||||||
document.body.removeChild(o);
|
document.body.removeChild(o);
|
||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
return ret;
|
return r;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
@ -1508,34 +1509,37 @@ var thegrid = (function () {
|
||||||
}
|
}
|
||||||
setsz();
|
setsz();
|
||||||
|
|
||||||
function seltgl(e) {
|
function gclick(e) {
|
||||||
if (e && e.ctrlKey)
|
if (e && e.ctrlKey)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
ev(e);
|
|
||||||
var oth = ebi(this.getAttribute('ref')),
|
var oth = ebi(this.getAttribute('ref')),
|
||||||
|
aplay = ebi('a' + oth.getAttribute('id')),
|
||||||
td = oth.parentNode.nextSibling,
|
td = oth.parentNode.nextSibling,
|
||||||
tr = td.parentNode;
|
tr = td.parentNode;
|
||||||
|
|
||||||
|
if (r.sel) {
|
||||||
td.click();
|
td.click();
|
||||||
this.setAttribute('class', tr.getAttribute('class'));
|
this.setAttribute('class', tr.getAttribute('class'));
|
||||||
}
|
}
|
||||||
|
else if (widget.is_open && aplay)
|
||||||
|
aplay.click();
|
||||||
|
|
||||||
function bgopen(e) {
|
else if (QS('#files tr.sel'))
|
||||||
ev(e);
|
window.open(this.getAttribute('href'), '_blank');
|
||||||
var url = this.getAttribute('href');
|
|
||||||
window.open(url, '_blank');
|
else return true;
|
||||||
|
return ev(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
r.loadsel = function () {
|
r.loadsel = function () {
|
||||||
if (r.dirty)
|
if (r.dirty)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var ths = QSA('#ggrid>a'),
|
var ths = QSA('#ggrid>a');
|
||||||
have_sel = !!QS('#files tr.sel');
|
|
||||||
|
|
||||||
for (var a = 0, aa = ths.length; a < aa; a++) {
|
for (var a = 0, aa = ths.length; a < aa; a++) {
|
||||||
ths[a].onclick = r.sel ? seltgl : have_sel ? bgopen : null;
|
ths[a].onclick = gclick;
|
||||||
ths[a].setAttribute('class', ebi(ths[a].getAttribute('ref')).parentNode.parentNode.getAttribute('class'));
|
ths[a].setAttribute('class', ebi(ths[a].getAttribute('ref')).parentNode.parentNode.getAttribute('class'));
|
||||||
}
|
}
|
||||||
var uns = QS('#ggrid a[ref="unsearch"]');
|
var uns = QS('#ggrid a[ref="unsearch"]');
|
||||||
|
|
Loading…
Reference in a new issue