jshint: js code validation and beautification

As discussed with Justin, this pull request includes the following changes: 

1. Ran JavaScript beautifier, as per jsbeautifier.org – this is not strictly anything to do with JSHint but makes it easier to spot invalid code. (We may want to tweak code layout further at some point – opinions vary...)

2. Added global 'use strict' to main.js and updated code to avoid errors.

3. Added JSHint options to main.js and updated code to validate.

@juberti and @marwahvikas PTAL.

Now saved with newline at end. (This is standard procedure with JavaScript to avoid problems if files get concatenated – not that that happens here.) I'd turned this off accidentally...

Is that what you meant?