Refactor code out of html file into its own JavaScript file.