mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 17:25:44 +00:00
55 lines
2.4 KiB
JavaScript
55 lines
2.4 KiB
JavaScript
function querySetup(payload) {
|
|
// This is called when a query was successfull
|
|
// some hiding
|
|
queryResultsExportElement.classList.add("disabled");
|
|
|
|
console.log("Query initial setup seccessfull.");
|
|
queryResultsDeterminateElement.style.width = "0%";
|
|
queryResultsProgressElement.classList.remove("hide");
|
|
queryResultsUserFeedbackElement.classList.remove("hide");
|
|
receivedMatchCountElement.innerText = "0";
|
|
textLookupCountElement.innerText = "0";
|
|
matchCountElement.innerText = payload.match_count;
|
|
// always re initializes results to delete old results from it
|
|
results = {};
|
|
results["matches"] = []; // list of all c with lc and rc
|
|
results["cpos_lookup"] = {}; // object contains all cpos as key value pair
|
|
results["text_lookup"] = {}; // same as above for all text ids
|
|
results["match_count"] = payload.match_count;
|
|
results["query"] = client.getQueryStr(queryFormElement);
|
|
}
|
|
|
|
function queryRenderResults(payload) {
|
|
// This is called when results are transmitted and being recieved
|
|
console.log("Current recieved chunk:", payload.chunk);
|
|
// upate progress status
|
|
if (payload.progress === 100) {
|
|
queryResultsProgressElement.classList.add("hide");
|
|
queryResultsUserFeedbackElement.classList.add("hide");
|
|
queryResultsExportElement.classList.remove("disabled");
|
|
activateInspect();
|
|
}
|
|
// update progress bar
|
|
queryResultsDeterminateElement.style.width = `${payload.progress}%`;
|
|
// 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()) {
|
|
resultItems.push({...match, ...{"index": index + results.matches.length}});
|
|
}
|
|
client.resultList.add(resultItems, (items) => {
|
|
for (let item of items) {
|
|
item.elm = client.resultList.createResultRowElement(item, payload.chunk);
|
|
}
|
|
client.resultList.update();
|
|
changeContext(); // sets lr context on first result load
|
|
});
|
|
// incorporating new chunk results into full results
|
|
results.matches.push(...payload.chunk.matches);
|
|
Object.assign(results.cpos_lookup, payload.chunk.cpos_lookup);
|
|
Object.assign(results.text_lookup, payload.chunk.text_lookup);
|
|
// show user current and total match count
|
|
receivedMatchCountElement.innerText = `${results.matches.length}`;
|
|
textLookupCountElement.innerText = `${Object.keys(results.text_lookup).length}`;
|
|
console.log("Results recieved:", results);
|
|
} |