From ca0bd0726a2ee0e44e9cf872493560e6ffef557f Mon Sep 17 00:00:00 2001 From: Masahiko AMANO Date: Mon, 30 Jan 2023 23:31:06 +0300 Subject: [PATCH] feat(web): add text filter to tags page --- web/public/js/tfm-tags.js | 17 +++++++++++++++++ web/public/tfm/tags.html | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/web/public/js/tfm-tags.js b/web/public/js/tfm-tags.js index c07347d..4b3665e 100644 --- a/web/public/js/tfm-tags.js +++ b/web/public/js/tfm-tags.js @@ -9,6 +9,23 @@ $(window).on("load", function () { }); }); +$(document).on("input", "#text-filter", function (e) { + let filter = $(this).val().toLowerCase(); + let unfiltered = $(".item"); + if (filter === "") { + unfiltered.css("display", "block"); + return; + } + unfiltered.each((index, element) => { + let current = $(element); + if (current.text().toLowerCase().includes(filter)) { + current.css("display", "block"); + } else { + current.css("display", "none"); + } + }); +}); + $(document).on("dblclick", ".item", function (e) { e.preventDefault(); let id = parseInt($(this).attr("id").slice(1)); diff --git a/web/public/tfm/tags.html b/web/public/tfm/tags.html index e7f911a..974e303 100644 --- a/web/public/tfm/tags.html +++ b/web/public/tfm/tags.html @@ -31,6 +31,14 @@

TFM: Tags

+
+
+ +
+ +
+
+