diff --git a/app/static/js/nopaque.js b/app/static/js/nopaque.js index 35fae36b..3c3d9309 100644 --- a/app/static/js/nopaque.js +++ b/app/static/js/nopaque.js @@ -164,6 +164,42 @@ nopaque.socket.on("foreign_jobs_update", function(msg) { for (let subscriber of nopaque.foreignJobsSubscribers) {subscriber._update(patch);} }); +// get context of one match if inspected +nopaque.socket.on("match_context", function(message) { + console.log("### match_context ###"); + console.log(message); + contextResultsElement.innerHTML = "

 

"; + document.getElementById("context-modal-loading").classList.add("hide"); + document.getElementById("context-modal-ready").classList.remove("hide"); + + let sentenceElement, token, tokenElement; + + lookup["cpos"] = {...lookup["cpos"], ...message["cpos_lookup"]}; + lookup["s"] = message["context_s_cpos"]; + lookup["text"] = {...lookup["text"], ...message["text_lookup"]}; + + for (let [key, value] of Object.entries(message['context_s_cpos'])) { + sentenceElement = document.createElement("p"); + for (cpos of value) { + token = lookup["cpos"][cpos]; + tokenElement = document.createElement("span"); + tokenElement.classList.add("token"); + if (message["match_cpos_list"].includes(cpos)) { + tokenElement.classList.add("bold"); + } + tokenElement.dataset.cpos = cpos; + tokenElement.innerText = token["word"]; + // if (expertModeSwitchElement.checked) { + // tokenElement.classList.add("chip"); + // addToolTipToTokenElement(tokenElement, token); + // } + // tokenElements.add(tokenElement); + sentenceElement.append(tokenElement); + sentenceElement.append(document.createTextNode(" ")); + } + contextResultsElement.append(sentenceElement); + } +}); document.addEventListener("DOMContentLoaded", function() { M.AutoInit(); diff --git a/app/templates/corpora/analyse_corpus.html.j2 b/app/templates/corpora/analyse_corpus.html.j2 index 2f0d4594..1357bc9c 100644 --- a/app/templates/corpora/analyse_corpus.html.j2 +++ b/app/templates/corpora/analyse_corpus.html.j2 @@ -444,43 +444,6 @@ "position": "top", "transitionMovement": 0}); } - - // get context of one match if inspected - nopaque.socket.on("match_context", function(message) { - console.log("### match_context ###"); - console.log(message); - contextResultsElement.innerHTML = "

 

"; - document.getElementById("context-modal-loading").classList.add("hide"); - document.getElementById("context-modal-ready").classList.remove("hide"); - - let sentenceElement, token, tokenElement; - - lookup["cpos"] = {...lookup["cpos"], ...message["cpos_lookup"]}; - lookup["s"] = message["context_s_cpos"]; - lookup["text"] = {...lookup["text"], ...message["text_lookup"]}; - - for (let [key, value] of Object.entries(message['context_s_cpos'])) { - sentenceElement = document.createElement("p"); - for (cpos of value) { - token = lookup["cpos"][cpos]; - tokenElement = document.createElement("span"); - tokenElement.classList.add("token"); - if (message["match_cpos_list"].includes(cpos)) { - tokenElement.classList.add("bold"); - } - tokenElement.dataset.cpos = cpos; - tokenElement.innerText = token["word"]; - // if (expertModeSwitchElement.checked) { - // tokenElement.classList.add("chip"); - // addToolTipToTokenElement(tokenElement, token); - // } - // tokenElements.add(tokenElement); - sentenceElement.append(tokenElement); - sentenceElement.append(document.createTextNode(" ")); - } - contextResultsElement.append(sentenceElement); - } - }); // collapsible display options var elem = document.querySelector('.collapsible.expandable');