Text search engine in Javascript