Facebook friends patch

This commit is contained in:
Fergus Leen 2014-06-20 02:18:40 +01:00
parent ecf24c2875
commit 88aa8d234c
2 changed files with 11 additions and 9 deletions

View file

@ -1,7 +1,6 @@
module.exports = initializeFacebook = -> module.exports = initializeFacebook = ->
# Additional JS functions here # Additional JS functions here
window.fbAsyncInit = -> window.fbAsyncInit = ->
Backbone.Mediator.publish "fbapi-loaded"
FB.init FB.init
appId: (if document.location.origin is "http://localhost:3000" then "607435142676437" else "148832601965463") # App ID appId: (if document.location.origin is "http://localhost:3000" then "607435142676437" else "148832601965463") # App ID
channelUrl: document.location.origin + "/channel.html" # Channel File channelUrl: document.location.origin + "/channel.html" # Channel File
@ -9,13 +8,14 @@ module.exports = initializeFacebook = ->
cookie: true # enable cookies to allow the server to access the session cookie: true # enable cookies to allow the server to access the session
xfbml: true # parse XFBML xfbml: true # parse XFBML
Backbone.Mediator.publish "fbapi-loaded"
# This is fired for any auth related change, such as login, logout or session refresh. # This is fired for any auth related change, such as login, logout or session refresh.
FB.Event.subscribe "auth.authResponseChange", (response) -> FB.Event.subscribe "auth.authResponseChange", (response) ->
# Here we specify what we do with the response anytime this event occurs. # Here we specify what we do with the response anytime this event occurs.
if response.status is "connected" if response.status is "connected"
# They have logged in to the app. # They have logged in to the app.
Backbone.Mediator.publish "facebook-logged-in", Backbone.Mediator.publish "facebook-logged-in",
response: response response: response
@ -23,7 +23,7 @@ module.exports = initializeFacebook = ->
else if response.status is "not_authorized" else if response.status is "not_authorized"
# #
else else
# #
# Load the SDK asynchronously # Load the SDK asynchronously
((d) -> ((d) ->
@ -35,8 +35,8 @@ module.exports = initializeFacebook = ->
js.id = id js.id = id
js.async = true js.async = true
js.src = "//connect.facebook.net/en_US/all.js" js.src = "//connect.facebook.net/en_US/all.js"
#js.src = "//connect.facebook.net/en_US/all/debug.js"; #js.src = "//connect.facebook.net/en_US/all/debug.js"
ref.parentNode.insertBefore js, ref ref.parentNode.insertBefore js, ref
return return
) document ) document

View file

@ -32,7 +32,6 @@ module.exports = class LadderTabView extends CocoView
@leaderboards = {} @leaderboards = {}
@refreshLadder() @refreshLadder()
@socialNetworkRes = @supermodel.addSomethingResource("social_network_apis", 0) @socialNetworkRes = @supermodel.addSomethingResource("social_network_apis", 0)
@checkFriends()
checkFriends: -> checkFriends: ->
return if @checked or (not window.FB) or (not window.gapi) return if @checked or (not window.FB) or (not window.gapi)
@ -97,6 +96,9 @@ module.exports = class LadderTabView extends CocoView
friend.otherTeam = if friend.team is 'humans' then 'ogres' else 'humans' friend.otherTeam = if friend.team is 'humans' then 'ogres' else 'humans'
friend.imageSource = "http://graph.facebook.com/#{friend.facebookID}/picture" friend.imageSource = "http://graph.facebook.com/#{friend.facebookID}/picture"
@facebookFriendSessions = result @facebookFriendSessions = result
@getRenderData()
@render()
# GOOGLE PLUS # GOOGLE PLUS