refine ui layouts: restructure the javascripts