From dd11d56dd986c82914ce529fb43c8e2beb78a094 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Fri, 23 Sep 2022 17:17:34 +0000
Subject: [PATCH] Merge branch 'hugo' of https://github.com/jackyzha0/quartz into hugo
---
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