From 1d4caa5f2b31ae527b81d1394d6a62dc6e5f7c27 Mon Sep 17 00:00:00 2001 From: remi Date: Sat, 11 Jun 2022 02:03:52 +0200 Subject: [PATCH] close #6 --- index.html | 2 +- main.js | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 7661825..30d24e7 100644 --- a/index.html +++ b/index.html @@ -29,7 +29,7 @@
- show all words uh. something else + show all words random word resources
diff --git a/main.js b/main.js index 217f8c4..40dd1b7 100644 --- a/main.js +++ b/main.js @@ -28,6 +28,7 @@ function animateHeader(inout = false) { header.classList.add("fullscreen"); main.style.opacity = "0"; main.classList.remove("main-animation-reverse"); + main.innerHTML = ""; }, 500); setTimeout(() => { header.classList.remove("header-animation-reverse"); @@ -259,11 +260,18 @@ function search(word) { return result; } -function doSearch(state = true) { +function doSearch(state = true, all = false) { + if (all == true) { + header.querySelector("input").value = "show:all"; + } let val = header.querySelector("input").value; - let results = search(val); + if (val == "") { + main.innerHTML = "enter some search terms..."; + return; + } + let results = search(val == "show:all" ? "" : val); if (results.length == 0) { - main.innerHTML = "no results lulw"; + main.innerHTML = "no results (todo: cool form)"; } else { main.innerHTML = ""; /* @@ -406,6 +414,12 @@ window.onload = () => { goHome(); } }; + header.querySelector("#showAllWords").onclick = () => { + if (header.classList.contains("fullscreen")) { + animateHeader(false); + } + doSearch(true, true); + }; loadDictionary(); window.addEventListener('popstate', (e) => { if (e.state == null) {