Emscripten/Javascript port

The port is in a good enough state that I feel safe merging it. If either of you can look it over real quick for any serious issues that would be great. I don't expect you to examine the Javascript stuff much, but a look over the rest would be nice.