Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Neato! Worked snappy for me. Kudos.

Suggestion: It appears that the searches sometimes stacked up in queue if I typed fast. (i.e. if I typed a long sentence quick the results continued to flash different content many times, playing catch-up. Looked through the JS quick and I see you are trying to prevent this with runningRequest1/2 so maybe it's the short delay in the .fadeTo() after the GET callback. Try moving the runningRequest = false into the fadeTo callback.

Also, .fadeTo() has a default queue of it's own. You could also add .stop() like this:

    $('#function').html(data).stop().fadeTo('fast',1);
Otherwise, really cool! I use "site:php.net foobar" most of the time but this would be a great little widget.


Thanks! This is my first real play with jQuery. I have added this to my bug queue and will be fixing it in a few hours. Cheers for the tip!


Here's another: you're searching on any keyup which creates lots of overhead. Google's implementation is more complex. It appears they search immediately as you type the first few characters on each keyup/down then if the word goes over a few characters it switches to querying every couple seconds, or until you hit the spacebar. It also seems like they have another timer if you pause after a second or two.

If it's just you using this, I would say don't give a crap. But if you plan to allow others to use it and it gains a userbase at all you might consider a similar approach for obvious reasons.

Cheers!


I was looking into this but havent yet been able to make it work smoothly. Since you have raised it I will focus on getting it working.

I have quite a list of things to improve now.


You may want to put in something that only searches if they havn't pressed a key after so many seconds.

I would assume that most of us type at a fairly constant rate so maybe check each keystroke to see how long its been since the last one and maybe if 500 ms have passed, then go ahead and fire off some search results.


Try using http://code.google.com/p/jquery-debounce/ - it creates a throttle/debounce function for you, so the submit would only be called at most every X ms, no matter how often the event fires. It's super useful.


+1




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: