JS-Lint friendly version of Typo.js

note: this round of changes is just to improve readability.
variables are declared at the top of functions
functions contain their own "use strict"; statements
hasOwnProperty is used instead of other implementations
[fix] typo in line 487 changed textCode to textCodes