From 50d2c6a8bdfc1b7c6c373a680f91a9ec3d88b5fe Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 31 Oct 2022 03:23:08 +0400 Subject: [PATCH] Reassign first and last row global var after sorting. --- web/assets/js/main.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/assets/js/main.js b/web/assets/js/main.js index 846ae5b..f12ca61 100644 --- a/web/assets/js/main.js +++ b/web/assets/js/main.js @@ -9,8 +9,8 @@ const overlay_content = overlay.children[1].firstChild; const overlay_label = overlay.children[1].lastChild; const g_tbody = document.getElementsByTagName('tbody')[0]; -const g_first_row = g_tbody.firstChild; -const g_last_row = g_tbody.lastChild; +let g_first_row = g_tbody.firstChild; +let g_last_row = g_tbody.lastChild; const g_back_row = document.getElementsByTagName("tr")[1]; let g_scale = 1; @@ -184,6 +184,8 @@ thead_name.addEventListener('click', e => { const b_name = b.children[0].textContent.toLowerCase(); return a_name < b_name ? -1 : a_name > b_name ? 1 : 0; }, null, null, thead_name, [thead_date, thead_size]); + g_first_row = g_tbody.firstChild; + g_last_row = g_tbody.lastChild; }); thead_date.classList.toggle("clickable"); @@ -194,6 +196,8 @@ thead_date.addEventListener('click', e => { const b_date = new Date(b.children[1].textContent.slice(0, -4)); return a_date - b_date; }, null, null, thead_date, [thead_name, thead_size]); + g_first_row = g_tbody.firstChild; + g_last_row = g_tbody.lastChild; }); @@ -217,6 +221,8 @@ thead_size.addEventListener('click', e => { e => e.children[2].textContent == "DIR", e => e.children[2].textContent != "DIR", thead_size, [thead_name, thead_date]); + g_first_row = g_tbody.firstChild; + g_last_row = g_tbody.lastChild; }); function sortTable(compareFn, filterFn, filterNegFn, target, other) {