Soem clean up and restructure

This commit is contained in:
Stephan Porada
2020-07-21 13:40:17 +02:00
parent 7dfc3ab877
commit 1b853f3338
17 changed files with 509 additions and 604 deletions

View File

@ -112,8 +112,6 @@ function queryRenderResults(payload, imported=false) {
} 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
@ -121,6 +119,8 @@ function queryRenderResults(payload, imported=false) {
resultItems.push({...match, ...{"index": index + results.data.matches.length}});
}
if (!imported) {
// update progress bar
queryResultsDeterminateElement.style.width = `${payload.progress}%`;
results.jsList.add(resultItems, (items) => {
for (let item of items) {
item.elm = results.jsList.createResultRowElement(item, payload.chunk);

View File

@ -1015,4 +1015,87 @@ class ResultsList extends List {
}
return matchRowElement
}
// creates the HTML table code for the metadata vie in the corpus analysis interface
createMetaDataForModal(metaDataObject) {
let table = `<div class="col s12">
<table class="highlight">
<thead>
<tr>
<th>Metadata Description</th>
<th>Value</th>
</tr>
</thead>
<tbody>`
for (let [outerKey, outerValue] of Object.entries(metaDataObject)) {
table += `<tr>
<td>${outerKey}</td>`
if (outerKey === "corpus_all_texts" || outerKey === "text_lookup") {
table += `<td>
<table>`
for (let [innerKey, innerValue] of Object.entries(outerValue)) {
table += `<tr style="border-bottom: none;">
<td>
<i>${innerValue.title}</i> written
by <i>${innerValue.author}</i>
in <i>${innerValue.publishing_year}</i>
<a class="waves-effect
waves-light
btn
right
more-text-detials"
data-metadata-key="${outerKey}"
data-text-key="${innerKey}"
href="#modal-text-details">More
<i class="material-icons right"
data-metadata-key="${outerKey}"
data-text-key="${innerKey}">
info_outline
</i>
</a>
</td>
</tr>`
}
table += `</td>
</table>`
} else {
table += `<td>${outerValue}</td>`
}
table += `</tr>`
}
table += `</tbody>
</table>`
return table
}
// Creates the text details for the texts shown in the corpus analysis metadata modal.
createTextDetails(metaDataObject) {
let modal = document.getElementById("modal-text-details");
modal = M.Modal.init(modal, {"dismissible": true});
modal.open();
let metadataKey = event.target.dataset.metadataKey;
let textKey = event.target.dataset.textKey;
let textData = metaDataObject[metadataKey][textKey];
let bibliographicData = document.getElementById("bibliographic-data");
bibliographicData.innerHTML = "";
let table = document.createElement("table");
for (let [key, value] of Object.entries(textData)) {
table.insertAdjacentHTML("afterbegin",
`
<tr>
<td>${key}</td>
<td>${value}</td>
</tr>
`);
}
table.insertAdjacentHTML("afterbegin",
`
<thead>
<th>Description</th>
<th>Value</th>
</thead>
`)
bibliographicData.appendChild(table);
}
}