Simplifying things to search.js

As I said on the commit, the purpose of this PR is to get things simpler on search.js.

If you think that the first commit is unnecessary and it's not fair to merge with its existance, just let me know that I make a third PR, with a clean/new fork.
@stof The previous code is more intuitive, but not simple. So yes, an "array lookup" is simpler. And one more thing: the previous condition was going against the very-hyped DRY princple – isn't it?