refactor some js
toggle a throbber