close #28 i think
This commit is contained in:
parent
82e4d36b14
commit
c35d27198c
20
main.js
20
main.js
@ -20,6 +20,7 @@ function toggleIME() {
|
||||
|
||||
function animateHeader(inout = false) {
|
||||
//todo: debounce this
|
||||
// const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)"); //do shit
|
||||
if (inout) {
|
||||
header.classList.add("header-animation-reverse");
|
||||
header.classList.remove("header-animation");
|
||||
@ -242,6 +243,13 @@ function loadDictionary() {
|
||||
|
||||
//ok, we're all ready!
|
||||
document.querySelector("header input").placeholder = "search";
|
||||
const url = new URL(window.location);
|
||||
const val = url.searchParams.get('s');
|
||||
if (val != null) {
|
||||
header.querySelector("input").value = val;
|
||||
doSearch(false);
|
||||
animateHeader(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
alert("yeah something went horribly wrong loading the wordlist so uh,,, certified ike moment");
|
||||
@ -448,20 +456,21 @@ function doSearch(state = true) {
|
||||
let header = document.createElement("div");
|
||||
header.classList.add("results-header");
|
||||
//When using search methods, accomodate search text.
|
||||
//we dont wanna actually change val, because this breaks searchParams
|
||||
switch (type) {
|
||||
//show:all
|
||||
case "all":
|
||||
val = "Showing all words";
|
||||
header.innerHTML += "<span class='heonian'>showing all words</span><br>";
|
||||
break;
|
||||
case "random":
|
||||
val = "Showing random word: " + results[0];
|
||||
//think about whether we wanna set searchparams to this, though..?
|
||||
header.innerHTML += "<span class='heonian'>showing random word: " + results[0] + "</span><br>";
|
||||
break;
|
||||
//OMG A WORD
|
||||
default:
|
||||
val = "search results for: " + val;
|
||||
header.innerHTML += "<span class='heonian'>search results for: " + val + "</span><br>";
|
||||
break;
|
||||
}
|
||||
header.innerHTML += "<span class='heonian'>" + val + "</span><br>";
|
||||
for (let i in types) {
|
||||
if (i !== "") { header.innerHTML += "<span class='results-header-count'>" + i + "s - " + types[i] + "</span>"; }
|
||||
}
|
||||
@ -566,8 +575,7 @@ window.onload = () => {
|
||||
doSearch(false);
|
||||
}
|
||||
});
|
||||
registerSW();
|
||||
//also check if ?s is there . for hecks sake (todo) (TODO!!!!!!)
|
||||
registerSW(); //considering disabling this for now,.... itso nly lead to trouble :////
|
||||
}
|
||||
|
||||
const sortObject = obj => Object.keys(obj).sort().reduce((res, key) => (res[key] = obj[key], res), {})
|
Loading…
Reference in New Issue
Block a user