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:
remi 2022-06-10 01:33:31 +02:00
parent a035ea3201
commit 260e25e37a
2 changed files with 25 additions and 12 deletions

View File

@ -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;

12
main.js
View File

@ -164,6 +164,7 @@ 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++) {
try {
//create array
searchDictionary[keys[i]] = [];
@ -175,8 +176,11 @@ function loadDictionary() {
//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"]));
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) {