Refine js code, fixed jshint error