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.

!= null works for both null and undefined.

I can go either way on this one - I defer to you for which is more typical in JS to signify an error value.