mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-22 22:10:34 +00:00
Some fixes and clean up
This commit is contained in:
@ -247,6 +247,9 @@
|
||||
var resultsListOptions; // specifies ResultsList options
|
||||
var textLookupCountElement // Nr of texts the matches occured in will be shown in this element
|
||||
var xpath; // xpath to grab first resultsList page pagination element
|
||||
var hitsPerPageInputElement;
|
||||
var paginationElements;
|
||||
var contextPerItemElement;
|
||||
|
||||
// ###### Initialize variables ######
|
||||
client = undefined;
|
||||
@ -267,6 +270,7 @@
|
||||
queryResultsUserFeedbackElement = document.getElementById("query-results-user-feedback");
|
||||
receivedMatchCountElement = document.getElementById("received-match-count");
|
||||
textLookupCountElement = document.getElementById("text-lookup-count");
|
||||
paginationElements = document.getElementsByClassName("pagination");
|
||||
|
||||
// ###### js list options and intialization ######
|
||||
displayOptionsData = ResultsList.getDisplayOptions(displayOptionsFormElement);
|
||||
@ -289,20 +293,20 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
//set accordion of collapsibles to false
|
||||
M.Collapsible.init(collapsibleElements, {accordion: false});
|
||||
// creates some models on DOMContentLoaded
|
||||
// creates some modals on DOMContentLoaded
|
||||
contextModal = M.Modal.init(contextModal, {"dismissible": true});
|
||||
exportModal = M.Modal.init(exportModal, {"dismissible": true});
|
||||
initModal = M.Modal.init(initDisplayElement, {"dismissible": false});
|
||||
// Init corpus analysis components
|
||||
resultsJSON = new ResultsJSON();
|
||||
resultsList = new ResultsList("result-list", resultsListOptions);
|
||||
results = new Results(resultsJSON, resultsList)
|
||||
results = new Results(resultsJSON, resultsList);
|
||||
initDisplay = new CorpusAnalysisDisplay(initDisplayElement);
|
||||
queryDisplay = new CorpusAnalysisDisplay(queryDisplayElement);
|
||||
client = new CorpusAnalysisClient({{ corpus_id }}, nopaque.socket);
|
||||
initModal.open();
|
||||
|
||||
// set displays visibilitys and Callback functions
|
||||
// set displays and callback functions
|
||||
client.setDisplay("init", initDisplay);
|
||||
client.setCallback("init", () => {
|
||||
initModal.close();
|
||||
@ -335,16 +339,11 @@
|
||||
}
|
||||
// Prevent page from reloading on submit
|
||||
event.preventDefault();
|
||||
// empty ResultsList and ResultsJSON for new query
|
||||
results.clear_all()
|
||||
// Get query string and send query to server
|
||||
results.resultsJSON.getQueryStr(queryFormElement);
|
||||
client.query(results.resultsJSON.query);
|
||||
});
|
||||
|
||||
// get context of one match if inspected via socket.io
|
||||
nopaque.socket.on("match_context", (response) => { results.resultsList.showMatchContext(response)});
|
||||
|
||||
// live update of hits per page if hits per page value is changed
|
||||
hitsPerPageInputElement = document.getElementById("display-options-form-results_per_page");
|
||||
hitsPerPageInputElement.onchange = results.resultsList.changeHitsPerPage;
|
||||
@ -354,22 +353,22 @@
|
||||
contextPerItemElement.onchange = results.resultsList.changeContext;
|
||||
|
||||
// eventListener if pagination is used to apply new context size to new page
|
||||
// and also activate inspect match if queryFinished is true
|
||||
paginationElements = document.getElementsByClassName("pagination");
|
||||
for (element of paginationElements) {
|
||||
// and also activate inspect match if progress is 100
|
||||
for (let element of paginationElements) {
|
||||
element.addEventListener("click", results.resultsList.changeContext);
|
||||
element.addEventListener("click", results.resultsList.activateInspect);
|
||||
}
|
||||
|
||||
// epxert mode table view
|
||||
expertModeSwitchElement.addEventListener("change", function(event) {
|
||||
// TODO: Redo this
|
||||
expertModeSwitchElement.addEventListener("change", (event) => {
|
||||
let currentTokenElements = document.getElementsByClassName("token");
|
||||
let paginationElements = document.getElementsByClassName("pagination");
|
||||
if (event.target.checked) {
|
||||
results.resultsList.expertModeOn(currentTokenElements, resultsJSON);
|
||||
for (element of paginationElements) {
|
||||
for (let element of paginationElements) {
|
||||
element.tokenElements = currentTokenElements;
|
||||
element.addEventListener("click", (event) => { results.resultsList.eventHandlerCheck(event)});
|
||||
// TODO: This replicates itself on expertModeSwitchElement use
|
||||
}
|
||||
} else {
|
||||
results.resultsList.expertModeOff(currentTokenElements);
|
||||
@ -378,13 +377,13 @@
|
||||
});
|
||||
|
||||
// Add onclick to open download modal when Export Results button is pressed
|
||||
queryResultsExportElement.onclick = function() {
|
||||
queryResultsExportElement.onclick = () => {
|
||||
exportModal.open();
|
||||
}
|
||||
|
||||
// add onclick to download JSON button and download the file
|
||||
downloadResultsJSONElement = document.getElementById("download-results-json")
|
||||
downloadResultsJSONElement.onclick = function() {
|
||||
downloadResultsJSONElement.onclick = () => {
|
||||
let filename = results.resultsJSON.createDownloadFilename();
|
||||
results.resultsJSON.downloadJSONRessource(filename)};
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user