fix funny html bug

This commit is contained in:
remi 2022-06-19 11:35:33 +02:00
parent a6542fbe60
commit 82e4d36b14
2 changed files with 18 additions and 12 deletions

28
main.js
View File

@ -371,13 +371,15 @@ function doSearch(state = true) {
} else { } else {
types[json[results[i]][o]["type"]]++; types[json[results[i]][o]["type"]]++;
} }
//number, meaning (*required) //meaning, tl, etc
meaning.innerHTML += "<span class='result-number'>" + (o + 1) + "</span><span class='result-big'>" + json[results[i]][o]["meaning"] + "</span>"; if (json[results[i]][o]["meaning"] != undefined) {
//longer translation (below are not required, make sure to check for them) meaning.innerHTML += "<span class='result-number'>" + (o + 1) + "</span><span class='result-big'>" + escapeHTML(json[results[i]][o]["meaning"]) + "</span>";
if (json[results[i]][o]["translation"] != undefined) { } else if (json[results[i]][o]["translation"] != undefined) {
if (json[results[i]][o]["meaning"] != undefined && json[results[i]][o]["translation"].toLowerCase() != json[results[i]][o]["meaning"].toLowerCase()) { meaning.innerHTML += "<span class='result-number'>" + (o + 1) + "</span><span class='result-big'>" + escapeHTML(json[results[i]][o]["translation"]) + "</span>";
}
if (json[results[i]][o]["translation"] != undefined && json[results[i]][o]["meaning"] != undefined) {
if (json[results[i]][o]["translation"].toLowerCase() != json[results[i]][o]["meaning"].toLowerCase())
meaning.innerHTML += "<br><span class='result-translation'>" + json[results[i]][o]["translation"] + "</span>"; meaning.innerHTML += "<br><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) {
@ -428,14 +430,14 @@ function doSearch(state = true) {
} }
//notes //notes
if (json[results[i]][o]["notes"] != undefined) { if (json[results[i]][o]["notes"] != undefined) {
meaning.innerHTML += "<p class='result-notes'>" + json[results[i]][o]["notes"] + "</p>"; meaning.innerHTML += "<p class='result-notes'>" + escapeHTML(json[results[i]][o]["notes"]) + "</p>";
} }
//(source, etc) //(source, etc)
if (json[results[i]][o]["canon-etymology"] != undefined) { if (json[results[i]][o]["canon-etymology"] != undefined) {
meaning.innerHTML += "<details class='result-meta'><summary>Canon Etymology</summary><p>" + json[results[i]][o]["canon-etymology"] + "</p></details>"; meaning.innerHTML += "<details class='result-meta'><summary>Canon Etymology</summary><p>" + escapeHTML(json[results[i]][o]["canon-etymology"]) + "</p></details>";
} }
if (json[results[i]][o]["meta-etymology"] != undefined) { if (json[results[i]][o]["meta-etymology"] != undefined) {
meaning.innerHTML += "<details class='result-meta'><summary>Meta Etymology</summary><p>" + json[results[i]][o]["meta-etymology"] + "</p></details>"; meaning.innerHTML += "<details class='result-meta'><summary>Meta Etymology</summary><p>" + escapeHTML(json[results[i]][o]["meta-etymology"]) + "</p></details>";
} }
//todo //todo
result.appendChild(meaning); //y, yeah. result.appendChild(meaning); //y, yeah.
@ -518,9 +520,13 @@ function removeSW() {
caches.delete(name); caches.delete(name);
}); //this doesnt actually seem to work :/ but . i'll leave it in for later fixing }); //this doesnt actually seem to work :/ but . i'll leave it in for later fixing
navigator.serviceWorker.getRegistrations().then(function(registrations) { navigator.serviceWorker.getRegistrations().then(function(registrations) {
for (let registration of registrations) { for (let registration of registrations)
registration.unregister(); registration.unregister();
}}); //dev use only!! or whatever... i just copypasted this from SO }); //dev use only!! or whatever... i just copypasted this from SO
}
function escapeHTML(str){
return new Option(str).innerHTML;
} }
window.onload = () => { window.onload = () => {

2
sw.js
View File

@ -1,4 +1,4 @@
const currentVersion = '2909'; const currentVersion = '20945';
const addResourcesToCache = async (resources) => { const addResourcesToCache = async (resources) => {
const cache = await caches.open(currentVersion); const cache = await caches.open(currentVersion);