From c0422040dbb2a9f0025709f037f7f17362d862bc Mon Sep 17 00:00:00 2001 From: tim b Date: Thu, 10 Jun 2010 07:33:17 -0700 Subject: don't spam search requests --- template/search_files.st | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'template/search_files.st') diff --git a/template/search_files.st b/template/search_files.st index 304c01d..88a3dab 100644 --- a/template/search_files.st +++ b/template/search_files.st @@ -2,6 +2,9 @@ dump.fm image search $head()$ + @@ -61,7 +64,7 @@ } } - function keyHandler(){ + function doSearch(){ term = jQuery("#search-query").val().trim() if (term.length < 3) { setMessage("search query too small") @@ -70,6 +73,12 @@ addScript(term) } } + + // only search every 500ms while someone is typing + function keyHandler(){ + if (keyHandler.timeout) clearTimeout(keyHandler.timeout); + keyHandler.timeout = setTimeout(doSearch, 250) + } jQuery("#search-query").keyup(keyHandler) -- cgit v1.2.3-70-g09d2