Partially completed Javascript for Figure 3.

I'll finish it later.