search: factor out javascript from macro

Signed-off-by: Yoan Blanc <yoan.blanc@cern.ch>