Refactor CoffeeScript for page-index