In-line Analytics

PR for internal review purposes as prelude for PR to upstream
    PR'd against copy of upstream master.

Known issues to be fixed later:
- Styling is embedded in html file as prelude to re-styling
- No tests
- pep8 and pylint not looked at yet.

@jbau @jrbl @stvstnfrd @caesar2164 if you please.
I wonder what other javascript is running on this page, and whether you will have to wrap your javascript in an object declaration to avoid namespace problems. compare() seems particularly liable to run into something someone else is barfing onto the page.

With some thought, wrapping your js bits in an object declaration might make writing the tests for the js bits easier, so there is probably some extra virtue in that.