close #28 i think

This commit is contained in:
remi 2022-06-19 11:55:12 +02:00
parent 82e4d36b14
commit c35d27198c
2 changed files with 15 additions and 7 deletions

20
main.js
View File

@ -20,6 +20,7 @@ function toggleIME() {
function animateHeader(inout = false) { function animateHeader(inout = false) {
//todo: debounce this //todo: debounce this
// const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)"); //do shit
if (inout) { if (inout) {
header.classList.add("header-animation-reverse"); header.classList.add("header-animation-reverse");
header.classList.remove("header-animation"); header.classList.remove("header-animation");
@ -242,6 +243,13 @@ function loadDictionary() {
//ok, we're all ready! //ok, we're all ready!
document.querySelector("header input").placeholder = "search"; 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 { } else {
alert("yeah something went horribly wrong loading the wordlist so uh,,, certified ike moment"); 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"); let header = document.createElement("div");
header.classList.add("results-header"); header.classList.add("results-header");
//When using search methods, accomodate search text. //When using search methods, accomodate search text.
//we dont wanna actually change val, because this breaks searchParams
switch (type) { switch (type) {
//show:all //show:all
case "all": case "all":
val = "Showing all words"; header.innerHTML += "<span class='heonian'>showing all words</span><br>";
break; break;
case "random": 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; break;
//OMG A WORD //OMG A WORD
default: default:
val = "search results for: " + val; header.innerHTML += "<span class='heonian'>search results for: " + val + "</span><br>";
break; break;
} }
header.innerHTML += "<span class='heonian'>" + val + "</span><br>";
for (let i in types) { for (let i in types) {
if (i !== "") { header.innerHTML += "<span class='results-header-count'>" + i + "s - " + types[i] + "</span>"; } if (i !== "") { header.innerHTML += "<span class='results-header-count'>" + i + "s - " + types[i] + "</span>"; }
} }
@ -566,8 +575,7 @@ window.onload = () => {
doSearch(false); doSearch(false);
} }
}); });
registerSW(); registerSW(); //considering disabling this for now,.... itso nly lead to trouble :////
//also check if ?s is there . for hecks sake (todo) (TODO!!!!!!)
} }
const sortObject = obj => Object.keys(obj).sort().reduce((res, key) => (res[key] = obj[key], res), {}) const sortObject = obj => Object.keys(obj).sort().reduce((res, key) => (res[key] = obj[key], res), {})

2
sw.js
View File

@ -1,4 +1,4 @@
const currentVersion = '20945'; const currentVersion = '24678';
const addResourcesToCache = async (resources) => { const addResourcesToCache = async (resources) => {
const cache = await caches.open(currentVersion); const cache = await caches.open(currentVersion);