From d999559fa5e34005369f51c6066364ae663bb8ec Mon Sep 17 00:00:00 2001 From: Oliver Gerlich Date: Mon, 16 Jul 2018 22:59:13 +0200 Subject: [PATCH] list perf: limit list to 10 nodes This improves performance. A long list is not really useful anyway; rather let the user filter/sort it to display interesting nodes only. --- webroot/js/view/list.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/webroot/js/view/list.js b/webroot/js/view/list.js index a606b3b..95c2fe4 100644 --- a/webroot/js/view/list.js +++ b/webroot/js/view/list.js @@ -116,6 +116,8 @@ export class ListView extends View { cell11.innerHTML = 'Option'; table.classList.add('nodes'); + + this.footerNote = domlib.newAt(this.el, 'span'); } // eslint-disable-next-line id-length @@ -434,11 +436,20 @@ export class ListView extends View { nodes = nodes.reverse(); } + const numDisplayedNodes = Math.min(10, nodes.length); + var fragment = document.createDocumentFragment(); - for (let i = 0; i < nodes.length; i += 1) { + for (let i = 0; i < numDisplayedNodes; i += 1) { const row = this.renderRow(nodes[i]); fragment.appendChild(row); } this.tbody.appendChild(fragment); + + if (numDisplayedNodes < nodes.length) { + this.footerNote.textContent = "" + (nodes.length - numDisplayedNodes) + " further nodes hidden."; + } + else { + this.footerNote.textContent = ""; + } } }