JSHint tidying

This is a big, invasive change so we'll probably want to discuss before
merging.

Major changes:
* Trailing whitespace eradication
* Removal of most unused variables (see comments)
* Fix missing curly braces
* Add specific global declarations in the few places where browser
  globals (e.g. ActiveXObject) are assumed
* drawer.js has some apparently unreachable code which should be
  reviewed
* viewer.js uses arguments.callee – we should see if there's a better
  way to structure this