Clean up js code:
Most of warning messages are: "is not defined" or "was used before it was defined" because we using global function.
With warning message: "Combine this with the previous 'var' statement", we can clean up it but will make code difficult to read and debug