Added support for require.js, and migrated code base superficially to use it.

This code basically just ports main.js to use require.js.  You may find it's syntax and flexibility pleasant and useful.  Take this if you like it.