Refactor javascript out of template file.