Ia7: Reorganize and Condense Javascript

Attempt to move as much as possible into JavaScript