Refactor the broker widget js