<commit_before>fb = $.Deferred()

fb.ready = ()->
  if (arguments.length == 0)
    fb.resolve()
  else
    fb.done.apply(fb, arguments)


# fbAsyncInit is called when all.js is loaded
@fbAsyncInit = ()->
  throw new Error "Missing Facebook App Id" unless features.appId
  params =
     appId      : features.appId, #App ID
     status     : true, # check login status
     cookie     : true, # enable cookies to allow the server to access the session
     xfbml      : true, # parse XFBML
     channelURL : features.channelUrl # Channel File

  FB.init(params)
  fb.resolve()

features =
  appId: undefined
  channelUrl: '//' + window.location.host + '/channel.html'
  locale: 'en_US'
  ready: fb.ready

_.extend(@App, {fb: features})

# add the fb js script to the page
$ ()->
  $.getScript("//connect.facebook.net/#{features.locale}/all.js")<commit_msg>unfuck facebook V turbolinks for great justice!<commit_after>fb = $.Deferred()

fb.ready = ()->
  if (arguments.length == 0)
    fb.resolve()
  else
    fb.done.apply(fb, arguments)


# fbAsyncInit is called when all.js is loaded
@fbAsyncInit = ()->
  throw new Error "Missing Facebook App Id" unless features.appId
  params =
     appId      : features.appId, #App ID
     status     : true, # check login status
     cookie     : true, # enable cookies to allow the server to access the session
     xfbml      : true, # parse XFBML
     channelURL : features.channelUrl # Channel File

  FB.init(params)
  fb.resolve()

features =
  appId: undefined
  channelUrl: '//' + window.location.host + '/channel.html'
  locale: 'en_US'
  ready: fb.ready

_.extend(@App, {fb: features})

# handle turbolinks stuff!
fb_root = null
justiceServed = false

fixFacebookWithTurbolinksForGreatJustice = ->
  document.addEventListener 'page:fetch', copyFbRoot
  document.addEventListener 'page:change'. restoreFbRoot
  document.addEventListener 'page:load', ->
    FB?.XFBML.parse()
  justiceServed = true

copyFbRoot = ->
  $('#fb-root').detach()
  
restoreFbRoot = ->
  if $('#fb-root').length > 0
    $('#fb-root').replaceWith fb_root
  else
    $('body').append fb_root

# add the fb js script to the page
$ ()->
  $.getScript("//connect.facebook.net/#{features.locale}/all.js")
  fixFacebookWithTurbolinksForGreatJustice() unless justiceServed
{'fraction_non_alphanumeric': 0.12931411096548712, 'fraction_numerical': 0.001310615989515072, 'mean_word_length': 3.2803738317757007, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3515253', 'n_tokens_mistral': 757, 'n_tokens_neox': 732, 'n_words': 200}