Some more documentation!

This commit is contained in:
Stephan Porada 2020-06-26 10:04:54 +02:00
parent 74104922b6
commit 9f341b90b9
2 changed files with 37 additions and 27 deletions

View File

@ -1,8 +1,13 @@
// This callback is called on a socket.on "corpus_analysis_send_meta_data".
// Handels incoming corpus metadata
function recvMetaData(payload) {
results.metaData.init(payload)
console.log(results.metaData);
}
// This callback is called in socket.on "corpus_analysis_inspect_match" but
// only if the response.type is "sub-results".
// Saves the incoming inspect match results into results.subResultsData.
function saveSubResultsChoices(response) {
console.log("Recieve match with context");
results.subResultsData.init();
@ -28,8 +33,9 @@ function saveSubResultsChoices(response) {
}
// This callback is called on socket.on "query".
// Does some hiding, showing disabling etc.
function querySetup(payload) {
// This is called when a query was successfull
// some hiding and resetting
let textarea = subResultsIdListElement.getElementsByTagName("textarea")[0];
textarea.innerText = "";
@ -54,6 +60,8 @@ function querySetup(payload) {
results.data.match_count = payload.match_count;
}
// This callback is called on socket.on "query_results"
// this handels the incoming result chunks
function queryRenderResults(payload) {
let resultItems; // array of built html result items row element
// This is called when results are transmitted and being recieved

View File

@ -363,12 +363,14 @@
<script>
// ###### Defining global variables used in other functions ######
var addToSubResultsElement; // Button to start adding matches to sub-results
var addToSubResultsFromInspectElement; // button in inspect mdoal to add this match to the sub results
var client; // CorpusAnalysisClient first undefined on DOMContentLoaded defined
var collapsibleElements; // All collapsibleElements on this page
var contextModal; // Modal to open on inspect for further match context
var data; // full JSON object holding match results
var expertModeSwitchElement; // Expert mode switch Element
var initDisplay; // CorpusAnalysisDisplay object first undfined on DOMContentLoaded defined
var interactionElements; // Interaction elements and their parameters
var matchCountElement; // Total nr. of matches will be displayed in this element
var progress; // global progress value
var queryDisplay; // CorpusAnalysisDisplay object first undfined on DOMContentLoaded defined
@ -381,13 +383,11 @@
var results; // results object
var resultsList; // resultsList object
var resultsListOptions; // specifies ResultsList options
var textLookupCountElement // Nr of texts the matches occured in will be shown in this element
var interactionElements; // Interaction elements and their parameters
var textTitlesElement; // matched text titles
var subResultsIdListElement; // list showing marked matches for sub corpus creation
var subResultsExportElement; // button to download sub results
var subResultsCreateElement; // if presses sub results will be created from ids
var addToSubResultsFromInspectElement; // button in inspect mdoal to add this match to the sub results
var subResultsExportElement; // button to download sub results
var subResultsIdListElement; // list showing marked matches for sub corpus creation
var textLookupCountElement // Nr of texts the matches occured in will be shown in this element
var textTitlesElement; // matched text titles
// ###### Defining local scope variables ######
let contextPerItemElement; // Form Element for display option
@ -406,8 +406,9 @@
let xpath; // xpath to grab first resultsList page pagination element
// ###### Initialize variables ######
client = undefined;
addToSubResultsElement = document.getElementById("add-to-sub-results");
addToSubResultsFromInspectElement = document.getElementById("add-to-sub-results-from-inspect");
client = undefined;
collapsibleElements = document.querySelector('.collapsible.expandable');
contextModal = document.getElementById("context-modal");
contextPerItemElement = document.getElementById("display-options-form-result_context");
@ -428,12 +429,11 @@
queryResultsProgressElement = document.getElementById("query-results-progress");
queryResultsUserFeedbackElement = document.getElementById("query-results-user-feedback");
receivedMatchCountElement = document.getElementById("received-match-count");
subResultsCreateElement = document.getElementById("sub-results-create-div");
subResultsExportElement = document.getElementById("sub-results-export");
subResultsIdListElement = document.getElementById("sub-results-match-ids-div");
textLookupCountElement = document.getElementById("text-lookup-count");
textTitlesElement = document.getElementById("text-titles");
subResultsIdListElement = document.getElementById("sub-results-match-ids-div");
subResultsExportElement = document.getElementById("sub-results-export");
subResultsCreateElement = document.getElementById("sub-results-create-div");
addToSubResultsFromInspectElement = document.getElementById("add-to-sub-results-from-inspect");
// ###### js list options and intialization ######
displayOptionsData = ResultsList.getDisplayOptions(displayOptionsFormElement);
@ -531,8 +531,11 @@
// live update of lr context per item if context value is changed
contextPerItemElement.onchange = results.jsList.changeContext;
// stuff that happens in the list table and should also be checked and
// updated if the pagination is used
// Initialization of interactionElemnts
// An interactionElement is an object identifing a switch or button via
// htmlID. Callbacks are set for these elements which will be triggered on
// a pagination interaction by the user or if the status of the element has
// been altered. (Like the switche has ben turned on or off).
interactionElements = new Array();
let expertModeInteraction = new InteractionElement("display-options-form-expert_mode");
expertModeInteraction.setCallback("on",
@ -565,18 +568,6 @@
results.jsList)
interactionElements.push(expertModeInteraction, subResultsInteraction, activateInspectInteraction, changeContextInteraction);
// eventListener if pagination is used to apply new context size to new page
// and also activate inspect match if progress is 100
// also adds more interaction buttons like add to sub results
for (let element of paginationElements) {
element.addEventListener("click", (event) => {
results.jsList.pageChangeEventInteractionHandler(interactionElements);
});
}
// checks if a change for every interactionElement happens and executes
// the callbacks accordingly
for (let interaction of interactionElements) {
@ -596,8 +587,19 @@
continue
}
};
// eventListener if pagination is used to apply new context size to new page
// and also activate inspect match if progress is 100
// also adds more interaction buttons like add to sub results
for (let element of paginationElements) {
element.addEventListener("click", (event) => {
results.jsList.pageChangeEventInteractionHandler(interactionElements);
});
}
});
// ### Download events and sub-results creation ###
// Add onclick to open download modal when Export Results button is pressed
queryResultsExportElement.onclick = () => {
exportModal.open();
@ -631,7 +633,7 @@
results.data.createSubResultsData();
}
// Add onclick to open download modal when sub results button is pressed
// Add onclick to open download modal when sub-results button is pressed
subResultsExportElement.onclick = () => {
exportModal.open();
console.log(results.subResultsData);