Refactor JS widgets