bring the sanity: convert to handlebars.js

This converts all the inline building of javascript structures into
using handlebars.js templates. It dramatically improves the
readability of the html snippets, and should make it much easier for
people to propose changes to content structure without being js
experts.

Additionally change the rendering order to render the plots
asynchronously so that we end up painting the main screen far faster,
which appears as a speed up to users.

This does mean we have a copy/paste of the template in both index and
gate files, eventually we can probably refactor that to an external
template file.

Change-Id: Ia54ce3b85d760f2948b04e88468c0627ade6884b