<commit_before>#= require jquery
#= require jquery.prevent_scroll_propagation

showFrame = document.getElementById("frame")
xdm = window.easyXDM.noConflict("FACTLINK")
window.remote = new xdm.Rpc {},
  remote:
    hide: {}
    show: {}
    highlightNewFactlink: {}
    stopHighlightingFactlink: {}
    createdNewFactlink: {}
    trigger: {}

  local:
    showFactlink: (id, successFn) ->
      url = "/facts/" + id
      showUrl url, successFn
      return # don't return anything unless you have a callback on the other site of easyXdm

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

      onFactlinkCreated = (e, id) ->
        remote.highlightNewFactlink text, id

      $(document).bind "factlinkCreated", onFactlinkCreated
      return # don't return anything unless you have a callback on the other site of easyXdm

    position: (top, left) ->
      try
        showFrame.contentWindow.position top, left
      catch e # Window not yet loaded
        showFrame.onload = ->
          showFrame.contentWindow.position top, left
      return # don't return anything unless you have a callback on the other site of easyXdm

showUrl = (url, successFn) ->
  successCalled = 0
  onLoadSuccess = ->
    unless successCalled
      successCalled++
      successFn()  if $.isFunction(successFn)

  # Somehow only lower case letters seem to work for those events --mark
  $(document).bind "modalready", onLoadSuccess<commit_msg>Revert "removed early loaded event; instead wait for event from backbone"<commit_after>#= require jquery
#= require jquery.prevent_scroll_propagation

showFrame = document.getElementById("frame")
xdm = window.easyXDM.noConflict("FACTLINK")
window.remote = new xdm.Rpc {},
  remote:
    hide: {}
    show: {}
    highlightNewFactlink: {}
    stopHighlightingFactlink: {}
    createdNewFactlink: {}
    trigger: {}

  local:
    showFactlink: (id, successFn) ->
      url = "/facts/" + id
      showUrl url, successFn
      return # don't return anything unless you have a callback on the other site of easyXdm

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

      onFactlinkCreated = (e, id) ->
        remote.highlightNewFactlink text, id

      $(document).bind "factlinkCreated", onFactlinkCreated
      return # don't return anything unless you have a callback on the other site of easyXdm

    position: (top, left) ->
      try
        showFrame.contentWindow.position top, left
      catch e # Window not yet loaded
        showFrame.onload = ->
          showFrame.contentWindow.position top, left
      return # don't return anything unless you have a callback on the other site of easyXdm

showUrl = (url, successFn) ->
  successCalled = 0
  onLoadSuccess = ->
    unless successCalled
      successCalled++
      successFn()  if $.isFunction(successFn)

  showFrame.onload = onLoadSuccess
  # Somehow only lower case letters seem to work for those events --mark
  $(document).bind "modalready", onLoadSuccess
{'fraction_non_alphanumeric': 0.09912945801741084, 'fraction_numerical': 0.0005616399887672002, 'mean_word_length': 2.95338512763596, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2132805', 'n_tokens_mistral': 1024, 'n_tokens_neox': 1001, 'n_words': 305}