Move javascript to separate file

As we add database support to the application, this will help keep
the code manageable.