Massive JS refactoring.

Added QUnit, but no unit tests, yet. Refactored all the JS to have one
global variable and using modules for some OOP structure.