From 7de4b391df4b30459b4ad6de7cb7d33209f2cacb Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Thu, 19 Mar 2020 11:04:36 +0100 Subject: [PATCH] Fix inspect activation on queryFinished --- app/static/js/nopaque.analyse_corpus.js | 18 ++++++++------- app/templates/corpora/analyse_corpus.html.j2 | 23 ++++++++------------ 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/app/static/js/nopaque.analyse_corpus.js b/app/static/js/nopaque.analyse_corpus.js index 9acd41ab..2dd914e2 100644 --- a/app/static/js/nopaque.analyse_corpus.js +++ b/app/static/js/nopaque.analyse_corpus.js @@ -60,6 +60,9 @@ function sendQuery(event) { // Function used when CQP server sends back the query results using socketio function recieveResults(response) { + let toolTipInfoElement; + + queryFinished = false; // ERROR code checking if (response["code"] === 0) { @@ -134,14 +137,12 @@ function recieveResults(response) { console.log(queryStatus); queryResultsDeterminateElement.style["width"] = `${queryStatus}%`; console.log(queryResultsDeterminateElement.style["width"]); - let toolTipInfoElement = document.getElementById("tool-tip-info"); - toolTipInfoElement.addEventListener("mouseover", function(event) { - M.Tooltip.init(toolTipInfoElement, {"html": `

The Server is still sending you your results. Functions like "Export Results" and "Match Inspect" will be available after all matches have been loaded.

`, - "inDuration": 1500, - "margin": 15, - "position": "top", - "transitionMovement": 0}) - }); + toolTipInfoElement = document.getElementById("tool-tip-info"); + M.Tooltip.init(toolTipInfoElement, {"html": `

The Server is still sending you your results. Functions like "Export Results" and "Match Inspect" will be available after all matches have been loaded.

`, + "inDuration": 1500, + "margin": 15, + "position": "top", + "transitionMovement": 0}); // enable download and inspect when query is finished // also sets queryFinished to true if (queryStatus === 100) { @@ -178,6 +179,7 @@ function inspect(dataIndex) { function showMatchContext(message) { console.log("### match_context ###"); console.log("Incoming data:", message); + let contextResultsElement = document.getElementById("context-results"); contextResultsElement.innerHTML = "

 

"; document.getElementById("context-modal-loading").classList.add("hide"); document.getElementById("context-modal-ready").classList.remove("hide"); diff --git a/app/templates/corpora/analyse_corpus.html.j2 b/app/templates/corpora/analyse_corpus.html.j2 index e0e143eb..8ffe28a6 100644 --- a/app/templates/corpora/analyse_corpus.html.j2 +++ b/app/templates/corpora/analyse_corpus.html.j2 @@ -237,7 +237,6 @@ server side --> var loadingModal; var exportModal; // create some global variables - var hitsPerPage; var result; var resultList; var queryFinished; @@ -246,9 +245,8 @@ server side --> var queryResultsDeterminateElement; var queryResultsTableElement; var queryLoadingElement; - var toolTipInfoElement; - - var contextResultsElement; + var queryFormElement; + var hitsPerPageInputElement; document.addEventListener("DOMContentLoaded", function() { contextModal = M.Modal.init(document.getElementById("context-modal"), @@ -277,23 +275,20 @@ server side --> // getting some HTML-elements to use/hide/remove/show or add some other // elements to them. // These elements will be used inside functions in nopaque.analyse_corpus.js - var queryResultsDeterminateElement = document.getElementsByClassName("determinate")[0]; - var queryResultsTableElement = document.getElementById("recieved-query-results"); - var queryLoadingElement = document.getElementById("getting-query-results"); - var exportQueryResultsElement = document.getElementById("export-query-results"); - - - var contextResultsElement = document.getElementById("context-results"); + queryResultsDeterminateElement = document.getElementsByClassName("determinate")[0]; + queryResultsTableElement = document.getElementById("recieved-query-results"); + queryLoadingElement = document.getElementById("getting-query-results"); + exportQueryResultsElement = document.getElementById("export-query-results"); // socket.io analysis submit to the CQP server - let queryFormElement = document.getElementById("query-form"); + queryFormElement = document.getElementById("query-form"); queryFormElement.addEventListener("submit", sendQuery); // get context of one match if inspected nopaque.socket.on("match_context", showMatchContext); - // live update of hits per page - var hitsPerPageInputElement = document.getElementById("hits-per-page"); + // live update of hits per page if hits per page value is changed + hitsPerPageInputElement = document.getElementById("hits-per-page"); hitsPerPageInputElement.onchange = changeHitsPerPage; // live update of lr context per item if context value is changed