2020-04-27 14:16:57 +00:00
|
|
|
function recvMetaData(payload) {
|
2020-04-30 13:21:55 +00:00
|
|
|
results.metaData.init(payload)
|
2020-04-30 12:45:54 +00:00
|
|
|
// 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;
|
2020-04-30 13:21:55 +00:00
|
|
|
console.log(results.metaData);
|
2020-04-27 14:16:57 +00:00
|
|
|
}
|
|
|
|
|
2020-03-31 08:17:04 +00:00
|
|
|
function querySetup(payload) {
|
|
|
|
// This is called when a query was successfull
|
2020-04-09 08:17:04 +00:00
|
|
|
// some hiding and resetting
|
2020-04-01 11:44:06 +00:00
|
|
|
queryResultsExportElement.classList.add("disabled");
|
2020-03-31 08:17:04 +00:00
|
|
|
queryResultsDeterminateElement.style.width = "0%";
|
2020-03-31 08:27:26 +00:00
|
|
|
queryResultsProgressElement.classList.remove("hide");
|
2020-04-01 11:44:06 +00:00
|
|
|
queryResultsUserFeedbackElement.classList.remove("hide");
|
2020-04-08 09:37:34 +00:00
|
|
|
// some initial values
|
2020-04-01 11:44:06 +00:00
|
|
|
receivedMatchCountElement.innerText = "0";
|
|
|
|
textLookupCountElement.innerText = "0";
|
|
|
|
matchCountElement.innerText = payload.match_count;
|
|
|
|
// always re initializes results to delete old results from it
|
2020-04-08 09:37:34 +00:00
|
|
|
// this has to be done here again because the last chunk from old results was still being recieved
|
2020-04-09 08:17:04 +00:00
|
|
|
results.clearAll()
|
2020-04-07 11:13:48 +00:00
|
|
|
// Get query string again
|
2020-04-30 13:21:55 +00:00
|
|
|
results.data.getQueryStr(queryFormElement);
|
|
|
|
results.data.match_count = payload.match_count;
|
2020-03-31 08:17:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function queryRenderResults(payload) {
|
2020-04-08 09:37:34 +00:00
|
|
|
let resultItems; // array of built html result items row element
|
2020-04-01 11:44:06 +00:00
|
|
|
// This is called when results are transmitted and being recieved
|
|
|
|
console.log("Current recieved chunk:", payload.chunk);
|
2020-04-02 12:22:03 +00:00
|
|
|
if (payload.chunk.cpos_ranges == true) {
|
2020-04-30 13:21:55 +00:00
|
|
|
results.data["cpos_ranges"] = true;
|
2020-04-02 12:22:03 +00:00
|
|
|
} else {
|
2020-04-30 13:21:55 +00:00
|
|
|
results.data["cpos_ranges"] = false;
|
2020-04-02 12:22:03 +00:00
|
|
|
}
|
2020-04-01 11:44:06 +00:00
|
|
|
// update progress bar
|
2020-03-31 08:17:04 +00:00
|
|
|
queryResultsDeterminateElement.style.width = `${payload.progress}%`;
|
2020-04-01 11:44:06 +00:00
|
|
|
// building the result list js list from incoming chunk
|
|
|
|
resultItems = []; // list for holding every row item
|
|
|
|
// get infos for full match row
|
|
|
|
for (let [index, match] of payload.chunk.matches.entries()) {
|
2020-04-30 13:21:55 +00:00
|
|
|
resultItems.push({...match, ...{"index": index + results.data.matches.length}});
|
2020-04-01 11:44:06 +00:00
|
|
|
}
|
2020-04-30 13:21:55 +00:00
|
|
|
results.jsList.add(resultItems, (items) => {
|
2020-04-01 11:44:06 +00:00
|
|
|
for (let item of items) {
|
2020-04-30 13:21:55 +00:00
|
|
|
item.elm = results.jsList.createResultRowElement(item, payload.chunk);
|
2020-04-01 11:44:06 +00:00
|
|
|
}
|
2020-04-30 13:21:55 +00:00
|
|
|
results.jsList.update();
|
|
|
|
results.jsList.changeContext(); // sets lr context on first result load
|
2020-04-01 11:44:06 +00:00
|
|
|
});
|
2020-03-31 08:17:04 +00:00
|
|
|
// incorporating new chunk results into full results
|
2020-04-30 13:21:55 +00:00
|
|
|
results.data.matches.push(...payload.chunk.matches);
|
|
|
|
Object.assign(results.data.cpos_lookup, payload.chunk.cpos_lookup);
|
|
|
|
Object.assign(results.data.text_lookup, payload.chunk.text_lookup);
|
2020-04-01 11:44:06 +00:00
|
|
|
// show user current and total match count
|
2020-04-30 13:21:55 +00:00
|
|
|
receivedMatchCountElement.innerText = `${results.data.matches.length}`;
|
|
|
|
textLookupCountElement.innerText = `${Object.keys(results.data.text_lookup).length}`;
|
|
|
|
console.log("Results recieved:", results.data);
|
2020-04-06 10:41:23 +00:00
|
|
|
// upate progress status
|
2020-04-06 13:27:25 +00:00
|
|
|
progress = payload.progress; // global declaration
|
|
|
|
if (progress === 100) {
|
2020-04-06 10:41:23 +00:00
|
|
|
queryResultsProgressElement.classList.add("hide");
|
|
|
|
queryResultsUserFeedbackElement.classList.add("hide");
|
|
|
|
queryResultsExportElement.classList.remove("disabled");
|
2020-04-30 13:21:55 +00:00
|
|
|
results.jsList.activateInspect();
|
2020-04-06 10:41:23 +00:00
|
|
|
}
|
2020-04-06 12:09:12 +00:00
|
|
|
// inital expert mode check and activation
|
2020-04-06 12:35:57 +00:00
|
|
|
if (expertModeSwitchElement.checked) {
|
2020-04-30 13:21:55 +00:00
|
|
|
results.jsList.expertModeOn("query-display");
|
2020-04-06 10:52:26 +00:00
|
|
|
}
|
2020-03-31 08:17:04 +00:00
|
|
|
}
|