Update demo code to the latest online version.

Also fix the validation errors and clean up JS code.
Demo: tab to spaces.