Revert "Revert "fixed some js bugs""

This reverts commit 7711b238fcdc1baff8cba4e2a6d51a87444f12cb.