legacy upload.js: Clean up and remove from jshintignore

* Coding style:
  - Braces
  - Single quotes
  - Dot instead of bracket access for properties
* Fixed various implied global/static variables, most significantly
  the for-loop variable 'cached' etc.
* Changed == '' to ! since === '' will require it to be a string
  and == '' returns true for almost anything that is falsy, no
  good way to choose a strict alternative.
* Changed setAttribute('disabled', ..) to using .property instead.
* Using setTimeout as a global instead of as a window property.
* Using other globals from wikibits.js through window property,
  as they are defined.
* Use a closure instead of string eval() in setTimeout().
* Made local equivalents for some global variables for access
  inside the closure.
* Don't create functions in a loop. Moved the onchange function
  outside the loop and re-used it for each one (safe in this case,
  and more efficient).
* Call setTimeout/clearTimeout as global, no need for the window
  object as host.

Change-Id: I9df912ee48d30c189394bf07f5e49014220f36a3