Cleaning up the JavaScript parts

* Fix: using strict mode
* Fix: encapsulating DocPatch related code
* Fix: following the recommendations of JSLint