cleaned up some js

using jshint and a little dependency injection...