From f8aa18e2a743f6ac35a79d26b72ce80f2cb9397c Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 25 Feb 2020 11:00:30 +0100 Subject: [PATCH] Add expert view to inspect view. --- app/static/js/nopaque.js | 10 +++++----- app/templates/corpora/analyse_corpus.html.j2 | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/static/js/nopaque.js b/app/static/js/nopaque.js index bae1d8a4..c7dda181 100644 --- a/app/static/js/nopaque.js +++ b/app/static/js/nopaque.js @@ -206,14 +206,14 @@ nopaque.socket.on("match_context", function(message) { tokenElement.classList.add("token"); if (message["match_cpos_list"].includes(cpos)) { tokenElement.classList.add("bold"); + tokenElement.classList.add("light-green"); } tokenElement.dataset.cpos = cpos; tokenElement.innerText = token["word"]; - // if (expertModeSwitchElement.checked) { - // tokenElement.classList.add("chip"); - // addToolTipToTokenElement(tokenElement, token); - // } - // tokenElements.add(tokenElement); + var expertModeSwitchElement = document.getElementById("expert-mode-switch"); + if (expertModeSwitchElement.checked) { + expertModeOn([tokenElement], message); + } sentenceElement.append(tokenElement); sentenceElement.append(document.createTextNode(" ")); } diff --git a/app/templates/corpora/analyse_corpus.html.j2 b/app/templates/corpora/analyse_corpus.html.j2 index 71bdf95d..063fd5d0 100644 --- a/app/templates/corpora/analyse_corpus.html.j2 +++ b/app/templates/corpora/analyse_corpus.html.j2 @@ -445,14 +445,14 @@ } } - // epxert mode + // epxert mode table view var expertModeSwitchElement = document.getElementById("expert-mode-switch"); expertModeSwitchElement.addEventListener("change", function(event) { var currentTokenElements = document.getElementsByClassName("token"); var paginationElements = document.getElementsByClassName("pagination"); if (event.target.checked) { console.log("Checked!"); - expertModeOn(currentTokenElements); + expertModeOn(currentTokenElements, result); for (element of paginationElements) { element.addEventListener("click", eventHandlerCheck); element.tokenElements = currentTokenElements; @@ -468,7 +468,7 @@ console.log("pagination used!"); console.log(expertModeSwitchElement.checked); if (expertModeSwitchElement.checked) { - expertModeOn(event.currentTarget.tokenElements); + expertModeOn(event.currentTarget.tokenElements, result); } else if (!expertModeSwitchElement.checked) { event.preventDefault(); console.log("prevented! Destroy"); @@ -490,17 +490,17 @@ } } - function expertModeOn(tokenElements) { + function expertModeOn(tokenElements, result_lookup) { console.log("expertModeOn!"); for (tokenElement of tokenElements) { tokenElement.classList.add("chip"); tokenElement.classList.add("hoverable"); tokenElement.classList.add("expert-view"); - token = result["cpos_lookup"][tokenElement.dataset.cpos]; + token = result_lookup["cpos_lookup"][tokenElement.dataset.cpos]; tokenElement.addEventListener("mouseover", function(event) { console.log("Mouseover!"); console.log(event.target); - token = result["cpos_lookup"][event.target.dataset.cpos]; + token = result_lookup["cpos_lookup"][event.target.dataset.cpos]; addToolTipToTokenElement(event.target, token); }) }