Fix colors in corpus analysis

This commit is contained in:
Patrick Jentsch 2024-06-03 11:03:57 +02:00
parent a65b1ff578
commit f1ccda6ad7
2 changed files with 21 additions and 15 deletions

View File

@ -498,7 +498,8 @@ nopaque.corpus_analysis.ConcordanceExtension = class ConcordanceExtension {
if (cpos !== firstCpos || pAttr.simple_pos !== 'PUNCT') {html += ' ';}
// Add entity start
if (isEntityStart) {
html += `<span class="s-attr" data-cpos="${cpos}" data-id="${pAttr.ent}" data-s-attr-type="ent" data-s-attr-ent-type="${subcorpus.p.lookups.ent_lookup[pAttr.ent].type}">`;
html += '<span class="s-attr" data-s-attr="ent">';
html += `<span class="s-attr" data-cpos="${cpos}" data-id="${pAttr.ent}" data-s-attr="ent_type" data-s-attr-value="${subcorpus.p.lookups.ent_lookup[pAttr.ent].type}">`;
}
// Add pAttr
html += `<span class="p-attr" data-cpos="${cpos}"></span>`;
@ -506,6 +507,7 @@ nopaque.corpus_analysis.ConcordanceExtension = class ConcordanceExtension {
if (isEntityEnd) {
html += ` <span class="black-text hide new white ent-indicator" data-badge-caption="">${subcorpus.p.lookups.ent_lookup[pAttr.ent].type}</span>`;
html += '</span>';
html += '</span>';
}
}
return html;
@ -522,17 +524,18 @@ nopaque.corpus_analysis.ConcordanceExtension = class ConcordanceExtension {
for (let pAttrElement of this.elements.subcorpusItems.querySelectorAll('.p-attr')) {
pAttrElement.setAttribute('class', 'p-attr');
}
// Set basic styling on .s-attr[data-type="ent"] elements
for (let entElement of this.elements.subcorpusItems.querySelectorAll('.s-attr[data-s-attr-type="ent"]')) {
// Set basic styling on .s-attr[data-s-attr="ent_type"] elements
for (let entElement of this.elements.subcorpusItems.querySelectorAll('.s-attr[data-s-attr="ent_type"]')) {
entElement.querySelector('.ent-indicator').classList.add('hide');
entElement.removeAttribute('style');
// TODO: Check why this is here
// entElement.removeAttribute('style');
entElement.setAttribute('class', 's-attr');
}
}
if (this.settings.textStyle >= 1) {
// Set advanced styling on .s-attr[data-type="ent"] elements
for (let entElement of this.elements.subcorpusItems.querySelectorAll('.s-attr[data-s-attr-type="ent"]')) {
entElement.classList.add('chip');
// Set advanced styling on .s-attr[data-s-attr="ent_type"] elements
for (let entElement of this.elements.subcorpusItems.querySelectorAll('.s-attr[data-s-attr="ent_type"]')) {
entElement.classList.add('chip', 's-attr-color');
entElement.querySelector('.ent-indicator').classList.remove('hide');
}
}

View File

@ -228,7 +228,8 @@ nopaque.corpus_analysis.ReaderExtension = class ReaderExtension {
if (cpos !== firstCpos || pAttr.simple_pos !== 'PUNCT') {html += ' ';}
// Add entity start
if (isEntityStart) {
html += `<span class="s-attr" data-cpos="${cpos}" data-id="${pAttr.ent}" data-s-attr-type="ent" data-s-attr-ent-type="${this.data.corpus.p.lookups.ent_lookup[pAttr.ent].type}">`;
html += '<span class="s-attr" data-s-attr="ent">';
html += `<span class="s-attr" data-cpos="${cpos}" data-id="${pAttr.ent}" data-s-attr="ent_type" data-s-attr-value="${this.data.corpus.p.lookups.ent_lookup[pAttr.ent].type}">`;
}
// Add pAttr
html += `<span class="p-attr" data-cpos="${cpos}"></span>`;
@ -236,6 +237,7 @@ nopaque.corpus_analysis.ReaderExtension = class ReaderExtension {
if (isEntityEnd) {
html += ` <span class="badge black-text hide new white ent-indicator" data-badge-caption="">${this.data.corpus.p.lookups.ent_lookup[pAttr.ent].type}</span>`;
html += '</span>';
html += '</span>';
}
}
return html;
@ -272,17 +274,18 @@ nopaque.corpus_analysis.ReaderExtension = class ReaderExtension {
for (let pAttrElement of this.elements.corpus.querySelectorAll('.p-attr')) {
pAttrElement.setAttribute('class', 'p-attr');
}
// Set basic styling on .s-attr[data-type="ent"] elements
for (let entElement of this.elements.corpus.querySelectorAll('.s-attr[data-s-attr-type="ent"]')) {
// Set basic styling on .s-attr[data-s-attr="ent_type"] elements
for (let entElement of this.elements.corpus.querySelectorAll('.s-attr[data-s-attr="ent_type"]')) {
entElement.querySelector('.ent-indicator').classList.add('hide');
entElement.removeAttribute('style');
// TODO: Check why this is here
// entElement.removeAttribute('style');
entElement.setAttribute('class', 's-attr');
}
}
if (this.settings.textStyle >= 1) {
// Set advanced styling on .s-attr[data-type="ent"] elements
for (let entElement of this.elements.corpus.querySelectorAll('.s-attr[data-s-attr-type="ent"]')) {
entElement.classList.add('chip');
// Set advanced styling on .s-attr[data-s-attr="ent_type"] elements
for (let entElement of this.elements.corpus.querySelectorAll('.s-attr[data-s-attr="ent_type"]')) {
entElement.classList.add('chip', 's-attr-color');
entElement.querySelector('.ent-indicator').classList.remove('hide');
}
}