Refactored JavaScript for API Live view.

Split the chunk of javascript into a number of separate functions and closures, greatly improving readability. Increased the upgrade frequency from 5 to 10 times per second. Performance is still abysmal but that's a thing of later concern. This relates to issue #6.