#3138 #3488 refactor SimulateTabView

This commit is contained in:
duybkict 2016-06-09 10:00:47 +07:00
parent b0fcddac68
commit a4e8cafdb3
2 changed files with 34 additions and 41 deletions

View file

@ -1,6 +1,6 @@
p(id="simulation-status-text") p(id="simulation-status-text")
if simulationStatus if view.simulationStatus
| #{simulationStatus} | #{view.simulationStatus}
else else
span(data-i18n="ladder.simulation_explanation") By simulating games you can get your game ranked faster! span(data-i18n="ladder.simulation_explanation") By simulating games you can get your game ranked faster!
span.spl(data-i18n="ladder.simulation_explanation_leagues") You will mainly help simulate games for allied players in your clans and courses. span.spl(data-i18n="ladder.simulation_explanation_leagues") You will mainly help simulate games for allied players in your clans and courses.
@ -17,8 +17,12 @@ p.simulation-count
//p.simulation-count //p.simulation-count
// span.spr(data-i18n="ladder.games_in_queue") Games currently in the queue: // span.spr(data-i18n="ladder.games_in_queue") Games currently in the queue:
// span#games-in-queue= numberOfGamesInQueue || 0 // span#games-in-queue= view.simulatorsLeaderboardData.numberOfGamesInQueue || 0
if view.simulatorsLeaderboardData
- var topSimulators = view.simulatorsLeaderboardData.topSimulators.models;
- var showJustTop = view.simulatorsLeaderboardData.inTopSimulators() || me.get('anonymous');
- if(!showJustTop) topSimulators = topSimulators.slice(0, 10);
table.table.table-bordered.table-condensed.table-hover table.table.table-bordered.table-condensed.table-hover
thead thead
tr tr
@ -28,9 +32,6 @@ table.table.table-bordered.table-condensed.table-hover
//th(data-i18n="ladder.games_played") Games played //th(data-i18n="ladder.games_played") Games played
//th(data-i18n="ladder.ratio") Ratio //th(data-i18n="ladder.ratio") Ratio
tbody tbody
- var topSimulators = simulatorsLeaderboardData.topSimulators.models;
- var showJustTop = simulatorsLeaderboardData.inTopSimulators() || me.get('anonymous');
- if(!showJustTop) topSimulators = topSimulators.slice(0, 10);
for user, rank in topSimulators for user, rank in topSimulators
- var myRow = user.id == me.id - var myRow = user.id == me.id
tr(class=myRow ? "success" : "") tr(class=myRow ? "success" : "")
@ -40,10 +41,11 @@ table.table.table-bordered.table-condensed.table-hover
//td.simulator-leaderboard-cell= user.get('simulatedFor') //td.simulator-leaderboard-cell= user.get('simulatedFor')
//td.simulator-leaderboard-cell= Math.round((user.get('simulatedBy') / user.get('simulatedFor')) * 10) / 10 //td.simulator-leaderboard-cell= Math.round((user.get('simulatedBy') / user.get('simulatedFor')) * 10) / 10
if !showJustTop && simulatorsLeaderboardData.nearbySimulators().length - var nearbySimulators = view.simulatorsLeaderboardData.nearbySimulators()
if !showJustTop && nearbySimulators
tr(class="active") tr(class="active")
td(colspan=5).ellipsis-row ... td(colspan=5).ellipsis-row ...
for user in simulatorsLeaderboardData.nearbySimulators() for user in nearbySimulators
- var myRow = user.id == me.id - var myRow = user.id == me.id
- var ratio = user.get('simulatedBy') / user.get('simulatedFor'); - var ratio = user.get('simulatedBy') / user.get('simulatedFor');
tr(class=myRow ? "success" : "") tr(class=myRow ? "success" : "")

View file

@ -11,8 +11,7 @@ module.exports = class SimulateTabView extends CocoView
events: events:
'click #simulate-button': 'onSimulateButtonClick' 'click #simulate-button': 'onSimulateButtonClick'
constructor: (options) -> initialize: ->
super(options)
@simulatorsLeaderboardData = new SimulatorsLeaderboardData(me) @simulatorsLeaderboardData = new SimulatorsLeaderboardData(me)
@simulatorsLeaderboardDataRes = @supermodel.addModelResource(@simulatorsLeaderboardData, 'top_simulators', {cache: false}) @simulatorsLeaderboardDataRes = @supermodel.addModelResource(@simulatorsLeaderboardData, 'top_simulators', {cache: false})
@simulatorsLeaderboardDataRes.load() @simulatorsLeaderboardDataRes.load()
@ -28,14 +27,6 @@ module.exports = class SimulateTabView extends CocoView
if (document.location.hash is '#simulate' or @options.level.get('type') is 'course-ladder') and not @simulator if (document.location.hash is '#simulate' or @options.level.get('type') is 'course-ladder') and not @simulator
@startSimulating() @startSimulating()
getRenderData: ->
ctx = super()
ctx.simulationStatus = @simulationStatus
ctx.simulatorsLeaderboardData = @simulatorsLeaderboardData
ctx.numberOfGamesInQueue = @simulatorsLeaderboardData.numberOfGamesInQueue
ctx._ = _
ctx
afterRender: -> afterRender: ->
super() super()