search: factor out javascript from macro

Less inline scripts.

**nb** it doesn't fix: #1968
Should this file be excluded or alternatively moved to invenio root instead of the search directory? or is it required to live next the source files? (just thinking that we likely need it for all JS, and not only the JS in search module?