From f8560eddd909aa58f56f0989aa76ec6f5a3689c3 Mon Sep 17 00:00:00 2001 From: crunk Date: Tue, 8 Mar 2022 23:48:44 +0100 Subject: [PATCH] simple tag search with js/css --- verse/static/css/style.css | 6 +++--- verse/static/js/dropdown.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/verse/static/css/style.css b/verse/static/css/style.css index 87f37bc..f58af9a 100644 --- a/verse/static/css/style.css +++ b/verse/static/css/style.css @@ -180,9 +180,9 @@ div.maincontent{ margin: 1px; } -.tags .searched { - background: #fff600; - color: black; +.searched { + background: #fff600 !important; + color: black !important; } .tooltip .tooltiptext { diff --git a/verse/static/js/dropdown.js b/verse/static/js/dropdown.js index 8db74cb..84cbf5c 100644 --- a/verse/static/js/dropdown.js +++ b/verse/static/js/dropdown.js @@ -64,5 +64,20 @@ searchInput.addEventListener('keyup', function (e) { // Make a new timeout set to go off in 1000ms (1 second) timeout = setTimeout(function () { console.log('Input Value:', searchInput.value); + searchTags(searchInput.value); }, 1000); }); + +function searchTags(searchInput) { + var tag_ele = document.getElementsByClassName('tags'); + for (var i = 0; i < tag_ele.length; ++i) { + let searchText = searchInput.toLowerCase(); + let tagtext = tag_ele[i].innerText.toLowerCase(); + if(searchText.includes(tagtext) || tagtext.includes(searchText)) { + addClass(tag_ele[i], "searched"); + } + else { + removeClass(tag_ele[i], "searched"); + } + } +}