Refactor search_box javascript to make it more object oriented