From 4c2f0cdfdfe2396b01730d3b56911cb80377f36c Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Tue, 2 Apr 2024 19:57:55 +0800 Subject: [PATCH] fixed autohide and added initial search --- gui/pages/settings/filters.htm | 44 ++++++++++++++++++++-------------- gui/scripts/windowman.JS | 35 ++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/gui/pages/settings/filters.htm b/gui/pages/settings/filters.htm index cf5bb80..4921122 100644 --- a/gui/pages/settings/filters.htm +++ b/gui/pages/settings/filters.htm @@ -9,38 +9,46 @@
- -
- - + + diff --git a/gui/scripts/windowman.JS b/gui/scripts/windowman.JS index 9afefe3..66f936c 100644 --- a/gui/scripts/windowman.JS +++ b/gui/scripts/windowman.JS @@ -343,7 +343,39 @@ export default class windowman { } /* Enable the searching interface. */ - function search() {} + function search() { + document.querySelectorAll(`[data-result]`).forEach((element) => { + // Begin searching when the textbox is changed. + element.addEventListener(`change`, async function () { + let search = {}; + search[`criteria`] = element.value; + if (search[`criteria`]) { + if ( + element.getAttribute(`data-results-filters`) + ? element.getAttribute(`data-results-filters`).trim() + : false + ) { + search[`additional criteria`] = element + .getAttribute(`data-results-filters`) + .split(`,`); + } + search[`source`] = element.getAttribute(`data-result`); + search[`raw`] = await (async () => { + const secretariat = await import( + chrome.runtime.getURL(`scripts/secretariat.js`) + ); + + await secretariat.search( + search[`source`], + search[`criteria`], + null, + search[`additional criteria`], + ); + })(); + } + }); + }); + } // Responsiveness to different screen sizes. function resize() { @@ -398,6 +430,7 @@ export default class windowman { window.addEventListener("resize", resize); resize(); + search(); links(); }