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> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>heonian web dictionary</title> <title>heonian web dictionary</title>

View File

@ -44,7 +44,7 @@ body {
} }
a { a {
color: rgb(119, 205, 233); color: rgb(27 120 151);
text-decoration: none; text-decoration: none;
} }
@ -146,6 +146,8 @@ main {
max-width: 600px; max-width: 600px;
margin: auto; margin: auto;
margin-top: 1rem; margin-top: 1rem;
padding-left: 1rem;
padding-right: 1rem;
} }
.main-animation { .main-animation {
@ -192,13 +194,22 @@ main {
content: ". "; content: ". ";
} }
.result-notes {
font-size: 0.85rem;
color: var(--darkgrey);
margin-top: 6px;
margin-bottom: 6px;
}
.result summary { .result summary {
margin-top: 4px;
color: grey; color: grey;
} }
.result details p { .result details p {
margin-top: 4px; margin-top: 4px;
margin-bottom: 4px; margin-bottom: 4px;
font-size: 1.25rem;
} }
/* todo. organize this file better. this is a fucking mess */ /* 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) { function stripWord(word) {
return word.replace(/[^a-zA-Z-]/gu, ""); return word.replace(/[^a-zA-Z-]/gu, "").toLowerCase();
} }
heonianVowels = { heonianVowels = {
@ -231,14 +231,26 @@ function doSearch() {
meaning.innerHTML += "<br><details><summary>Translation</summary><p>"+json[results[i]][o]["translation"]+"</p></details>"; meaning.innerHTML += "<br><details><summary>Translation</summary><p>"+json[results[i]][o]["translation"]+"</p></details>";
} }
//example //example
if (json[results[i]][o]["example"] != undefined) { if (json[results[i]][o]["examples"] != undefined) {
//todo 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 //notes
if (json[results[i]][o]["notes"] != undefined) { 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) //(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 //todo
result.appendChild(meaning); //y, yeah. result.appendChild(meaning); //y, yeah.
} }

View File

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