Refactor python backend to use a buildjson function and distinct routes

This also involved making some changes to the js so that the different
submit buttons point to different routes.
Refactor drawgraph so that the submit function's input is a jQuery
selection containing the DOM element we want to append the plot to.

This obviates the need for input elements to have a particular class,
since we can just get the data for the AJAX call from the children of the
argument.
Add proper error handling.

In the process, I changed the callback function so that it takes as input
a selection to which the plot should be appended, similar to my earlier
refactor of the submit function. This involves finagling jQuery selections
into d3 selections, which is a bit of a hassle.
Add basic mathjax rendering ability to the page.
Add dynmic mathjax updating
Merge branch 'mathjax'