make search rate-control less visually confusing

This commit is contained in:
ed 2021-06-30 01:44:25 +02:00
parent 8b4b7fa794
commit 7e606cdd9f
5 changed files with 32 additions and 9 deletions

View file

@ -614,8 +614,6 @@ in the `scripts` folder:
roughly sorted by priority roughly sorted by priority
* ctrl-click overrides onclick (tree, ...)
* indicate dropped queries in search ui
* readme.md as epilogue * readme.md as epilogue
* reduce up2k roundtrips * reduce up2k roundtrips
* start from a chunk index and just go * start from a chunk index and just go

View file

@ -607,7 +607,7 @@ input.eq_gain {
#srch_q { #srch_q {
white-space: pre; white-space: pre;
color: #f80; color: #f80;
height: 1em; min-height: 1em;
margin: .2em 0 -1em 1.6em; margin: .2em 0 -1em 1.6em;
} }
#tq_raw { #tq_raw {

View file

@ -1879,6 +1879,7 @@ document.onkeydown = function (e) {
} }
var search_timeout, var search_timeout,
defer_timeout,
search_in_progress = 0; search_in_progress = 0;
function ev_search_input() { function ev_search_input() {
@ -1893,9 +1894,29 @@ document.onkeydown = function (e) {
if (id != "q_raw") if (id != "q_raw")
encode_query(); encode_query();
clearTimeout(search_timeout); set_vq();
if (Date.now() - search_in_progress > 30 * 1000)
clearTimeout(defer_timeout);
defer_timeout = setTimeout(try_search, 2000);
try_search();
}
function try_search() {
if (Date.now() - search_in_progress > 30 * 1000) {
clearTimeout(defer_timeout);
clearTimeout(search_timeout);
search_timeout = setTimeout(do_search, 200); search_timeout = setTimeout(do_search, 200);
}
}
function set_vq() {
if (search_in_progress)
return;
var q = ebi('q_raw').value,
vq = ebi('files').getAttribute('q_raw');
srch_msg(false, (q == vq) ? '' : 'search results below are from a previous query:\n ' + (vq ? vq : '(*)'));
} }
function encode_query() { function encode_query() {
@ -1965,7 +1986,8 @@ document.onkeydown = function (e) {
xhr.setRequestHeader('Content-Type', 'text/plain'); xhr.setRequestHeader('Content-Type', 'text/plain');
xhr.onreadystatechange = xhr_search_results; xhr.onreadystatechange = xhr_search_results;
xhr.ts = Date.now(); xhr.ts = Date.now();
xhr.send(JSON.stringify({ "q": ebi('q_raw').value })); xhr.q_raw = ebi('q_raw').value;
xhr.send(JSON.stringify({ "q": xhr.q_raw }));
} }
function xhr_search_results() { function xhr_search_results() {
@ -2036,6 +2058,8 @@ document.onkeydown = function (e) {
ofiles.innerHTML = html.join('\n'); ofiles.innerHTML = html.join('\n');
ofiles.setAttribute("ts", this.ts); ofiles.setAttribute("ts", this.ts);
ofiles.setAttribute("q_raw", this.q_raw);
set_vq();
mukey.render(); mukey.render();
reload_browser(); reload_browser();
filecols.set_style(['File Name']); filecols.set_style(['File Name']);

View file

@ -1,7 +1,5 @@
"use strict"; "use strict";
window.onerror = vis_exh;
function goto_up2k() { function goto_up2k() {
if (up2k === false) if (up2k === false)
@ -32,7 +30,7 @@ catch (ex) {
} }
catch (ex) { } catch (ex) { }
} }
window['treectl'].onscroll(); // uhh treectl.onscroll();
function up2k_flagbus() { function up2k_flagbus() {

View file

@ -32,6 +32,9 @@ function esc(txt) {
}); });
} }
function vis_exh(msg, url, lineNo, columnNo, error) { function vis_exh(msg, url, lineNo, columnNo, error) {
if (!window.onerror)
return;
window.onerror = undefined; window.onerror = undefined;
window['vis_exh'] = null; window['vis_exh'] = null;
var html = ['<h1>you hit a bug!</h1><p>please screenshot this error and send me a copy arigathanks gozaimuch (ed/irc.rizon.net or ed#2644)</p><p>', var html = ['<h1>you hit a bug!</h1><p>please screenshot this error and send me a copy arigathanks gozaimuch (ed/irc.rizon.net or ed#2644)</p><p>',