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) {
//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), {})

2
sw.js
View File

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