From 85f9625fea004195545c6fba8787b2f898bbbece Mon Sep 17 00:00:00 2001 From: remi Date: Fri, 10 Jun 2022 04:53:11 +0200 Subject: [PATCH] pushing despite. not very done cuz i wanna upload --- main.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/main.js b/main.js index e854ab8..8144f36 100644 --- a/main.js +++ b/main.js @@ -78,8 +78,9 @@ document.addEventListener("keydown", (e) => { } }); -function stripWord(word) { - return word.replace(/[^a-zA-Z-]/gu, "").toLowerCase(); +function stripWord(word, space = false) { + return space == false ? word.replace(/[^a-zA-Z-]/gu, "").toLowerCase() : + word.replace(/[^a-zA-Z-\s]/gu, "").toLowerCase(); } heonianVowels = { @@ -153,6 +154,13 @@ function heonianToRoman(text) { return roman; } +function processVerb(word) { + //basically, turn welikanyapash into liku + //and uhhhhhhhhhhh maybe. return as an object with. all the things . used, for info + return word; + //but ... not yet uwu +} + function loadDictionary() { fetch("./wordlist.json").then((e) => { if (e.status === 200) { @@ -173,11 +181,13 @@ function loadDictionary() { //add: romanized word searchDictionary[keys[i]].push(stripWord(heonianToRoman(keys[i]))); + //what if i add it here. + searchDictionary[keys[i]].push(stripWord(heonianToRoman(keys[i]).replace("dsh","z"))); //add: translations, meanings for (let o = 0; o < values[i].length; o++) { - if (values[i][o].hasOwnProperty("translation")) searchDictionary[keys[i]].push(stripWord(values[i][o]["translation"])); - if (values[i][o].hasOwnProperty("meaning")) searchDictionary[keys[i]].push(stripWord(values[i][o]["meaning"])); + if (values[i][o].hasOwnProperty("translation")) searchDictionary[keys[i]].push(stripWord(values[i][o]["translation"], true)); + if (values[i][o].hasOwnProperty("meaning")) searchDictionary[keys[i]].push(stripWord(values[i][o]["meaning"], true)); } } catch (e) { console.log(keys[i] + " failed to load :/"); @@ -195,8 +205,14 @@ function loadDictionary() { } function search(word) { - word = stripWord(word); - word = heonianToRoman(word); + let words = word.split(" "); + for (let i = 0; i < words.length; i++) { + words[i] = stripWord(words[i]); + words[i] = heonianToRoman(words[i]); + words[i] = processVerb(words[i]); + } + word = words.join(""); + console.log("debug - search: " + word); let result = []; for (let key in searchDictionary) { for (let value in searchDictionary[key]) { @@ -251,7 +267,7 @@ function doSearch() { //ripping off jisho: Bold, word type (*required) meaning.innerHTML += ""+json[results[i]][o]["type"]+""; if (types[json[results[i]][o]["type"]] == undefined) { - types[json[results[i]][o]["type"]] = 0; + types[json[results[i]][o]["type"]] = 1; } else { types[json[results[i]][o]["type"]]++; }