basic but better search results,

This commit is contained in:
remi 2022-06-09 02:03:14 +02:00
parent 312bf4b720
commit a4f1a04c72
4 changed files with 30 additions and 7 deletions

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>heonian web dictionary</title>

View File

@ -44,7 +44,7 @@ body {
}
a {
color: rgb(119, 205, 233);
color: rgb(27 120 151);
text-decoration: none;
}
@ -146,6 +146,8 @@ main {
max-width: 600px;
margin: auto;
margin-top: 1rem;
padding-left: 1rem;
padding-right: 1rem;
}
.main-animation {
@ -192,13 +194,22 @@ main {
content: ". ";
}
.result-notes {
font-size: 0.85rem;
color: var(--darkgrey);
margin-top: 6px;
margin-bottom: 6px;
}
.result summary {
margin-top: 4px;
color: grey;
}
.result details p {
margin-top: 4px;
margin-bottom: 4px;
font-size: 1.25rem;
}
/* todo. organize this file better. this is a fucking mess */

20
main.js
View File

@ -62,7 +62,7 @@ document.addEventListener("keydown", (e) => {
});
function stripWord(word) {
return word.replace(/[^a-zA-Z-]/gu, "");
return word.replace(/[^a-zA-Z-]/gu, "").toLowerCase();
}
heonianVowels = {
@ -231,14 +231,26 @@ function doSearch() {
meaning.innerHTML += "<br><details><summary>Translation</summary><p>"+json[results[i]][o]["translation"]+"</p></details>";
}
//example
if (json[results[i]][o]["example"] != undefined) {
//todo
if (json[results[i]][o]["examples"] != undefined) {
let temp = ""
temp += "<details><summary>Examples</summary><p>";
for (let e in json[results[i]][o]["examples"]) {
temp += "<span class='heonian'>"+e+"</span> - "+json[results[i]][o]["examples"][e];
}
temp += "</p></details>";
meaning.innerHTML += temp;
}
//notes
if (json[results[i]][o]["notes"] != undefined) {
meaning.innerHTML += "<br><p class='result-notes'>"+json[results[i]][o]["notes"]+"</p>";
meaning.innerHTML += "<p class='result-notes'>"+json[results[i]][o]["notes"]+"</p>";
}
//(source, etc)
if (json[results[i]][o]["canon-etymology"] != undefined) {
meaning.innerHTML += "<details><summary>Canon Etymology</summary><p>"+json[results[i]][o]["canon-etymology"]+"</p></details>";
}
if (json[results[i]][o]["meta-etymology"] != undefined) {
meaning.innerHTML += "<details><summary>Meta Etymology</summary><p>"+json[results[i]][o]["meta-etymology"]+"</p></details>";
}
//todo
result.appendChild(meaning); //y, yeah.
}

View File

@ -130,7 +130,7 @@
"type": "noun",
"meaning": "snow",
"translation": "snow",
"notes": "",
"notes": "this is where notes go",
"meta-etymology": "I want one my names to mean something pretty - Ari.",
"examples": {
"     ": "i hope ari can see snow"