refactor ui/base.js