Javascript refactoring

Worked on pulling one of the super-functions out of the app.js file and into a separate js file, then refactoring it by pulling some extra features into their own functions and adding a bunch of comments to figure out the rest. Templates would clean that part up significantly.

You don't have to merge this pull request, it's just to give you an idea of how to clean up the JS code. Maybe some of the parsing could also be moved into the model or into helper functions before you retrieve the data via ajax call.