trying diffrent design for translations. not sure if i like this more than just hiding the tl, but also. hiding the tl is silly?
This commit is contained in:
parent
a035ea3201
commit
260e25e37a
9
main.css
9
main.css
@ -224,6 +224,15 @@ main {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.result-translation {
|
||||
font-size: 0.9rem;
|
||||
color: var(--darkgrey);
|
||||
}
|
||||
|
||||
.result-translation::before {
|
||||
content: " - ";
|
||||
}
|
||||
|
||||
.result summary {
|
||||
margin-top: 4px;
|
||||
color: grey;
|
||||
|
28
main.js
28
main.js
@ -164,19 +164,23 @@ function loadDictionary() {
|
||||
let keys = Object.keys(json);
|
||||
//prepare search. maybe async this if we're loading a specific word?
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
//create array
|
||||
searchDictionary[keys[i]] = [];
|
||||
try {
|
||||
//create array
|
||||
searchDictionary[keys[i]] = [];
|
||||
|
||||
//add: word
|
||||
searchDictionary[keys[i]].push(keys[i]);
|
||||
//add: word
|
||||
searchDictionary[keys[i]].push(keys[i]);
|
||||
|
||||
//add: romanized word
|
||||
searchDictionary[keys[i]].push(stripWord(heonianToRoman(keys[i])));
|
||||
//add: romanized word
|
||||
searchDictionary[keys[i]].push(stripWord(heonianToRoman(keys[i])));
|
||||
|
||||
//add: translations, meanings
|
||||
for (let o = 0; o < values[i].length; o++) {
|
||||
searchDictionary[keys[i]].push(stripWord(values[i][o]["meaning"]));
|
||||
searchDictionary[keys[i]].push(stripWord(values[i][o]["translation"]));
|
||||
//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"]));
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(keys[i] + " failed to load :/");
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,8 +248,8 @@ function doSearch() {
|
||||
//number, meaning (*required)
|
||||
meaning.innerHTML += "<br><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)
|
||||
if (json[results[i]][o]["translation"] != undefined) {
|
||||
meaning.innerHTML += "<br><details><summary>Translation</summary><p>"+json[results[i]][o]["translation"]+"</p></details>";
|
||||
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>";
|
||||
}
|
||||
//example
|
||||
if (json[results[i]][o]["examples"] != undefined) {
|
||||
|
Loading…
Reference in New Issue
Block a user