Add readme to home, fuzzy search instruction and make UI a tad bit better

This commit is contained in:
2021-09-22 23:53:57 -04:00
parent f0ed92aab1
commit af4a1f83e1
6 changed files with 60 additions and 21 deletions

View File

@@ -1,3 +1,4 @@
// good luck reading through this
(function () {
var client = new XMLHttpRequest();
client.open("GET", "/pages.json");
@@ -6,6 +7,7 @@
fuzzyInit(client.responseText);
}
client.send();
document.querySelector("#search").focus();
})();
function fuzzyInit(pagesFileName) {
@@ -39,11 +41,18 @@ function fuzzyInit(pagesFileName) {
break;
}
if (document.querySelector("#search").value === ""){
document.querySelector("#results").innerHTML = "";
// help
if (document.querySelector("#search").value === "?" || document.querySelector("#search").value == "help") {
document.querySelector("#results").innerHTML = "Enter a page or directory name. If do not know any, clear the search field to list everything. Using the <code>Enter</code> key would take you to the first page in list, if it is not empty."
return;
}
// if (document.querySelector("#search").value === ""){
// document.querySelector("#results").innerHTML = "Try entering something into the input field...";
// return;
// }
let results = [];
for (const [i, [title, page]] of pages.entries()) {
ret = fuzzySearch(title, document.querySelector("#search").value);