From ca84da5b31fa00ca6c729a9b500efeb28f90b41b Mon Sep 17 00:00:00 2001
From: Nikola Georgiev <42315052+nikolageorgiev2000@users.noreply.github.com>
Date: Mon, 12 Sep 2022 00:05:14 +0000
Subject: [PATCH] feat: Hide full path to file in Wikilinks by default (#195)

---
 assets/js/semantic-search.js |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/assets/js/semantic-search.js b/assets/js/semantic-search.js
index 3cebe5a..4382817 100644
--- a/assets/js/semantic-search.js
+++ b/assets/js/semantic-search.js
@@ -15,7 +15,15 @@
   return (await response.json());
 }
 
-registerHandlers((e) => {
+function debounce(func, timeout = 200) {
+  let timer;
+  return (...args) => {
+    clearTimeout(timer)
+    timer = setTimeout(() => { func.apply(this, args); }, timeout)
+  };
+}
+
+registerHandlers(debounce((e) => {
   term = e.target.value
   if (term !== "") {
     searchContents(term)
@@ -27,4 +35,4 @@
       ))
       .then(results => displayResults(results))
   }
-})
+}))

--
Gitblit v1.10.0