mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -05:00
commit
20a5ae1b8c
9 changed files with 51 additions and 48 deletions
|
@ -710,3 +710,4 @@
|
|||
user_names: "User Names"
|
||||
files: "Files"
|
||||
top_simulators: "Top Simulators"
|
||||
source_document: "Source Document"
|
|
@ -10,6 +10,8 @@
|
|||
display: none
|
||||
#docs-button
|
||||
display: none
|
||||
#gold-view
|
||||
right: 1%
|
||||
|
||||
#control-bar-view
|
||||
width: 100%
|
||||
|
@ -41,7 +43,7 @@
|
|||
margin: 0 auto
|
||||
|
||||
canvas#surface
|
||||
background-color: #ddd
|
||||
background-color: #333
|
||||
max-height: 93%
|
||||
max-height: -webkit-calc(100% - 60px)
|
||||
max-height: calc(100% - 60px)
|
||||
|
|
|
@ -17,14 +17,11 @@ module.exports = class PatchModal extends ModalView
|
|||
constructor: (@patch, @targetModel, options) ->
|
||||
super(options)
|
||||
targetID = @patch.get('target').id
|
||||
if false
|
||||
@originalSource = targetModel.clone(false)
|
||||
@onOriginalLoaded()
|
||||
if targetID is @targetModel.id
|
||||
@originalSource = @targetModel.clone(false)
|
||||
else
|
||||
@originalSource = new targetModel.constructor({_id:targetID})
|
||||
@originalSource.fetch()
|
||||
@listenToOnce @originalSource, 'sync', @onOriginalLoaded
|
||||
@addResourceToLoad(@originalSource)
|
||||
@originalSource = new @targetModel.constructor({_id:targetID})
|
||||
@supermodel.loadModel @originalSource, 'source_document'
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
|
@ -35,7 +32,7 @@ module.exports = class PatchModal extends ModalView
|
|||
c
|
||||
|
||||
afterRender: ->
|
||||
return if @originalSource.loading
|
||||
return unless @supermodel.finished()
|
||||
headModel = null
|
||||
if @targetModel.hasWriteAccess()
|
||||
headModel = @originalSource.clone(false)
|
||||
|
|
|
@ -45,7 +45,7 @@ module.exports = class LadderTabView extends CocoView
|
|||
checkFriends: ->
|
||||
return if @checked or (not window.FB) or (not window.gapi)
|
||||
@checked = true
|
||||
|
||||
|
||||
# @addSomethingToLoad("facebook_status")
|
||||
|
||||
@fbStatusRes = @supermodel.addSomethingResource("facebook_status", 0)
|
||||
|
@ -78,7 +78,7 @@ module.exports = class LadderTabView extends CocoView
|
|||
@fbFriendRes.load()
|
||||
|
||||
FB.api '/me/friends', @onFacebookFriendsLoaded
|
||||
|
||||
|
||||
onFacebookFriendsLoaded: (response) =>
|
||||
@facebookData = response.data
|
||||
@loadFacebookFriendSessions()
|
||||
|
@ -104,7 +104,7 @@ module.exports = class LadderTabView extends CocoView
|
|||
friend.otherTeam = if friend.team is 'humans' then 'ogres' else 'humans'
|
||||
friend.imageSource = "http://graph.facebook.com/#{friend.facebookID}/picture"
|
||||
@facebookFriendSessions = result
|
||||
|
||||
|
||||
# GOOGLE PLUS
|
||||
|
||||
onConnectGPlus: ->
|
||||
|
@ -113,7 +113,7 @@ module.exports = class LadderTabView extends CocoView
|
|||
application.gplusHandler.reauthorize()
|
||||
|
||||
onConnectedWithGPlus: -> location.reload() if @connecting
|
||||
|
||||
|
||||
gplusSessionStateLoaded: ->
|
||||
if application.gplusHandler.loggedIn
|
||||
#@addSomethingToLoad("gplus_friends")
|
||||
|
@ -146,7 +146,7 @@ module.exports = class LadderTabView extends CocoView
|
|||
friend.otherTeam = if friend.team is 'humans' then 'ogres' else 'humans'
|
||||
friend.imageSource = friendsMap[friend.gplusID].image.url
|
||||
@gplusFriendSessions = result
|
||||
|
||||
|
||||
# LADDER LOADING
|
||||
|
||||
refreshLadder: ->
|
||||
|
@ -160,7 +160,7 @@ module.exports = class LadderTabView extends CocoView
|
|||
|
||||
render: ->
|
||||
super()
|
||||
|
||||
|
||||
@$el.find('.histogram-display').each (i, el) =>
|
||||
histogramWrapper = $(el)
|
||||
team = _.find @teams, name: histogramWrapper.data('team-name')
|
||||
|
@ -168,8 +168,8 @@ module.exports = class LadderTabView extends CocoView
|
|||
$.when(
|
||||
$.get("/db/level/#{@level.get('slug')}/histogram_data?team=#{team.name.toLowerCase()}", (data) -> histogramData = data)
|
||||
).then =>
|
||||
@generateHistogram(histogramWrapper, histogramData, team.name.toLowerCase())
|
||||
|
||||
@generateHistogram(histogramWrapper, histogramData, team.name.toLowerCase()) unless @destroyed
|
||||
|
||||
getRenderData: ->
|
||||
ctx = super()
|
||||
ctx.level = @level
|
||||
|
@ -186,7 +186,7 @@ module.exports = class LadderTabView extends CocoView
|
|||
#renders twice, hack fix
|
||||
if $("#"+histogramElement.attr("id")).has("svg").length then return
|
||||
histogramData = histogramData.map (d) -> d*100
|
||||
|
||||
|
||||
margin =
|
||||
top: 20
|
||||
right: 20
|
||||
|
@ -195,17 +195,17 @@ module.exports = class LadderTabView extends CocoView
|
|||
|
||||
width = 300 - margin.left - margin.right
|
||||
height = 125 - margin.top - margin.bottom
|
||||
|
||||
|
||||
formatCount = d3.format(",.0")
|
||||
|
||||
|
||||
x = d3.scale.linear().domain([-3000,6000]).range([0,width])
|
||||
|
||||
data = d3.layout.histogram().bins(x.ticks(20))(histogramData)
|
||||
y = d3.scale.linear().domain([0,d3.max(data, (d) -> d.y)]).range([height,0])
|
||||
|
||||
|
||||
#create the x axis
|
||||
xAxis = d3.svg.axis().scale(x).orient("bottom").ticks(5).outerTickSize(0)
|
||||
|
||||
|
||||
svg = d3.select("#"+histogramElement.attr("id")).append("svg")
|
||||
.attr("width", width + margin.left + margin.right)
|
||||
.attr("height", height + margin.top + margin.bottom)
|
||||
|
@ -214,13 +214,13 @@ module.exports = class LadderTabView extends CocoView
|
|||
barClass = "bar"
|
||||
if teamName.toLowerCase() is "ogres" then barClass = "ogres-bar"
|
||||
if teamName.toLowerCase() is "humans" then barClass = "humans-bar"
|
||||
|
||||
|
||||
bar = svg.selectAll(".bar")
|
||||
.data(data)
|
||||
.enter().append("g")
|
||||
.attr("class",barClass)
|
||||
.attr("transform", (d) -> "translate(#{x(d.x)},#{y(d.y)})")
|
||||
|
||||
.attr("transform", (d) -> "translate(#{x(d.x)},#{y(d.y)})")
|
||||
|
||||
bar.append("rect")
|
||||
.attr("x",1)
|
||||
.attr("width",width/20)
|
||||
|
@ -232,7 +232,7 @@ module.exports = class LadderTabView extends CocoView
|
|||
.enter().append("g")
|
||||
.attr("class","specialbar")
|
||||
.attr("transform", "translate(#{x(playerScore)},#{y(9001)})")
|
||||
|
||||
|
||||
scorebar.append("rect")
|
||||
.attr("x",1)
|
||||
.attr("width",3)
|
||||
|
@ -240,9 +240,9 @@ module.exports = class LadderTabView extends CocoView
|
|||
rankClass = "rank-text"
|
||||
if teamName.toLowerCase() is "ogres" then rankClass = "rank-text ogres-rank-text"
|
||||
if teamName.toLowerCase() is "humans" then rankClass = "rank-text humans-rank-text"
|
||||
|
||||
|
||||
message = "#{histogramData.length} players"
|
||||
if @leaderboards[teamName].session? then message="#{@leaderboards[teamName].myRank}/#{histogramData.length}"
|
||||
if @leaderboards[teamName].session? then message="##{@leaderboards[teamName].myRank} of #{histogramData.length}"
|
||||
svg.append("g")
|
||||
.append("text")
|
||||
.attr("class",rankClass)
|
||||
|
@ -250,14 +250,14 @@ module.exports = class LadderTabView extends CocoView
|
|||
.attr("text-anchor","end")
|
||||
.attr("x",width)
|
||||
.text(message)
|
||||
|
||||
|
||||
#Translate the x-axis up
|
||||
svg.append("g")
|
||||
.attr("class", "x axis")
|
||||
.attr("transform","translate(0," + height + ")")
|
||||
.call(xAxis)
|
||||
|
||||
|
||||
|
||||
|
||||
consolidateFriends: ->
|
||||
allFriendSessions = (@facebookFriendSessions or []).concat(@gplusFriendSessions or [])
|
||||
sessions = _.uniq allFriendSessions, false, (session) -> session._id
|
||||
|
@ -312,7 +312,7 @@ class LeaderboardData extends CocoClass
|
|||
@trigger 'sync', @
|
||||
# TODO: cache user ids -> names mapping, and load them here as needed,
|
||||
# and apply them to sessions. Fetching each and every time is too costly.
|
||||
|
||||
|
||||
onFail: (resource, jqxhr) =>
|
||||
return if @destroyed
|
||||
@trigger 'error', @, jqxhr
|
||||
|
|
|
@ -35,7 +35,6 @@ module.exports = class ControlBarView extends View
|
|||
@session = options.session
|
||||
@level = options.level
|
||||
@playableTeams = options.playableTeams
|
||||
@ladderGame = options.ladderGame
|
||||
@spectateGame = options.spectateGame ? false
|
||||
super options
|
||||
|
||||
|
@ -55,13 +54,13 @@ module.exports = class ControlBarView extends View
|
|||
super c
|
||||
c.worldName = @worldName
|
||||
c.multiplayerEnabled = @session.get('multiplayer')
|
||||
c.ladderGame = @ladderGame
|
||||
c.ladderGame = @level.get('type') is 'ladder'
|
||||
c.spectateGame = @spectateGame
|
||||
c.homeLink = "/"
|
||||
levelID = @level.get('slug')
|
||||
if levelID in ["brawlwood", "brawlwood-tutorial", "dungeon-arena", "dungeon-arena-tutorial"]
|
||||
levelID = 'brawlwood' if levelID is 'brawlwood-tutorial'
|
||||
c.homeLink = "/play/ladder/" + levelID
|
||||
console.log "level type is", @level.get('type')
|
||||
if @level.get('type') in ['ladder', 'ladder-tutorial']
|
||||
c.homeLink = '/play/ladder/' + @level.get('slug').replace /\-tutorial$/, ''
|
||||
else
|
||||
c.homeLink = '/'
|
||||
c
|
||||
|
||||
afterRender: ->
|
||||
|
|
|
@ -97,8 +97,12 @@ module.exports = class SpellView extends View
|
|||
aceCommands.push c.name
|
||||
addCommand
|
||||
name: 'run-code'
|
||||
bindKey: {win: 'Shift-Enter|Ctrl-Enter|Ctrl-S', mac: 'Shift-Enter|Command-Enter|Ctrl-Enter|Command-S|Ctrl-S'}
|
||||
bindKey: {win: 'Shift-Enter|Ctrl-Enter', mac: 'Shift-Enter|Command-Enter|Ctrl-Enter'}
|
||||
exec: -> Backbone.Mediator.publish 'tome:manual-cast', {}
|
||||
addCommand
|
||||
name: 'no-op'
|
||||
bindKey: {win: 'Ctrl-S', mac: 'Command-S|Ctrl-S'}
|
||||
exec: -> # just prevent page save call
|
||||
addCommand
|
||||
name: 'toggle-playing'
|
||||
bindKey: {win: 'Ctrl-P', mac: 'Command-P|Ctrl-P'}
|
||||
|
|
|
@ -174,7 +174,7 @@ module.exports = class PlayLevelView extends View
|
|||
@initSurface()
|
||||
@initGoalManager()
|
||||
@initScriptManager()
|
||||
@insertSubviews ladderGame: (@level.get('type') is "ladder")
|
||||
@insertSubviews()
|
||||
@initVolume()
|
||||
@listenTo(@session, 'change:multiplayer', @onMultiplayerChanged)
|
||||
@originalSessionState = $.extend(true, {}, @session.get('state'))
|
||||
|
@ -238,15 +238,15 @@ module.exports = class PlayLevelView extends View
|
|||
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
||||
ctx.fillText("Loaded #{@modelsLoaded} thingies",50,50)
|
||||
|
||||
insertSubviews: (subviewOptions) ->
|
||||
@insertSubView @tome = new TomeView levelID: @levelID, session: @session, thangs: @world.thangs, supermodel: @supermodel, ladderGame: subviewOptions.ladderGame
|
||||
insertSubviews: ->
|
||||
@insertSubView @tome = new TomeView levelID: @levelID, session: @session, thangs: @world.thangs, supermodel: @supermodel
|
||||
@insertSubView new PlaybackView {}
|
||||
@insertSubView new GoalsView {}
|
||||
@insertSubView new GoldView {}
|
||||
@insertSubView new HUDView {}
|
||||
@insertSubView new ChatView levelID: @levelID, sessionID: @session.id, session: @session
|
||||
worldName = utils.i18n @level.attributes, 'name'
|
||||
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, playableTeams: @world.playableTeams, ladderGame: subviewOptions.ladderGame}
|
||||
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, playableTeams: @world.playableTeams}
|
||||
#Backbone.Mediator.publish('level-set-debug', debug: true) if me.displayName() is 'Nick!'
|
||||
|
||||
afterInsert: ->
|
||||
|
|
|
@ -161,7 +161,7 @@ module.exports = class SpectateLevelView extends View
|
|||
@initSurface()
|
||||
@initGoalManager()
|
||||
@initScriptManager()
|
||||
@insertSubviews ladderGame: @otherSession?
|
||||
@insertSubviews()
|
||||
@initVolume()
|
||||
|
||||
@originalSessionState = $.extend(true, {}, @session.get('state'))
|
||||
|
@ -229,8 +229,8 @@ module.exports = class SpectateLevelView extends View
|
|||
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
||||
ctx.fillText("Loaded #{@modelsLoaded} thingies",50,50)
|
||||
|
||||
insertSubviews: (subviewOptions) ->
|
||||
@insertSubView @tome = new TomeView levelID: @levelID, session: @session, thangs: @world.thangs, supermodel: @supermodel, ladderGame: subviewOptions.ladderGame
|
||||
insertSubviews: ->
|
||||
@insertSubView @tome = new TomeView levelID: @levelID, session: @session, thangs: @world.thangs, supermodel: @supermodel
|
||||
@insertSubView new PlaybackView {}
|
||||
|
||||
@insertSubView new GoldView {}
|
||||
|
|
|
@ -108,7 +108,7 @@ sendLadderUpdateEmail = (session, now, daysAgo) ->
|
|||
context =
|
||||
email_id: sendwithus.templates.ladder_update_email
|
||||
recipient:
|
||||
address: if DEBUGGING then 'nick@codecombat.com' else user.email
|
||||
address: if DEBUGGING then 'nick@codecombat.com' else user.get('email')
|
||||
name: name
|
||||
email_data:
|
||||
name: name
|
||||
|
|
Loading…
Reference in a new issue