JS fix

fix bugs and add some functions.