+ fixes for js

+ fixed typo from variable
+ fixed code-style
+ optimized some if-statements
+ removed some unused/unneeded variables
+ removed / re-sort some comments