From 961027a8f7a68bb0e9a22a835e3ea842a10c0c1a Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Mon, 6 Apr 2020 15:27:25 +0200 Subject: [PATCH] Add global prgress for inspect activation --- app/static/js/nopaque.analyse_corpus.js | 15 ++++++++++----- app/static/js/nopaque.callbacks.js | 3 ++- app/templates/corpora/analyse_corpus.html.j2 | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/static/js/nopaque.analyse_corpus.js b/app/static/js/nopaque.analyse_corpus.js index b96d61d3..11a07754 100644 --- a/app/static/js/nopaque.analyse_corpus.js +++ b/app/static/js/nopaque.analyse_corpus.js @@ -73,11 +73,16 @@ function download(downloadElem, dataStr, filename, type, filenameSlug) { // ###### Functions to inspect one match, to show more details ###### // activate inspect buttons if queryFinished is true -function activateInspect(progress) { - let inspectBtnElements; - inspectBtnElements = document.getElementsByClassName("inspect"); - for (let inspectBtn of inspectBtnElements) { - inspectBtn.classList.remove("disabled"); +function activateInspect() { + console.log("activation progress", progress); + if (progress === 100) { + let inspectBtnElements; + inspectBtnElements = document.getElementsByClassName("inspect"); + for (let inspectBtn of inspectBtnElements) { + inspectBtn.classList.remove("disabled"); + } + } else { + return } } diff --git a/app/static/js/nopaque.callbacks.js b/app/static/js/nopaque.callbacks.js index 43999647..1d683d33 100644 --- a/app/static/js/nopaque.callbacks.js +++ b/app/static/js/nopaque.callbacks.js @@ -50,7 +50,8 @@ function queryRenderResults(payload) { textLookupCountElement.innerText = `${Object.keys(results.resultsJSON.text_lookup).length}`; console.log("Results recieved:", results.resultsJSON); // upate progress status - if (payload.progress === 100) { + progress = payload.progress; // global declaration + if (progress === 100) { queryResultsProgressElement.classList.add("hide"); queryResultsUserFeedbackElement.classList.add("hide"); queryResultsExportElement.classList.remove("disabled"); diff --git a/app/templates/corpora/analyse_corpus.html.j2 b/app/templates/corpora/analyse_corpus.html.j2 index e47c012a..101c1215 100644 --- a/app/templates/corpora/analyse_corpus.html.j2 +++ b/app/templates/corpora/analyse_corpus.html.j2 @@ -230,6 +230,7 @@ var resultsList; // resultsList object var queryFormElement; // the query form var collapsibleElements; // all collapsibles on site + var progress; // global progress value var queryResultsProgressElement; // Div element holding the progress bar var queryResultsDeterminateElement; // The progress bar for recieved results var queryResultsUserFeedbackElement; // Element showing match count|total etc @@ -361,7 +362,7 @@ expertModeOff(currentTokenElements); console.log("unchecked! Destroy"); } - }) + }); }); // Add onclick to open download modal when Export Results button is pressed