From 5fa54108226a8b94ba1a091903fcafd453d7e905 Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 14 Feb 2022 22:15:19 +0300 Subject: [PATCH] simplify lint report html/css/js --- edit/edit.css | 13 +++++++------ edit/linter-manager.js | 18 +++++++----------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/edit/edit.css b/edit/edit.css index 4377b500..b8acdf96 100644 --- a/edit/edit.css +++ b/edit/edit.css @@ -843,6 +843,8 @@ body:not(.find-open) [data-match-highlight-count="1"] .CodeMirror-selection-high border-spacing: 0; line-height: 1.0; width: 100%; + font-size: 85%; + cursor: pointer; } #lint tr td:last-child { width: 100%; @@ -850,6 +852,9 @@ body:not(.find-open) [data-match-highlight-count="1"] .CodeMirror-selection-high #lint td[role="line"] { padding-left: 0.25rem; } +#lint .report { + display: flex; +} #lint .empty { display: none; } @@ -858,16 +863,12 @@ body:not(.find-open) [data-match-highlight-count="1"] .CodeMirror-selection-high line-height: 16px; font-weight: bold; } -#lint .report { - font-size: 85%; - cursor: pointer; -} -.lint-report-container > :not(.empty) ~ :not(.empty) { +#lint .report:not(.empty) ~ :not(.empty) { border-top: 1px dotted rgba(128, 128, 128, .5); margin-top: .25em; padding-top: .25em; } -#lint .report tr:hover { +#lint tr:hover { background-color: hsla(180, 50%, 36%, .2); } #lint td { diff --git a/edit/linter-manager.js b/edit/linter-manager.js index 6bd1792c..1a4fd269 100644 --- a/edit/linter-manager.js +++ b/edit/linter-manager.js @@ -328,16 +328,12 @@ linterMan.DEFAULTS = { } function createTable(cm) { - const caption = $create('td.caption'); - const tbody = $create('tbody.report'); - const table = $create('table', - $create('tr', [ - caption, - $create('td', tbody), - ])); + const caption = $create('.caption'); + const table = $create('table'); + const report = $create('.report', [caption, table]); const trs = []; return { - element: table, + element: report, trs, updateAnnotations, updateCaption, @@ -357,20 +353,20 @@ linterMan.DEFAULTS = { } else { tr = createTr(); trs.push(tr); - tbody.append(tr.element); + table.appendChild(tr.element); } tr.update(anno); i++; } if (i === 0) { trs.length = 0; - tbody.textContent = ''; + table.textContent = ''; } else { while (trs.length > i) { trs.pop().element.remove(); } } - table.classList.toggle('empty', trs.length === 0); + report.classList.toggle('empty', !trs.length); function *getAnnotations() { for (const line of lines.filter(Boolean)) {