mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 09:15:41 +00:00
69 lines
2.9 KiB
JavaScript
69 lines
2.9 KiB
JavaScript
function recvMetaData(payload) {
|
|
results.metaData.init(payload)
|
|
console.log(results.metaData);
|
|
}
|
|
|
|
function querySetup(payload) {
|
|
// This is called when a query was successfull
|
|
// some hiding and resetting
|
|
queryResultsExportElement.classList.add("disabled");
|
|
queryResultsDeterminateElement.style.width = "0%";
|
|
queryResultsProgressElement.classList.remove("hide");
|
|
queryResultsUserFeedbackElement.classList.remove("hide");
|
|
// some initial values
|
|
receivedMatchCountElement.innerText = "0";
|
|
textLookupCountElement.innerText = "0";
|
|
matchCountElement.innerText = payload.match_count;
|
|
// always re initializes results to delete old results from it
|
|
// this has to be done here again because the last chunk from old results was still being recieved
|
|
results.clearAll()
|
|
// Get query string again
|
|
results.data.getQueryStr(queryFormElement);
|
|
results.data.match_count = payload.match_count;
|
|
}
|
|
|
|
function queryRenderResults(payload) {
|
|
let resultItems; // array of built html result items row element
|
|
// This is called when results are transmitted and being recieved
|
|
console.log("Current recieved chunk:", payload.chunk);
|
|
if (payload.chunk.cpos_ranges == true) {
|
|
results.data["cpos_ranges"] = true;
|
|
} else {
|
|
results.data["cpos_ranges"] = false;
|
|
}
|
|
// 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.data.matches.length}});
|
|
}
|
|
results.jsList.add(resultItems, (items) => {
|
|
for (let item of items) {
|
|
item.elm = results.jsList.createResultRowElement(item, payload.chunk);
|
|
}
|
|
results.jsList.update();
|
|
results.jsList.changeContext(); // sets lr context on first result load
|
|
});
|
|
// incorporating new chunk results into full results
|
|
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);
|
|
// show user current and total match count
|
|
receivedMatchCountElement.innerText = `${results.data.matches.length}`;
|
|
textLookupCountElement.innerText = `${Object.keys(results.data.text_lookup).length}`;
|
|
console.log("Results recieved:", results.data);
|
|
// upate progress status
|
|
progress = payload.progress; // global declaration
|
|
if (progress === 100) {
|
|
queryResultsProgressElement.classList.add("hide");
|
|
queryResultsUserFeedbackElement.classList.add("hide");
|
|
queryResultsExportElement.classList.remove("disabled");
|
|
results.jsList.activateInspect();
|
|
}
|
|
// inital expert mode check and activation
|
|
if (expertModeSwitchElement.checked) {
|
|
results.jsList.expertModeOn("query-display");
|
|
}
|
|
} |