add file selection from text viewer

This commit is contained in:
ed 2021-11-06 22:02:43 +01:00
parent e5b3d2a312
commit c0d7aa9e4a
3 changed files with 46 additions and 6 deletions

View file

@ -331,7 +331,7 @@ window.baguetteBox = (function () {
function tglsel() { function tglsel() {
var thumb = currentGallery[currentIndex].imageElement, var thumb = currentGallery[currentIndex].imageElement,
name = vsplit(thumb.href)[1], name = vsplit(thumb.href)[1].split('?')[0],
files = msel.getall(); files = msel.getall();
for (var a = 0; a < files.length; a++) for (var a = 0; a < files.length; a++)
@ -345,7 +345,7 @@ window.baguetteBox = (function () {
function selbg() { function selbg() {
var img = vidimg(), var img = vidimg(),
thumb = currentGallery[currentIndex].imageElement, thumb = currentGallery[currentIndex].imageElement,
name = vsplit(thumb.href)[1], name = vsplit(thumb.href)[1].split('?')[0],
files = msel.getsel(), files = msel.getsel(),
sel = false; sel = false;

View file

@ -748,6 +748,11 @@ input.eq_gain {
#tree li:last-child { #tree li:last-child {
border-bottom: none; border-bottom: none;
} }
#tree ul a.sel {
background: #111;
box-shadow: -.8em 0 0 #c37 inset;
color: #fff;
}
#tree ul a.hl { #tree ul a.hl {
color: #400; color: #400;
background: #fc4; background: #fc4;
@ -1053,6 +1058,10 @@ html.light #doc .line-highlight {
#tree #docul a { #tree #docul a {
display: block; display: block;
} }
#seldoc.sel {
color: #fff;
background: #925;
}
#pvol, #pvol,
#barbuf, #barbuf,
#barpos, #barpos,

View file

@ -2489,11 +2489,34 @@ var showfile = (function () {
r.updtree = function () { r.updtree = function () {
var fn = QS('#path span:last-child'), var fn = QS('#path span:last-child'),
lis = QSA('#docul li a'); lis = QSA('#docul li a'),
sels = msel.getsel(),
actsel = false;
fn = fn ? fn.textContent : ''; fn = fn ? fn.textContent : '';
for (var a = 0, aa = lis.length; a < aa; a++) for (var a = 0, aa = lis.length; a < aa; a++) {
clmod(lis[a], 'hl', lis[a].textContent == fn); var lin = lis[a].textContent,
sel = false;
for (var b = 0; b < sels.length; b++)
if (vsplit(sels[b].vp)[1] == lin)
sel = true;
clmod(lis[a], 'hl', lin == fn);
clmod(lis[a], 'sel', sel);
if (lin == fn && sel)
actsel = true;
}
clmod(ebi('seldoc'), 'sel', actsel);
};
r.tglsel = function () {
var fn = ebi('docname').textContent;
for (var a = 0; a < r.files.length; a++)
if (r.files[a].name == fn)
clmod(ebi(r.files[a].id).closest('tr'), 'sel', 't');
msel.selui();
}; };
var bdoc = ebi('bdoc'); var bdoc = ebi('bdoc');
@ -2504,6 +2527,7 @@ var showfile = (function () {
'<a href="#" class="btn" id="dldoc" tt="download this file">💾 download</a>\n' + '<a href="#" class="btn" id="dldoc" tt="download this file">💾 download</a>\n' +
'<a href="#" class="btn" id="prevdoc" tt="show previous document$NHotkey: i">⬆ prev</a>\n' + '<a href="#" class="btn" id="prevdoc" tt="show previous document$NHotkey: i">⬆ prev</a>\n' +
'<a href="#" class="btn" id="nextdoc" tt="show next document$NHotkey: K">⬇ next</a>\n' + '<a href="#" class="btn" id="nextdoc" tt="show next document$NHotkey: K">⬇ next</a>\n' +
'<a href="#" class="btn" id="seldoc" tt="file is selected$NHotkey: S">sel</a>\n' +
'</div>' '</div>'
); );
ebi('xdoc').onclick = function () { ebi('xdoc').onclick = function () {
@ -2512,6 +2536,7 @@ var showfile = (function () {
ebi('dldoc').setAttribute('download', ''); ebi('dldoc').setAttribute('download', '');
ebi('prevdoc').onclick = function () { tree_neigh(-1); }; ebi('prevdoc').onclick = function () { tree_neigh(-1); };
ebi('nextdoc').onclick = function () { tree_neigh(1); }; ebi('nextdoc').onclick = function () { tree_neigh(1); };
ebi('seldoc').onclick = r.tglsel;
return r; return r;
})(); })();
@ -2867,7 +2892,7 @@ function tree_neigh(n) {
} }
var act = -1; var act = -1;
for (var a = 0, aa = links.length; a < aa; a++) { for (var a = 0, aa = links.length; a < aa; a++) {
if (links[a].getAttribute('class') == 'hl') { if (clgot(links[a], 'hl')) {
act = a; act = a;
break; break;
} }
@ -3039,6 +3064,11 @@ document.onkeydown = function (e) {
if (k == 'KeyD') if (k == 'KeyD')
return QSA('#ghead a[z]')[1].click(); return QSA('#ghead a[z]')[1].click();
} }
if (showfile.active()) {
if (k == 'KeyS')
showfile.tglsel();
}
}; };
@ -4455,6 +4485,7 @@ var msel = (function () {
clmod(ebi('wtoggle'), 'sel', r.getsel().length); clmod(ebi('wtoggle'), 'sel', r.getsel().length);
thegrid.loadsel(); thegrid.loadsel();
fileman.render(); fileman.render();
showfile.updtree();
} }
r.seltgl = function (e) { r.seltgl = function (e) {
ev(e); ev(e);