add codeclimate badge, refactor js code