Convert from camelCase to snake_case
Add comment to HTML describing content generated by javascript.
Extracted a number of functions.

This was an undisciplined refactor, mainly due to the author
getting his head in a knot vis-a-vis using closures to save
passing several parameters to functions vs. a runtime
proliferation of copies of functions.