Move it to index.js/edit.js and eliminate the global doSearch function. Not enough code is shared to justify it.