Refactored javascript that is used more than once out of template pages into widget.js (eg. there is no reason to have the same javascript functions rendered multiple times).

Re-added some workflows.py methods that were mistakenly removed in the code cleanup.