diff --git a/main.css b/main.css index c6d354c..54a2155 100644 --- a/main.css +++ b/main.css @@ -128,6 +128,9 @@ header input:focus { header span.heonian { font-size: 1.5rem; + cursor: pointer; + user-select: none; + -webkit-user-select: none; } header.fullscreen { @@ -145,6 +148,7 @@ header.fullscreen { header.fullscreen span.heonian { font-size: 8rem; + cursor: default; } header.fullscreen #search { @@ -191,6 +195,10 @@ main { padding-top: 0; } +.result:last-child { + border-bottom: none; +} + .result-meaning { padding-bottom: 8px; } @@ -222,6 +230,8 @@ main { color: var(--darkgrey); margin-top: 6px; margin-bottom: 6px; + border-left: 3px solid var(--darkgrey); + padding-left: 4px; } .result-translation { @@ -244,4 +254,12 @@ main { font-size: 1.25rem; } +.results-header-count::after { + content: ", "; +} + +.results-header-count:last-child::after { + content: ""; +} + /* todo. organize this file better. this is a fucking mess */ \ No newline at end of file diff --git a/main.js b/main.js index cebf66c..e854ab8 100644 --- a/main.js +++ b/main.js @@ -169,7 +169,7 @@ function loadDictionary() { searchDictionary[keys[i]] = []; //add: word - searchDictionary[keys[i]].push(keys[i]); + // searchDictionary[keys[i]].push(keys[i]); //add: romanized word searchDictionary[keys[i]].push(stripWord(heonianToRoman(keys[i]))); @@ -196,6 +196,7 @@ function loadDictionary() { function search(word) { word = stripWord(word); + word = heonianToRoman(word); let result = []; for (let key in searchDictionary) { for (let value in searchDictionary[key]) { @@ -209,7 +210,8 @@ function search(word) { } function doSearch() { - let results = search(header.querySelector("input").value); + let val = header.querySelector("input").value; + let results = search(val); if (results.length == 0) { main.innerHTML = "no results lulw"; } else { @@ -217,6 +219,7 @@ function doSearch() { /* [words - 420 found / expressions - 69 found / wahtever else - ygettheidea] (click one to filter to just those) */ + let types = {} for (let i = 0; i < results.length; i++) { let result = document.createElement("div"); result.classList.add("result"); @@ -227,8 +230,10 @@ function doSearch() { header.innerHTML = results[i] + " " + heonianToRoman(results[i]) + ""; // 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? // 3. formal/nonformal versions, inflections button + // could try to work on this though // 4. audio clip if found @@ -245,6 +250,11 @@ function doSearch() { meaning.classList.add("result-meaning"); //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; + } else { + types[json[results[i]][o]["type"]]++; + } //number, meaning (*required) meaning.innerHTML += "
"+(o+1)+""+json[results[i]][o]["meaning"]+""; //longer translation (below are not required, make sure to check for them) @@ -256,7 +266,7 @@ function doSearch() { let temp = "" temp += "
Examples

"; for (let e in json[results[i]][o]["examples"]) { - temp += ""+e+" - "+json[results[i]][o]["examples"][e]; + temp += ""+e+" - "+json[results[i]][o]["examples"][e]+"
"; } temp += "

"; meaning.innerHTML += temp; @@ -277,6 +287,14 @@ function doSearch() { } main.appendChild(result); } + types = sortObject(types); + let header = document.createElement("div"); + header.classList.add("results-header"); + header.innerHTML += "search results for: " + val + "
"; + for (let i in types) { + header.innerHTML += ""+i+"s - "+types[i]+""; + } + main.prepend(header); } } @@ -284,5 +302,12 @@ window.onload = () => { header = document.querySelector("header"); main = document.querySelector("main"); header.querySelector("#search button").onclick = () => {toggleIME();}; + header.querySelector("span.heonian").onclick = () => { + if (!header.classList.contains("fullscreen")) { + animateHeader(true); + } + }; loadDictionary(); -} \ No newline at end of file +} + +const sortObject = obj => Object.keys(obj).sort().reduce((res, key) => (res[key] = obj[key], res), {}) \ No newline at end of file