Fix whitespace

This involves two whitespace only changes:

- Trim all trailing whitespaces
- Add final newlines that are missing from some JS files

You can confirm that this is a whitespace-only change by doing `git diff -w master` and verifying that no changes are shown.