From 126a4a673216d09448c2611ba54a8f70aabc2924 Mon Sep 17 00:00:00 2001 From: wareya Date: Sun, 17 Dec 2017 22:03:23 -0500 Subject: [PATCH] fix deconj display when using alternatives --- background-script.js | 9 ++++++--- texthook.js | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/background-script.js b/background-script.js index 39913e3..5194712 100644 --- a/background-script.js +++ b/background-script.js @@ -670,11 +670,13 @@ function build_lookup_comb (forms) if(!looked_up.hasOwnProperty(form.text)) { let result = search(form.text); + let copied_result = []; if(result) { for(let r = 0; r < result.length; r++) { - let entry = result[r]; + let entry = {}; + Object.assign(entry, result[r]); entry.deconj = undefined; // clear if something set it before, we need this later // store all the parts of speech that this dictionary entry can apply to // normally, they're scattered across its senses @@ -686,8 +688,9 @@ function build_lookup_comb (forms) for(let j = 0; j < sense.pos.length; j++) entry.allpos.add(sense.pos[j]); } + copied_result.push(entry); } - looked_up[form.text] = result; + looked_up[form.text] = copied_result; } } } @@ -999,7 +1002,7 @@ function lookup_indirect(text, time, divexisted, alternatives_mode, strict_alter if(results.length > 0) first = false; } - console.log(results); + //console.log(results); if(results.length > 0) return results; } diff --git a/texthook.js b/texthook.js index 17010ec..04a2205 100644 --- a/texthook.js +++ b/texthook.js @@ -163,8 +163,8 @@ function clip(str) function build_div_inner (text, result) { - console.log("building div for " + text); - console.log(result); + //console.log("building div for " + text); + //console.log(result); let temp = document.createElement("div"); if(settings.showoriginal) { @@ -194,7 +194,7 @@ function build_div_inner (text, result) for(let i = 0; i < result.length; i++) { let term = result[i]; - if(term.deconj) + if(term.deconj && term.deconj.length > 0) text = term.deconj.values().next().value.text; //print_object(term); let temptag = document.createElement("span");