Refactor for easier automation support

Key changes (mostly bookkeeping-related):
* Moved all (non-editor, non-graphics, non-mobile) event listeners and the timer into addlisteners.
* Introduced stubs for functions needed by engine.js, so that they can be used as fallbacks if graphics.js or other files are not present (e.g. in a web worker).
* Changed the forceRegenImages boolean to a function which should be called when images should be regenerated. The behavior is the same, but the usage is slightly different.
* Moved lastDownTarget and canvas into globalvariables.js.
* Altered parser.js so that it only talks to CodeMirror if CodeMirror is loaded.
* Removed hard-coded event listeners from standalone.html, switched it to use addlisteners instead.
* Killed the wrapper.js used by tests.html. The new fallbacks provided by engine.js suffice, and this way it's easier to use PuzzleScript in a standalone way.