mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 19:06:59 -05:00
"Merge branch 'master' of https://github.com/codecombat/codecombat
This commit is contained in:
commit
ac222c27e8
2 changed files with 13 additions and 4 deletions
|
@ -74,6 +74,7 @@
|
||||||
<script>
|
<script>
|
||||||
// Additional JS functions here
|
// Additional JS functions here
|
||||||
window.fbAsyncInit = function() {
|
window.fbAsyncInit = function() {
|
||||||
|
Backbone.Mediator.publish('fbapi-loaded')
|
||||||
FB.init({
|
FB.init({
|
||||||
appId : document.location.origin === 'http://localhost:3000' ? '607435142676437' : '148832601965463', // App ID
|
appId : document.location.origin === 'http://localhost:3000' ? '607435142676437' : '148832601965463', // App ID
|
||||||
channelUrl : document.location.origin +'/channel.html', // Channel File
|
channelUrl : document.location.origin +'/channel.html', // Channel File
|
||||||
|
|
|
@ -24,6 +24,8 @@ module.exports = class LadderTabView extends CocoView
|
||||||
'click .connect-facebook': 'onConnectFacebook'
|
'click .connect-facebook': 'onConnectFacebook'
|
||||||
|
|
||||||
subscriptions:
|
subscriptions:
|
||||||
|
'fbapi-loaded': 'onFacebookAPILoaded'
|
||||||
|
'gapi-loaded': 'onGPlusAPILoaded'
|
||||||
'facebook-logged-in': 'onConnectedWithFacebook'
|
'facebook-logged-in': 'onConnectedWithFacebook'
|
||||||
|
|
||||||
constructor: (options, @level, @sessions) ->
|
constructor: (options, @level, @sessions) ->
|
||||||
|
@ -31,7 +33,6 @@ module.exports = class LadderTabView extends CocoView
|
||||||
@teams = teamDataFromLevel @level
|
@teams = teamDataFromLevel @level
|
||||||
@leaderboards = {}
|
@leaderboards = {}
|
||||||
@refreshLadder()
|
@refreshLadder()
|
||||||
@checkFriends()
|
|
||||||
|
|
||||||
checkFriends: ->
|
checkFriends: ->
|
||||||
@loadingFacebookFriends = true
|
@loadingFacebookFriends = true
|
||||||
|
@ -45,8 +46,14 @@ module.exports = class LadderTabView extends CocoView
|
||||||
else
|
else
|
||||||
@gplusSessionStateLoaded()
|
@gplusSessionStateLoaded()
|
||||||
|
|
||||||
|
apiLoaded: ->
|
||||||
|
return unless @fbAPILoaded and @gplusAPILoaded
|
||||||
|
@checkFriends()
|
||||||
# FACEBOOK
|
# FACEBOOK
|
||||||
|
|
||||||
|
onFacebookAPILoaded: ->
|
||||||
|
@fbAPILoaded = true
|
||||||
|
@apiLoaded()
|
||||||
# Connect button pressed
|
# Connect button pressed
|
||||||
|
|
||||||
onConnectFacebook: ->
|
onConnectFacebook: ->
|
||||||
|
@ -80,6 +87,10 @@ module.exports = class LadderTabView extends CocoView
|
||||||
|
|
||||||
# GOOGLE PLUS
|
# GOOGLE PLUS
|
||||||
|
|
||||||
|
onGPlusAPILoaded: ->
|
||||||
|
@gplusAPILoaded = true
|
||||||
|
@apiLoaded()
|
||||||
|
|
||||||
gplusSessionStateLoaded: ->
|
gplusSessionStateLoaded: ->
|
||||||
if application.gplusHandler.loggedIn
|
if application.gplusHandler.loggedIn
|
||||||
@loadingGPlusFriends = true
|
@loadingGPlusFriends = true
|
||||||
|
@ -141,16 +152,13 @@ class LeaderboardData
|
||||||
@topPlayers = new LeaderboardCollection(@level, {order:-1, scoreOffset: HIGHEST_SCORE, team: @team, limit: 20})
|
@topPlayers = new LeaderboardCollection(@level, {order:-1, scoreOffset: HIGHEST_SCORE, team: @team, limit: 20})
|
||||||
promises = []
|
promises = []
|
||||||
promises.push @topPlayers.fetch()
|
promises.push @topPlayers.fetch()
|
||||||
@topPlayers.once 'sync', @onceLeaderboardPartLoaded, @
|
|
||||||
|
|
||||||
if @session
|
if @session
|
||||||
score = @session.get('totalScore') or 10
|
score = @session.get('totalScore') or 10
|
||||||
@playersAbove = new LeaderboardCollection(@level, {order:1, scoreOffset: score, limit: 4, team: @team})
|
@playersAbove = new LeaderboardCollection(@level, {order:1, scoreOffset: score, limit: 4, team: @team})
|
||||||
promises.push @playersAbove.fetch()
|
promises.push @playersAbove.fetch()
|
||||||
@playersAbove.once 'sync', @onceLeaderboardPartLoaded, @
|
|
||||||
@playersBelow = new LeaderboardCollection(@level, {order:-1, scoreOffset: score, limit: 4, team: @team})
|
@playersBelow = new LeaderboardCollection(@level, {order:-1, scoreOffset: score, limit: 4, team: @team})
|
||||||
promises.push @playersBelow.fetch()
|
promises.push @playersBelow.fetch()
|
||||||
@playersBelow.once 'sync', @onceLeaderboardPartLoaded, @
|
|
||||||
level = "#{level.get('original')}.#{level.get('version').major}"
|
level = "#{level.get('original')}.#{level.get('version').major}"
|
||||||
success = (@myRank) =>
|
success = (@myRank) =>
|
||||||
promises.push $.ajax "/db/level/#{level}/leaderboard_rank?scoreOffset=#{@session.get('totalScore')}&team=#{@team}", {success}
|
promises.push $.ajax "/db/level/#{level}/leaderboard_rank?scoreOffset=#{@session.get('totalScore')}&team=#{@team}", {success}
|
||||||
|
|
Loading…
Reference in a new issue