Add backspace help

This commit is contained in:
Paul W. 2021-10-01 01:23:35 -04:00
parent 834817401b
commit 3509ba9974

View File

@ -1,4 +1,4 @@
setTimeout(() => {
(() => {
let searchField = document.querySelector("#search");
if (searchField === null)
return;
@ -11,7 +11,7 @@ setTimeout(() => {
}
client.send();
searchField.focus();
}, 50);
})();
function fuzzyInit(pagesFileName) {
if (pagesFileName == "")
@ -49,7 +49,7 @@ function fuzzyInit(pagesFileName) {
// help
if (searchValue === "?" || searchValue === "help") {
resultBlock.innerHTML = "<h2>Help</h2>Enter a page or directory name.<br>If do not know any, clear the search field to list everything.<br> Using the <code>Enter</code> key would take you to the first page in list, if the list is not empty.<br>Alternatively, use the <code>Up</code> and <code>Down</code> arrow keys to select the page you want and use the <code>Enter</code> key."
resultBlock.innerHTML = "<h2>Help</h2>Enter a page or directory name.<br>If do not know any, clear the search field to list everything.<br> Using the <code>Enter</code> key would take you to the first page in list, if the list is not empty.<br>Alternatively, use the <code>Up</code> and <code>Down</code> arrow keys to select the page you want and use the <code>Enter</code> key.<br>Use <code>Backspace</code> to go back to the search."
return;
}
@ -74,10 +74,13 @@ function fuzzyInit(pagesFileName) {
if (results.length <= 0)
resultBlock.innerHTML = "Unknown command or no matching pages found."
}
);
});
document.body.addEventListener("keydown", (e) => {
if (e.code === "Backspace") {
searchField.focus();
}
if (e.code === "ArrowDown" || e.code === "ArrowUp") {
if (resultBlock.childNodes === null)
return;