From 82529c781b23603f29bd2440643b502828f36752 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Mon, 5 May 2014 15:33:08 -0700 Subject: [PATCH 1/2] Fixed some ladder home links. --- app/styles/play/spectate.sass | 4 +- app/views/play/ladder/ladder_tab.coffee | 46 ++++++++++---------- app/views/play/level/control_bar_view.coffee | 13 +++--- app/views/play/level/tome/spell_view.coffee | 6 ++- app/views/play/level_view.coffee | 8 ++-- app/views/play/spectate_view.coffee | 6 +-- 6 files changed, 44 insertions(+), 39 deletions(-) diff --git a/app/styles/play/spectate.sass b/app/styles/play/spectate.sass index 2fd8cf684..43d44e320 100644 --- a/app/styles/play/spectate.sass +++ b/app/styles/play/spectate.sass @@ -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) diff --git a/app/views/play/ladder/ladder_tab.coffee b/app/views/play/ladder/ladder_tab.coffee index 955df8b47..c1213e541 100644 --- a/app/views/play/ladder/ladder_tab.coffee +++ b/app/views/play/ladder/ladder_tab.coffee @@ -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 diff --git a/app/views/play/level/control_bar_view.coffee b/app/views/play/level/control_bar_view.coffee index 62f1932d1..a0a9407bb 100644 --- a/app/views/play/level/control_bar_view.coffee +++ b/app/views/play/level/control_bar_view.coffee @@ -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: -> diff --git a/app/views/play/level/tome/spell_view.coffee b/app/views/play/level/tome/spell_view.coffee index 1e2f5ed3a..fb52061a2 100644 --- a/app/views/play/level/tome/spell_view.coffee +++ b/app/views/play/level/tome/spell_view.coffee @@ -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'} diff --git a/app/views/play/level_view.coffee b/app/views/play/level_view.coffee index 5f087275a..d1fef01f6 100644 --- a/app/views/play/level_view.coffee +++ b/app/views/play/level_view.coffee @@ -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: -> diff --git a/app/views/play/spectate_view.coffee b/app/views/play/spectate_view.coffee index 4af55f00b..4a14f76c4 100644 --- a/app/views/play/spectate_view.coffee +++ b/app/views/play/spectate_view.coffee @@ -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 {} From bdf6d9e7594921348525a5e6c80854c48e88facd Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Mon, 5 May 2014 15:41:02 -0700 Subject: [PATCH 2/2] Fixed recipient address --- server/routes/mail.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/routes/mail.coffee b/server/routes/mail.coffee index 8b4f979fa..e7c2ee361 100644 --- a/server/routes/mail.coffee +++ b/server/routes/mail.coffee @@ -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