Refactor/coding style

Some changes:
 * Refactored `global.js` and some other js files.
 * Make codes more beautiful.

pls review. @szulabs @tonyseek @doyoubi