From 67d06cd887abce532db8676f4d4d94af1dd907f4 Mon Sep 17 00:00:00 2001 From: glax Date: Wed, 31 May 2023 22:16:14 +0200 Subject: [PATCH] resolves #23 website filter --- Website/interaction.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Website/interaction.js b/Website/interaction.js index 57859f5..9e3648d 100644 --- a/Website/interaction.js +++ b/Website/interaction.js @@ -2,6 +2,7 @@ let tasks = []; let toEditId; +const searchBox = document.querySelector("#searchbox"); const searchPublicationQuery = document.querySelector("#searchPublicationQuery"); const selectPublication = document.querySelector("#taskSelectOutput"); const connectorSelect = document.querySelector("#connectors"); @@ -34,6 +35,7 @@ const tagTasksTotal = document.querySelector("#totalTasksTag"); const tagTaskPopup = document.querySelector("footer-tag-popup"); const tagTasksPopupContent = document.querySelector("footer-tag-content"); +searchbox.addEventListener("keyup", (event) => FilterResults()); settingsCog.addEventListener("click", () => OpenSettings()); document.querySelector("#blurBackgroundSettingsPopup").addEventListener("click", () => HideSettings()); closetaskpopup.addEventListener("click", () => HideAddTaskPopup()); @@ -331,6 +333,30 @@ function CloseTasksPopup(){ tagTaskPopup.style.display = "none"; } +function FilterResults(){ + if(searchBox.value.length > 0){ + tasksContent.childNodes.forEach(publication => { + publication.childNodes.forEach(item => { + if(item.nodeName.toLowerCase() == "publication-information"){ + item.childNodes.forEach(information => { + if(information.nodeName.toLowerCase() == "publication-name"){ + if(!information.textContent.toLowerCase().includes(searchBox.value.toLowerCase())){ + publication.style.display = "none"; + }else{ + publication.style.display = "initial"; + } + } + }); + } + }); + }); + }else{ + tasksContent.childNodes.forEach(publication => publication.style.display = "initial"); + } + + +} + //Resets the tasks shown ResetContent(); //Get Tasks and show them