AMD-ify our JS

/cc @potch

I actually removed a lot of code. it's pretty legit.