diff --git a/app/static/js/nopaque.Results.js b/app/static/js/nopaque.Results.js index 89bd0299..65748c9d 100644 --- a/app/static/js/nopaque.Results.js +++ b/app/static/js/nopaque.Results.js @@ -83,7 +83,7 @@ class Data { class MetaData { // Sets empty object structure when no input is given. - // Else it works like a delete. + // if json object like input is given class fields are created from this init(json = {}) { Object.assign(this, json); } diff --git a/app/static/js/nopaque.callbacks.js b/app/static/js/nopaque.callbacks.js index 48246c7b..bb02a2fc 100644 --- a/app/static/js/nopaque.callbacks.js +++ b/app/static/js/nopaque.callbacks.js @@ -1,15 +1,5 @@ function recvMetaData(payload) { results.metaData.init(payload) - // results.metaDataJSON.corpus_name = payload.corpus_name; - // results.metaDataJSON.corpus_description = payload.corpus_description; - // results.metaDataJSON.corpus_creation_date = payload.corpus_creation_date; - // results.metaDataJSON.corpus_last_edited_date = payload.corpus_last_edited_date; - // results.metaDataJSON.corpus_properties = payload.corpus_properties; - // results.metaDataJSON.corpus_size_tokens = payload.corpus_size_tokens; - // results.metaDataJSON.corpus_all_texts = payload.corpus_all_texts; - // results.metaDataJSON.corpus_analysis_date = payload.corpus_analysis_date; - // results.metaDataJSON.corpus_cqi_py_version = payload.corpus_cqi_py_version; - // results.metaDataJSON.corpus_cqpserver_version = payload.corpus_cqpserver_version; console.log(results.metaData); } diff --git a/app/static/js/nopaque.lists.js b/app/static/js/nopaque.lists.js index 09919626..a82a4402 100644 --- a/app/static/js/nopaque.lists.js +++ b/app/static/js/nopaque.lists.js @@ -168,6 +168,7 @@ class ResultsList extends List { //gets result cpos infos for one dataIndex to send back to the server inspect(dataIndex) { + this.contextId = dataIndex; let contextResultsElement; contextResultsElement = document.getElementById("context-results"); contextResultsElement.innerHTML = ""; // clear it from old inspects @@ -176,7 +177,7 @@ class ResultsList extends List { { payload: { first_cpos: results.data.matches[dataIndex].c[0], - last_cpos: results.data.matches[dataIndex].c[1] + last_cpos: results.data.matches[dataIndex].c[1], } } ); @@ -207,17 +208,19 @@ class ResultsList extends List { let token; let tokenHTMLArray; let tokenHTMlElement; + let uniqueContextS; let uniqueS; - // TODO: contextData needs some identifier like match Nr to indicate what context this is. Also use this in the filename this.contextData = response.payload; this.contextData["query"] = results.data.query; + this.contextData["context_id"] = this.contextId; Object.assign(this.contextData, results.metaData); contextResultsElement = document.getElementById("context-results"); modalExpertModeSwitchElement = document.getElementById("inspect-display-options-form-expert_mode_inspect"); highlightSentencesSwitchElement = document.getElementById("inspect-display-options-form-highlight_sentences"); nrOfContextSentences = document.getElementById("context-sentences"); uniqueS = new Set(); + uniqueContextS = new Set(); // check if cpos ranges are used or not if (this.contextData.cpos_ranges == true) { // python range like function from MDN @@ -246,7 +249,8 @@ class ResultsList extends List { } for (let cpos of c) { token = this.contextData.cpos_lookup[cpos]; - uniqueS.add(token.s) + uniqueContextS.add(token.s); + uniqueS.add(token.s); htmlTokenStr = ` { - let filename = results.data.createDownloadFilename("context"); + let filename = results.data.createDownloadFilename(`context-id-${results.jsList.contextId}`); results.data.addData(results.metaData); results.data.downloadJSONRessource(filename, results.jsList.contextData,