       type = job.state
     return type
 
+  # Fills a defined progress bar up to the given percent
+  fillProgressBar = (repository, metric, type, percent) ->
+    progressClass = '.admin.control.progress'
+    repositoryId = repository.split('.').join('-')
+    barDiv = $("#{progressClass} .#{repositoryId}.#{metric}.#{type}.bar")
+    barDiv.css('width', "#{percent}%")
+
+  # Determines whether the request for the job progress should
+  # be repeated
   repeatRequest = (response) ->
     for repository, metrics of response
       for metric, job of metrics

        requestStatus()
      )

  requestStatus = () ->
    $.getJSON('/metrics/status', processStatus)

  processStatus = (response) ->
    for repository, metrics of response
      for metric, job of metrics
        type = determineBarType(job)
        if type?
          progressClass = '.admin.control.progress'
          repositoryId = repository.split('.').join('-')
          barDiv = $("#{progressClass} .#{repositoryId}.#{metric}.#{type}.bar")
          barDiv.css('width', "#{job.percent}%")
          if type == 'compute'
            barDiv = $("#{progressClass} .#{repositoryId}.#{metric}.analyze.bar")
            barDiv.css('width', "100%")


    if repeatRequest(response)
      setTimeout(requestStatus, 500)

  determineBarType = (job) ->
    type = null
    types = ['analyze', 'compute']

          return true
    return false

  if gon? and gon.repository? and gon.metrics?
    # activate repository selector
    $('.dropdown-toggle').dropdown()
    initializeButtons()
