please, remember:  CODE FORMATTING IS NOT OPTIONAL.

cleaned up js:
 - factor out functions
 - variable and function names
 - comments
 - **formatting**