   if last_created_text == text
     remote.highlightNewFactlink(text, id)
 
-showUrl = (url, successFn) ->
-  window.onModalReady = ->
-    window.onModalReady = -> # nothing
-    successFn()
-
+showUrl = (url) ->
   backbone = showFrame.contentWindow.Backbone
   history = backbone?.history
   if history && backbone.History.started


    history.navigate url, trigger: true
  else
    showFrame.onload = -> window.onModalReady()
    showFrame.src = url

showFrame.src = '/client/blank'

last_created_text = null

window.remote = Factlink.createFrameProxyObject window.parent,
  ['hide', 'onModalReady', 'highlightNewFactlink', 'stopHighlightingFactlink',
    'createdNewFactlink', 'trigger', 'setFeatureToggles'
  ]

local =
    showFactlink: (id) ->
      url = "/client/facts/#{id}"
      showUrl url

    prepareNewFactlink: (text, siteUrl, siteTitle, guided) ->
      url = "/facts/new" +
              "?fact=" + encodeURIComponent(text) +
              "&url=" + encodeURIComponent(siteUrl) +
              "&title=" + encodeURIComponent(siteTitle) +
              "&guided=" + encodeURIComponent(guided)
      showUrl url
      last_created_text = text

Factlink.listenToWindowMessages null, local
