add close button to search results

This commit is contained in:
ed 2021-02-21 05:33:57 +00:00
parent feebdee88b
commit 2a6dd7b512
3 changed files with 24 additions and 4 deletions

View file

@ -70,8 +70,8 @@ class U2idx(object):
def run_query(self, vols, qstr, qv): def run_query(self, vols, qstr, qv):
qv = tuple(qv) qv = tuple(qv)
self.log("qs: " + qstr) # self.log("qs: " + qstr)
self.log("qv: " + repr(qv)) # self.log("qv: " + repr(qv))
ret = [] ret = []
lim = 100 lim = 100
@ -83,7 +83,7 @@ class U2idx(object):
continue continue
self.dbs[ptop] = db self.dbs[ptop] = db
self.log("idx /{} @ {} {}".format(vtop, ptop, flags)) # self.log("idx /{} @ {} {}".format(vtop, ptop, flags))
c = db.execute(qstr, qv) c = db.execute(qstr, qv)
for _, ts, sz, rd, fn in c: for _, ts, sz, rd, fn in c:

View file

@ -594,6 +594,7 @@ function autoplay_blocked() {
] ]
]; ];
var html = []; var html = [];
var orig_html = null;
for (var a = 0; a < sconf.length; a++) { for (var a = 0; a < sconf.length; a++) {
html.push('<tr><td><br />' + sconf[a][0] + '</td>'); html.push('<tr><td><br />' + sconf[a][0] + '</td>');
for (var b = 1; b < 3; b++) { for (var b = 1; b < 3; b++) {
@ -658,7 +659,7 @@ function autoplay_blocked() {
ebi('path').style.display = 'none'; ebi('path').style.display = 'none';
ebi('tree').style.display = 'none'; ebi('tree').style.display = 'none';
var html = []; var html = ['<tr><td>-</td><td colspan="4"><a href="#" id="unsearch">close search results</a></td></tr>'];
var res = JSON.parse(this.responseText); var res = JSON.parse(this.responseText);
for (var a = 0; a < res.length; a++) { for (var a = 0; a < res.length; a++) {
var r = res[a], var r = res[a],
@ -676,9 +677,23 @@ function autoplay_blocked() {
'</td><td>' + ext + '</td><td>' + unix2iso(ts) + '</td></tr>'); '</td><td>' + ext + '</td><td>' + unix2iso(ts) + '</td></tr>');
} }
if (!orig_html)
orig_html = ebi('files').tBodies[0].innerHTML;
ofiles.tBodies[0].innerHTML = html.join('\n'); ofiles.tBodies[0].innerHTML = html.join('\n');
ofiles.setAttribute("ts", this.ts); ofiles.setAttribute("ts", this.ts);
reload_browser(); reload_browser();
ebi('unsearch').onclick = unsearch;
}
function unsearch(e) {
ev(e);
ebi('path').style.display = 'inline-block';
ebi('tree').style.display = 'block';
ebi('files').tBodies[0].innerHTML = orig_html;
orig_html = null;
reload_browser();
} }
})(); })();

View file

@ -85,6 +85,11 @@ function sortTable(table, col) {
th[col].className = 'sort' + reverse; th[col].className = 'sort' + reverse;
var stype = th[col].getAttribute('sort'); var stype = th[col].getAttribute('sort');
tr = tr.sort(function (a, b) { tr = tr.sort(function (a, b) {
if (!a.cells[col])
return -1;
if (!b.cells[col])
return 1;
var v1 = a.cells[col].textContent.trim(); var v1 = a.cells[col].textContent.trim();
var v2 = b.cells[col].textContent.trim(); var v2 = b.cells[col].textContent.trim();
if (stype == 'int') { if (stype == 'int') {