Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
Put a timeout on keyup/press events
Browse files Browse the repository at this point in the history
Currently, it's making at least twice as many requests as
necessary.
  • Loading branch information
isaacs committed May 13, 2012
1 parent 488e750 commit a25af9a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions www/attachments/site.js
Expand Up @@ -265,7 +265,12 @@ app.index = function () {
lastSearchForPage = currentSearch;
}

var hcTimer = null;
var handleChange = function () {
if (hcTimer) clearTimeout(hcTimer);
hcTimer = setTimeout(handleChange_, 100);
}
function handleChange_ () {
currentSearch = $('input#search-input').val().toLowerCase();
currentTerms = $.trim(currentSearch).split(' ')
if (currentSearch === '') {
Expand Down

0 comments on commit a25af9a

Please sign in to comment.