1
0
Fork 0

Added table row filtering based on value of filter input text field.

This commit is contained in:
Alexander Andreev 2022-10-18 22:21:31 +04:00
parent 4ef2a77c25
commit ed17b83aae
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F
1 changed files with 13 additions and 0 deletions

View File

@ -117,6 +117,19 @@ for (let i = 0; i < file_links.length; ++i)
e.preventDefault();
});
//// FILTERING
function filter(sub) {
const table = document.getElementsByTagName("tbody")[0].children
for (let j = 0; j < table.length; ++j)
if (sub === "" || table[j].children[0].children[0].innerText.toLowerCase().indexOf(sub) != -1)
table[j].classList.remove("hidden");
else
table[j].classList.add("hidden");
}
document.getElementsByName("filter")[0].addEventListener("input", e => filter(e.target.value.toLowerCase()));
//// SORT BY COLUMN
const [thead_name, thead_date, thead_size] = document.getElementsByTagName('thead')[0]