Refactor progress bar javascript to use template