Reorganization of JS to make portable/re-usable across applications

Martin, 

I am not sure if I made this pull request correctly (we don't really use pull requests at PKP), but if not, just [pull from my repo](https://github.com/jalperin/almviz). It should pull cleanly and it seems to be working well. 

Right now, I have this code exactly as-is (except for the calling code) in an OJS plugin. 

It could still use a bit of work to make it look better, but all the right elements are in place. I also still need to work on the transitions, but I am going to release it for OJS as-is, unless someone (eLife is also working on this) tweaks in the coming days. 

Let me know if things are clear. I have tried to keep things as generic as possible and to separate things out into functions in a logical way, but you may disagree :)

Juan