Document analytics (WIP)

The Javascript still needs some cleaning up, but here is a functional basic first phase of the analytics page.