Whitespace fixes

The javascript file has a bunch of trailing whitespace and also a tab/space inconsistency. This fixes all that and makes the file a bit nicer to work on.