Skip to content

Commit

Permalink
restructure jbo import, themes
Browse files Browse the repository at this point in the history
  • Loading branch information
mi2ebi committed Jan 22, 2024
1 parent 4fa8582 commit 1718569
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 30 deletions.
29 changes: 2 additions & 27 deletions events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const worker = new Worker("worker.js", {"type": "module"});
var worker = {"postMessage": function(a) {console.log("no");}};
var config = {};
let page;
var q = "";
Expand All @@ -25,14 +25,6 @@ function getConflictRegex(g) {
conflict = "(" + conflict.join("|").replace(/\|+/, "|") + ")";
return conflict;
}
worker.addEventListener("message", function(e) {
results = e.data;
id("results").innerHTML = "";
id("length").innerHTML = results.length + " result" + (results.length == 1 ? "" : "s");
page = 0;
load(results, page);
checkLength();
});
window.addEventListener("scroll", function(e) {
if (window.innerHeight + window.scrollY >= document.body.scrollHeight - 100) {
page++;
Expand Down Expand Up @@ -125,7 +117,7 @@ id("search").addEventListener("input", function() {
id("info").append(createHTMLElement("p", null, [e.message.split(": ").slice(-1)[0].toLowerCase()]));
}
}
worker.postMessage({"query": q, "config": config, "rafsilist": RAFSI});
worker.postMessage({"query": q, "config": config, "rafsilist": RAFSI, "jbo": jbo});
} else {
results = null;
clearResults();
Expand Down Expand Up @@ -210,23 +202,6 @@ id("clear").addEventListener("click", function() {
id("search").value = "";
dispatchSearchInputEvent();
});
// theme (mi lebna ti la lalxu)
function setTheme(dark) {
document.documentElement.className = dark ? "dark" : "";
try {
localStorage.setItem("theme", dark ? "dark" : "light");
} catch (e) {
//
}
}
var theme = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)") ? "dark" : "light";
try {
theme = localStorage.getItem("theme") || theme;
} catch (e) {
//
}
setTheme(theme == "dark");
setTimeout(() => {document.body.style.transition = "background 0.2s"}, 0);
id("theme").addEventListener("click", function() {
setTheme(document.documentElement.className != "dark");
});
29 changes: 29 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,39 @@ <h1>la xlasisku</h1>
<div id="length"></div>
<div id="results"></div>
<div id="bottom"></div>
<script>
// theme (mi lebna ti la lalxu)
function setTheme(dark) {
document.documentElement.className = dark ? "dark" : "";
try {
localStorage.setItem("theme", dark ? "dark" : "light");
} catch (e) {
//
}
}
var theme = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)") ? "dark" : "light";
try {
theme = localStorage.getItem("theme") || theme;
} catch (e) {
//
}
setTheme(theme == "dark");
setTimeout(() => {document.body.style.transition = "background 0.2s"}, 0);
</script>
<script src="helper.js"></script>
<script src="data/jbo.js"></script>
<script src="events.js"></script>
<script>
// ready for stuff to happen
worker = new Worker("worker.js", {"type": "module"});
worker.addEventListener("message", function(e) {
results = e.data;
id("results").innerHTML = "";
id("length").innerHTML = results.length + " result" + (results.length == 1 ? "" : "s");
page = 0;
load(results, page);
checkLength();
});
id("sm").removeAttribute("disabled");
id("rm").removeAttribute("disabled");
id("xm").removeAttribute("disabled");
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
--link: 0, 105, 204;
--err: 209, 41, 41;
--focus: 255, 174, 12;
--sans: "IBM Plex Sans", ui-sans-serif, sans-serif;
--sans: "Noto Sans", "Noto Sans Math", ui-sans-serif, sans-serif;
--mono: "Iosevka", ui-monospace, monospace;
}
body.regex {
Expand Down
4 changes: 2 additions & 2 deletions worker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {jbo} from "./data/jbo.js";
var config, rafsilist;
var config, rafsilist, jbo;
function h(t) {
return t.replace(/[h‘’]/igu, "'");
}
Expand Down Expand Up @@ -102,6 +101,7 @@ onmessage = function(e) {
const query = e.data.query;
config = e.data.config;
rafsilist = e.data.rafsilist;
jbo = e.data.jbo;
const res = search(query);
postMessage(res);
};

0 comments on commit 1718569

Please sign in to comment.