diff --git a/web/app/static/js/modules/corpus_analysis/client/Client.js b/web/app/static/js/modules/corpus_analysis/client/Client.js index 496749bb..7aac251d 100644 --- a/web/app/static/js/modules/corpus_analysis/client/Client.js +++ b/web/app/static/js/modules/corpus_analysis/client/Client.js @@ -122,6 +122,16 @@ class Client { getResultsData(resultsType, dataIndexes, results) { let tmp_first_cpos = []; let tmp_last_cpos = []; + let objectKey = ''; + if (resultsType === 'full-results') { + objectKey = 'fullResultsData'; + } else if (resultsType === 'sub-results') { + objectKey = 'subResultsData'; + } else if (resultsType = 'inspect-results') { + objectKey = 'inspectResultsData'; + } + // Delete old data before new data is coming in. + results[objectKey].init(); for (let dataIndex of dataIndexes) { tmp_first_cpos.push(results.data.matches[dataIndex].c[0]); tmp_last_cpos.push(results.data.matches[dataIndex].c[1]); diff --git a/web/app/static/js/modules/corpus_analysis/client/callbacks.js b/web/app/static/js/modules/corpus_analysis/client/callbacks.js index 445e4df3..2eaddb9d 100644 --- a/web/app/static/js/modules/corpus_analysis/client/callbacks.js +++ b/web/app/static/js/modules/corpus_analysis/client/callbacks.js @@ -90,7 +90,7 @@ function getResultsData() { } /** - * Handles incoming results whcih have been requestes via getResultsData(). and + * Handles incoming results which have been requested via getResultsData(). and * saves the data accorindgly into the results object. */ function saveResultsData() { @@ -103,7 +103,7 @@ function saveResultsData() { console.info('Saving sub-results data.'); objectKey = 'subResultsData'; } else if (type = 'inspect-results') { - objectKey = 'inspectResultsData' + objectKey = 'inspectResultsData'; console.info('Saving inspect-results data'); } // Save incoming data. Data is incoming one match at a time. diff --git a/web/app/static/js/modules/corpus_analysis/view/ResultsView.js b/web/app/static/js/modules/corpus_analysis/view/ResultsView.js index 5f6b8830..b1378831 100644 --- a/web/app/static/js/modules/corpus_analysis/view/ResultsView.js +++ b/web/app/static/js/modules/corpus_analysis/view/ResultsView.js @@ -327,7 +327,14 @@ class ResultsList extends List { ]); // Clear fields from old data on every new inspect() call. this.contextId = dataIndex[0]; - this.contextResults.innerHTML = ""; + this.contextResults.innerHTML = ''; + // Open modal. + this.contextModal.open(); + this.contextResults.insertAdjacentHTML('afterbegin', ` +
+
+
+ `); if (client.dynamicMode) { // Notify Client to get results from server. this.notifyClient('get-results', {resultsType: 'inspect-results', @@ -342,7 +349,6 @@ class ResultsList extends List { // Match nr for user to display derived from data_index. let contextMatchNrElement = document.getElementById("context-match-nr"); contextMatchNrElement.textContent = this.contextId + 1; - this.contextModal.open(); // Add the add button to add this match to sub results with onclick event. let classes = `btn-floating btn waves-effect` + ` waves-light corpus-analysis-color.lighten right` @@ -390,7 +396,6 @@ class ResultsList extends List { '#inspect-display-options-form-highlight_sentences', '#context-sentences' ]) - let uniqueS = new Set(); let uniqueContextS = new Set(); let {lc, c, rc} = this.helperCreateCpos(results.inspectResultsData.cpos_ranges, @@ -451,6 +456,8 @@ class ResultsList extends List { tokenHTMlElement = this.HTMLTStrToElement(htmlTokenStr) tokenHTMLArray.push(tokenHTMlElement); } + // Remove loading indeterminate HTML before context is inserted. + this.contextResults.innerHTML = ''; for (let sId of uniqueS) { let htmlSentence = ``; let sentenceElement = this.HTMLTStrToElement(htmlSentence);