Refactored JavaScript.

I rewrote the entire JavaScript.