Refactor app/assets/javascripts/lib/lines.js from a B on Code Climate, part of #54