nopaque/app/static/js/nopaque.callbacks.js
2020-03-31 10:17:04 +02:00

31 lines
1.2 KiB
JavaScript

function querySetup(payload) {
// This is called when a query was successfull
console.log("Query setup.");
console.log(payload);
queryResultsDeterminateElement.style.width = "0%";
receivedMatchNumElement.innerText = "0";
textLookupNumElement.innerText = "0";
matchNumElement.innerText = payload.num_matches;
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[]
}
function queryRenderResults(payload) {
// This is called when results are transmitted.
console.log("CHUNK:", payload.chunk);
console.log("RESULTS:", results);
if (payload.progress === 100) {
queryResultsProgressElement.classList.add("hide");
}
queryResultsDeterminateElement.style.width = `${payload.progress}%`;
results.matches.push(...payload.chunk.matches);
receivedMatchNumElement.innerText = `${results.matches.length}`;
// incorporating new chunk results into full results
Object.assign(results.cpos_lookup, payload.chunk.cpos_lookup);
Object.assign(results.text_lookup, payload.chunk.text_lookup);
textLookupNumElement.innerText = `${Object.keys(results.text_lookup).length}`;
}