mv socket on event on match_context to nopaque.js

This commit is contained in:
Stephan Porada 2020-02-03 13:01:26 +01:00
parent 21371efde6
commit da766b32ca
2 changed files with 36 additions and 37 deletions

View File

@ -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 = "<p>&nbsp;</p>";
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();

View File

@ -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 = "<p>&nbsp;</p>";
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');
</script>