js rewrite to oop

Rewrite the javascript file, now you have an object oriented javascript file.