ruby++
This commit is contained in:
parent
85f9625fea
commit
08b5f6daf6
8
main.css
8
main.css
@ -239,10 +239,6 @@ main {
|
|||||||
color: var(--darkgrey);
|
color: var(--darkgrey);
|
||||||
}
|
}
|
||||||
|
|
||||||
.result-translation::before {
|
|
||||||
content: " - ";
|
|
||||||
}
|
|
||||||
|
|
||||||
.result summary {
|
.result summary {
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
color: grey;
|
color: grey;
|
||||||
@ -254,6 +250,10 @@ main {
|
|||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.result details.result-meta p {
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
.results-header-count::after {
|
.results-header-count::after {
|
||||||
content: ", ";
|
content: ", ";
|
||||||
}
|
}
|
||||||
|
31
main.js
31
main.js
@ -132,7 +132,7 @@ heonianConsonants = {
|
|||||||
"10": "h",
|
"10": "h",
|
||||||
};
|
};
|
||||||
|
|
||||||
function heonianToRoman(text) {
|
function heonianToRoman(text, strict = false) {
|
||||||
let roman = "";
|
let roman = "";
|
||||||
for (let i = 0; i < text.length; i++) {
|
for (let i = 0; i < text.length; i++) {
|
||||||
let h = text.codePointAt(i);
|
let h = text.codePointAt(i);
|
||||||
@ -147,7 +147,7 @@ function heonianToRoman(text) {
|
|||||||
roman += heonianConsonants[h[1] + "" + h[2]] + heonianVowels[h[3] - 1];
|
roman += heonianConsonants[h[1] + "" + h[2]] + heonianVowels[h[3] - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if (strict == false) {
|
||||||
roman += text.charAt(i);
|
roman += text.charAt(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,6 +161,15 @@ function processVerb(word) {
|
|||||||
//but ... not yet uwu
|
//but ... not yet uwu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateRuby(word) {
|
||||||
|
letters = word.split("");
|
||||||
|
ruby = "";
|
||||||
|
for (let i = 0; i < letters.length; i++) {
|
||||||
|
ruby += `<ruby>${letters[i]}<rt>${heonianToRoman(letters[i])}</rt></ruby>`;
|
||||||
|
}
|
||||||
|
return ruby;
|
||||||
|
}
|
||||||
|
|
||||||
function loadDictionary() {
|
function loadDictionary() {
|
||||||
fetch("./wordlist.json").then((e) => {
|
fetch("./wordlist.json").then((e) => {
|
||||||
if (e.status === 200) {
|
if (e.status === 200) {
|
||||||
@ -241,9 +250,9 @@ function doSearch() {
|
|||||||
result.classList.add("result");
|
result.classList.add("result");
|
||||||
|
|
||||||
// 1. add word in heo + romanized ruby as header
|
// 1. add word in heo + romanized ruby as header
|
||||||
let header = document.createElement("ruby");
|
let header = document.createElement("span");
|
||||||
header.classList.add("result-header");
|
header.classList.add("result-header");
|
||||||
header.innerHTML = results[i] + " <rt>" + heonianToRoman(results[i]) + "</rt>";
|
header.innerHTML = generateRuby(results[i]);
|
||||||
|
|
||||||
// 2. add tags [tags like. common word, slang, formal???, type, etc]
|
// 2. add tags [tags like. common word, slang, formal???, type, etc]
|
||||||
// hhh how do i do this part, what tags. would i add. would this be. per word, or per definition?
|
// hhh how do i do this part, what tags. would i add. would this be. per word, or per definition?
|
||||||
@ -261,28 +270,30 @@ function doSearch() {
|
|||||||
repeat for all meanings of word,
|
repeat for all meanings of word,
|
||||||
*/
|
*/
|
||||||
result.appendChild(header);
|
result.appendChild(header);
|
||||||
|
let last = "";
|
||||||
for (let o = 0; o < json[results[i]].length; o++) {
|
for (let o = 0; o < json[results[i]].length; o++) {
|
||||||
let meaning = document.createElement("div");
|
let meaning = document.createElement("div");
|
||||||
meaning.classList.add("result-meaning");
|
meaning.classList.add("result-meaning");
|
||||||
//ripping off jisho: Bold, word type (*required)
|
//ripping off jisho: Bold, word type (*required)
|
||||||
meaning.innerHTML += "<b class='capitalize'>"+json[results[i]][o]["type"]+"</b>";
|
if (last != json[results[i]][o]["type"]) meaning.innerHTML += "<b class='capitalize'>"+json[results[i]][o]["type"]+"</b><br>";
|
||||||
|
last = json[results[i]][o]["type"];
|
||||||
if (types[json[results[i]][o]["type"]] == undefined) {
|
if (types[json[results[i]][o]["type"]] == undefined) {
|
||||||
types[json[results[i]][o]["type"]] = 1;
|
types[json[results[i]][o]["type"]] = 1;
|
||||||
} else {
|
} else {
|
||||||
types[json[results[i]][o]["type"]]++;
|
types[json[results[i]][o]["type"]]++;
|
||||||
}
|
}
|
||||||
//number, meaning (*required)
|
//number, meaning (*required)
|
||||||
meaning.innerHTML += "<br><span class='result-number'>"+(o+1)+"</span><span class='result-big'>"+json[results[i]][o]["meaning"]+"</span>";
|
meaning.innerHTML += "<span class='result-number'>"+(o+1)+"</span><span class='result-big'>"+json[results[i]][o]["meaning"]+"</span>";
|
||||||
//longer translation (below are not required, make sure to check for them)
|
//longer translation (below are not required, make sure to check for them)
|
||||||
if (json[results[i]][o]["translation"] != undefined && json[results[i]][o]["translation"].toLowerCase() != json[results[i]][o]["meaning"].toLowerCase()) {
|
if (json[results[i]][o]["translation"] != undefined && json[results[i]][o]["translation"].toLowerCase() != json[results[i]][o]["meaning"].toLowerCase()) {
|
||||||
meaning.innerHTML += "<span class='result-translation'>"+json[results[i]][o]["translation"]+"</span>";
|
meaning.innerHTML += "<br><span class='result-translation'>"+json[results[i]][o]["translation"]+"</span>";
|
||||||
}
|
}
|
||||||
//example
|
//example
|
||||||
if (json[results[i]][o]["examples"] != undefined) {
|
if (json[results[i]][o]["examples"] != undefined) {
|
||||||
let temp = ""
|
let temp = ""
|
||||||
temp += "<details><summary>Examples</summary><p>";
|
temp += "<details><summary>Examples</summary><p>";
|
||||||
for (let e in json[results[i]][o]["examples"]) {
|
for (let e in json[results[i]][o]["examples"]) {
|
||||||
temp += "<span class='heonian'>"+e+"</span> - "+json[results[i]][o]["examples"][e]+"<br>";
|
temp += "<span class='heonian'>"+generateRuby(e)+"</span> - "+json[results[i]][o]["examples"][e]+"<br>";
|
||||||
}
|
}
|
||||||
temp += "</p></details>";
|
temp += "</p></details>";
|
||||||
meaning.innerHTML += temp;
|
meaning.innerHTML += temp;
|
||||||
@ -293,10 +304,10 @@ function doSearch() {
|
|||||||
}
|
}
|
||||||
//(source, etc)
|
//(source, etc)
|
||||||
if (json[results[i]][o]["canon-etymology"] != undefined) {
|
if (json[results[i]][o]["canon-etymology"] != undefined) {
|
||||||
meaning.innerHTML += "<details><summary>Canon Etymology</summary><p>"+json[results[i]][o]["canon-etymology"]+"</p></details>";
|
meaning.innerHTML += "<details class='result-meta'><summary>Canon Etymology</summary><p>"+json[results[i]][o]["canon-etymology"]+"</p></details>";
|
||||||
}
|
}
|
||||||
if (json[results[i]][o]["meta-etymology"] != undefined) {
|
if (json[results[i]][o]["meta-etymology"] != undefined) {
|
||||||
meaning.innerHTML += "<details><summary>Meta Etymology</summary><p>"+json[results[i]][o]["meta-etymology"]+"</p></details>";
|
meaning.innerHTML += "<details class='result-meta'><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.
|
||||||
|
Loading…
Reference in New Issue
Block a user