Refactoring procedural JavaScript to MVC -- starting with document.ready for controller