Skip to content

Commit

Permalink
Only delay running a filter when the user is still typing.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jul 4, 2010
1 parent 4452402 commit c6c5b38
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions index.html
Expand Up @@ -120,12 +120,12 @@
return retval;
} // process_steam_profile

var change_filter_timer = null;
var run_filter_timer = null;
function run_filter()
{
// stop any pending filter runs.
clearTimeout(change_filter_timer);
change_filter_timer = null;
clearTimeout(run_filter_timer);
run_filter_timer = null;

var filter = '';
var widget = $('input.tagfilter');
Expand Down Expand Up @@ -195,14 +195,14 @@
} // if
} // focus_filter_textbox

function change_filter_textbox()
function typing_in_filter()
{
// we only update the filter when it's been more than X ms, in case the
// list is massive.
if (change_filter_timer != null)
clearTimeout(change_filter_timer);
change_filter_timer = setTimeout('run_filter();', 500);
} // change_filter_textbox
if (run_filter_timer != null)
clearTimeout(run_filter_timer);
run_filter_timer = setTimeout('run_filter();', 1000);
} // typing_in_filter

function process_tag_edit(element)
{
Expand Down Expand Up @@ -332,8 +332,8 @@
<div class='searchbox'>
<input class='tagfilter' name='filter' type='text'
onFocus='focus_filter_textbox();'
onChange='change_filter_textbox();'
onKeyDown='change_filter_textbox();'
onChange='run_filter();'
onKeyDown='typing_in_filter();'
value='Enter filter tags' size='22' autocomplete='off'/>
</div>
</div>
Expand Down

0 comments on commit c6c5b38

Please sign in to comment.