Improved JavaScript code.

Made the class part of the global namespace.