   ###
   # Use the current challenge metadata to fill in the web page
   ###
+  console.log('updating challenge')
   request = $.ajax {url: "/api/c/challenges/#{challenge}"}
   request.done (data) ->
     currentChallenge = data.challenge

  #
  #
  if challenge?
    updateChallenge(challenge)
    updateStats(challenge)
    getTask(near)
  else
    if not difficulty
      difficulty = 1
    if not near
      near = "#{map.getCenter().lng}|#{map.getCenter().lat}"
    getNewChallenge(difficulty, near)


  ###
  # Gets a specific challenge
  ###
  console.log(getting challenge)
  request = $.ajax {url: "/api/c/challenges/#{id}"}
  request.done (data) ->
    slug = data.slug
    console.log(data)
    console.log(data.slug)
    updateChallenge(slug)
    updateStats(slug)
    getTask()
  request.fail (ajaxErrorHandler)

