Move js code into its own file

This commit moves some JS code contained in the home view into its own
file.