From f46c20a4f65a52749587aaa2b6a0d8d28104b31e Mon Sep 17 00:00:00 2001 From: Anish Reddy Ravula <2anishreddy@gmail.com> Date: Mon, 13 Nov 2023 12:54:18 -0600 Subject: [PATCH] Add the badge filter to search the DOM instead of making another request Making another request is very slow as it involves reloading the whole webpage to get the query filter from the URL --- sharing_portal/static/sharing_portal/index.js | 7 +++++++ sharing_portal/templates/sharing_portal/index.html | 9 +++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sharing_portal/static/sharing_portal/index.js b/sharing_portal/static/sharing_portal/index.js index b6d97e17..0d9c592c 100644 --- a/sharing_portal/static/sharing_portal/index.js +++ b/sharing_portal/static/sharing_portal/index.js @@ -36,3 +36,10 @@ } } })(); + +function filter_artifacts(badge_filter) { + const filterInput = document.getElementById('cardFilter'); + filterInput.value = ""; // reset the value in field + filterInput.value = badge_filter; + filterInput.dispatchEvent(new KeyboardEvent('keyup')); // trigger a keyup to apply filter +} diff --git a/sharing_portal/templates/sharing_portal/index.html b/sharing_portal/templates/sharing_portal/index.html index a4b80058..f131432f 100644 --- a/sharing_portal/templates/sharing_portal/index.html +++ b/sharing_portal/templates/sharing_portal/index.html @@ -118,11 +118,12 @@