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;
|
margin-bottom: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.result-translation {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: var(--darkgrey);
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-translation::before {
|
||||||
|
content: " - ";
|
||||||
|
}
|
||||||
|
|
||||||
.result summary {
|
.result summary {
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
color: grey;
|
color: grey;
|
||||||
|
28
main.js
28
main.js
@ -164,19 +164,23 @@ function loadDictionary() {
|
|||||||
let keys = Object.keys(json);
|
let keys = Object.keys(json);
|
||||||
//prepare search. maybe async this if we're loading a specific word?
|
//prepare search. maybe async this if we're loading a specific word?
|
||||||
for (let i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
//create array
|
try {
|
||||||
searchDictionary[keys[i]] = [];
|
//create array
|
||||||
|
searchDictionary[keys[i]] = [];
|
||||||
|
|
||||||
//add: word
|
//add: word
|
||||||
searchDictionary[keys[i]].push(keys[i]);
|
searchDictionary[keys[i]].push(keys[i]);
|
||||||
|
|
||||||
//add: romanized word
|
//add: romanized word
|
||||||
searchDictionary[keys[i]].push(stripWord(heonianToRoman(keys[i])));
|
searchDictionary[keys[i]].push(stripWord(heonianToRoman(keys[i])));
|
||||||
|
|
||||||
//add: translations, meanings
|
//add: translations, meanings
|
||||||
for (let o = 0; o < values[i].length; o++) {
|
for (let o = 0; o < values[i].length; o++) {
|
||||||
searchDictionary[keys[i]].push(stripWord(values[i][o]["meaning"]));
|
if (values[i][o].hasOwnProperty("translation")) searchDictionary[keys[i]].push(stripWord(values[i][o]["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)
|
//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 += "<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)
|
//longer translation (below are not required, make sure to check for them)
|
||||||
if (json[results[i]][o]["translation"] != undefined) {
|
if (json[results[i]][o]["translation"] != undefined && json[results[i]][o]["translation"].toLowerCase() != json[results[i]][o]["meaning"].toLowerCase()) {
|
||||||
meaning.innerHTML += "<br><details><summary>Translation</summary><p>"+json[results[i]][o]["translation"]+"</p></details>";
|
meaning.innerHTML += "<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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user