Add: updateCount. Fix table caption

This commit is contained in:
eight 2018-09-01 19:12:04 +08:00
parent f42e97d71d
commit 054d94ebd2

View File

@ -20,7 +20,7 @@ var linterReport = (() => { // eslint-disable-line no-var
}
table.update();
table.updateAnnotations(annotations);
$('#lint').classList.toggle('hidden', Array.from(cms.values()).every(t => t.isEmpty()));
updateCount();
});
linter.onUnhook(cm => {
@ -29,6 +29,7 @@ var linterReport = (() => { // eslint-disable-line no-var
table.element.remove();
cms.delete(cm);
}
updateCount();
});
document.addEventListener('DOMContentLoaded', () => {
@ -37,6 +38,15 @@ var linterReport = (() => { // eslint-disable-line no-var
return {refresh};
function updateCount() {
const issueCount = Array.from(cms.values()).reduce((sum, t) => {
sum += t.trs.length;
return sum;
}, 0);
$('#lint').classList.toggle('hidden', issueCount === 0);
$('#issue-count').textContent = issueCount;
}
function getIssues() {
const issues = new Set();
for (const table of cms.values()) {
@ -83,7 +93,7 @@ var linterReport = (() => { // eslint-disable-line no-var
function update() {
caption.textContent = typeof editor === 'object' ?
'' : editors.indexOf(cm) + 1;
'' : `${t('sectionCode')} ${editors.indexOf(cm) + 1}`;
}
function updateAnnotations(lines) {