Refactor js codes.