code-dot-org/code-dot-org — pull request #453 by cpirich (2014-11-17 19:20:17+00:00)
Title: add editCode support to studio (playlab)

![screen shot 2014-11-17 at 10 58 36 am](https://cloud.githubusercontent.com/assets/5429146/5075639/4ae7e338-6e49-11e4-92c7-586e30b62251.png)

* Play Lab (studio) can now be used in a limited form with droplet / JavaScript (instead of blockly). While we may not publish any levels like this, it helps us validate the droplet / JavaScript model with a more complex app (see below)
* Accessing hammer.js moved to utils.js to work around conflicts with require.js (similar to lodash). I had to modify a bunch of test files to define window/document/navigator in order to make the tests run, since nearly everything includes utils.js and it now requires hammer.js.
* In studio, I cleaned up all of the dependencies on blockly-core as was done last week with turtle, maze, and webapp
* I tweaked the interpreter execution model to step rapidly until the current JavaScript node is marked "done" - this improves performance and should also be employed in turtle and webapp in a future change.
* Added a new game for StudioEC, associated strings, and added a new level (/editcode/8) to access the Studio sandbox level in droplet
* Created a new API for StudioEC called attachEventHandler() that is similar to the webapp function. Event names are predefined and include parameters (e.g. 'whenSpriteCollided-0-1' for event when sprite 0 collides with sprite 1). Real parameters should probably be passed, but this works for now.
* I did not expose any blocking APIs from playlab, as I don't believe it makes sense to carry that over into the more advanced JavaScript world. APIs like saySprite, moveDistance, wait, showTitleScreen, and others may need to be exposed as APIs that fire immediately with an optional completion event function block.

Notes:
1. The sync vs. async issues in Play Lab are complex and figuring out the right model to expose similar concepts for students at the high-school level using JavaScript will take some iteration.
2. Using droplet with string parameters instead of enumerated type dropdowns is not easy (event names, directions, fireball types, etc.) If we want to make this easy in block mode and generally avoid writing lots of API documentation, we may need to enhance droplet to support a mixed dropdown / free editor option.