pushing despite. not very done cuz i wanna upload
This commit is contained in:
parent
fad6471e48
commit
85f9625fea
30
main.js
30
main.js
@ -78,8 +78,9 @@ document.addEventListener("keydown", (e) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function stripWord(word) {
|
function stripWord(word, space = false) {
|
||||||
return word.replace(/[^a-zA-Z-]/gu, "").toLowerCase();
|
return space == false ? word.replace(/[^a-zA-Z-]/gu, "").toLowerCase() :
|
||||||
|
word.replace(/[^a-zA-Z-\s]/gu, "").toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
heonianVowels = {
|
heonianVowels = {
|
||||||
@ -153,6 +154,13 @@ function heonianToRoman(text) {
|
|||||||
return roman;
|
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() {
|
function loadDictionary() {
|
||||||
fetch("./wordlist.json").then((e) => {
|
fetch("./wordlist.json").then((e) => {
|
||||||
if (e.status === 200) {
|
if (e.status === 200) {
|
||||||
@ -173,11 +181,13 @@ function loadDictionary() {
|
|||||||
|
|
||||||
//add: romanized word
|
//add: romanized word
|
||||||
searchDictionary[keys[i]].push(stripWord(heonianToRoman(keys[i])));
|
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
|
//add: translations, meanings
|
||||||
for (let o = 0; o < values[i].length; o++) {
|
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("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"]));
|
if (values[i][o].hasOwnProperty("meaning")) searchDictionary[keys[i]].push(stripWord(values[i][o]["meaning"], true));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(keys[i] + " failed to load :/");
|
console.log(keys[i] + " failed to load :/");
|
||||||
@ -195,8 +205,14 @@ function loadDictionary() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function search(word) {
|
function search(word) {
|
||||||
word = stripWord(word);
|
let words = word.split(" ");
|
||||||
word = heonianToRoman(word);
|
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 = [];
|
let result = [];
|
||||||
for (let key in searchDictionary) {
|
for (let key in searchDictionary) {
|
||||||
for (let value in searchDictionary[key]) {
|
for (let value in searchDictionary[key]) {
|
||||||
@ -251,7 +267,7 @@ function doSearch() {
|
|||||||
//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>";
|
meaning.innerHTML += "<b class='capitalize'>"+json[results[i]][o]["type"]+"</b>";
|
||||||
if (types[json[results[i]][o]["type"]] == undefined) {
|
if (types[json[results[i]][o]["type"]] == undefined) {
|
||||||
types[json[results[i]][o]["type"]] = 0;
|
types[json[results[i]][o]["type"]] = 1;
|
||||||
} else {
|
} else {
|
||||||
types[json[results[i]][o]["type"]]++;
|
types[json[results[i]][o]["type"]]++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user