Added the main JS functionality.

Added the main JS functionality.