Unfortunately, this changed a lot, in addition to being moved out of the html file.  Fortunately, there aren't too many commits.  Also, the refactoring of code makes this much more simple.