Add result rendering for the user etc.

This commit is contained in:
Stephan Porada
2020-08-25 15:56:04 +02:00
parent d2453c2cc3
commit 763183435d
10 changed files with 183 additions and 69 deletions

View File

@ -96,6 +96,9 @@ import {
import {
recieveNotification,
} from '../../static/js/modules/corpus_analysis/view/listeners.js';
import {
scrollToTop,
} from '../../static/js/modules/corpus_analysis/view/scrollToTop.js'
/**
* Second Phase:
@ -114,7 +117,7 @@ document.addEventListener("DOMContentLoaded", () => {
* object as the View handeling the represnetation of the data.
*/
let results = new Results();
let resultsView = new ResultsList('result-list', ResultsList.options);
let resultsList = new ResultsList('result-list', ResultsList.options);
/**
* Register listeners listening to socket.io events and their callbacks
* Afterwards load them.
@ -145,18 +148,18 @@ document.addEventListener("DOMContentLoaded", () => {
listenForMetaData]);
client.loadSocketEventListeners();
/**
* Register resultsView listeners listening to nitification events.
* Register resultsList listeners listening to nitification events.
*/
const listenForNotification = new NotificationListener('notify',
recieveNotification);
resultsView.setNotificationListeners([listenForNotification]);
resultsView.loadNotificationListeners();
resultsList.setNotificationListeners([listenForNotification]);
resultsList.loadNotificationListeners();
// Connect client to server
client.notifyView('connecting');
client.connect();
// Send a query and recieve its answer data
let queryFormElement = document.getElementById('query-form');
let queryFormElement = document.querySelector('#query-form');
queryFormElement.addEventListener('submit', (event) => {
try {
/**
@ -178,6 +181,25 @@ document.addEventListener("DOMContentLoaded", () => {
results.data.getQueryStr(queryFormElement);
client.query(results.data.query);
});
/**
* Display events
* 1. live update of hits per page if hits per page value is changed
*/
resultsList.getHTMLElements([
'#display-options-form-results_per_page',
'#display-options-form-result_context'
]);
resultsList.displayOptionsFormResultsPerPage.onchange = () => {
resultsList.changeHitsPerPage();
};
resultsList.displayOptionsFormResultContext.onchange = () => {
resultsList.changeContext();
};
// enable scroll to Top
scrollToTop('.headline', '#menu-scroll-to-top-div');
});
</script>
{% endblock %}