#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,38 +17,40 @@ 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
table.table.table-bordered.table-condensed.table-hover if view.simulatorsLeaderboardData
thead - var topSimulators = view.simulatorsLeaderboardData.topSimulators.models;
tr - var showJustTop = view.simulatorsLeaderboardData.inTopSimulators() || me.get('anonymous');
th - if(!showJustTop) topSimulators = topSimulators.slice(0, 10);
th(data-i18n="general.player").name-col-cell Player table.table.table-bordered.table-condensed.table-hover
th(data-i18n="ladder.games_simulated") Games simulated thead
//th(data-i18n="ladder.games_played") Games played tr
//th(data-i18n="ladder.ratio") Ratio th
tbody th(data-i18n="general.player").name-col-cell Player
- var topSimulators = simulatorsLeaderboardData.topSimulators.models; th(data-i18n="ladder.games_simulated") Games simulated
- var showJustTop = simulatorsLeaderboardData.inTopSimulators() || me.get('anonymous'); //th(data-i18n="ladder.games_played") Games played
- if(!showJustTop) topSimulators = topSimulators.slice(0, 10); //th(data-i18n="ladder.ratio") Ratio
for user, rank in topSimulators tbody
- var myRow = user.id == me.id for user, rank in topSimulators
tr(class=myRow ? "success" : "")
td.simulator-leaderboard-cell= rank + 1
td.name-col-cell= user.get('name') || "Anonymous"
td.simulator-leaderboard-cell= user.get('simulatedBy')
//td.simulator-leaderboard-cell= user.get('simulatedFor')
//td.simulator-leaderboard-cell= Math.round((user.get('simulatedBy') / user.get('simulatedFor')) * 10) / 10
if !showJustTop && simulatorsLeaderboardData.nearbySimulators().length
tr(class="active")
td(colspan=5).ellipsis-row ...
for user in simulatorsLeaderboardData.nearbySimulators()
- var myRow = user.id == me.id - var myRow = user.id == me.id
- var ratio = user.get('simulatedBy') / user.get('simulatedFor');
tr(class=myRow ? "success" : "") tr(class=myRow ? "success" : "")
td.simulator-leaderboard-cell= user.rank td.simulator-leaderboard-cell= rank + 1
td.name-col-cell= user.get('name') || "Anonymous" td.name-col-cell= user.get('name') || "Anonymous"
td.simulator-leaderboard-cell= user.get('simulatedBy') td.simulator-leaderboard-cell= user.get('simulatedBy')
//td.simulator-leaderboard-cell= user.get('simulatedFor') //td.simulator-leaderboard-cell= user.get('simulatedFor')
//td.simulator-leaderboard-cell= _.isNaN(ratio) || ratio == Infinity ? '' : ratio.toFixed(1) //td.simulator-leaderboard-cell= Math.round((user.get('simulatedBy') / user.get('simulatedFor')) * 10) / 10
- var nearbySimulators = view.simulatorsLeaderboardData.nearbySimulators()
if !showJustTop && nearbySimulators
tr(class="active")
td(colspan=5).ellipsis-row ...
for user in nearbySimulators
- var myRow = user.id == me.id
- var ratio = user.get('simulatedBy') / user.get('simulatedFor');
tr(class=myRow ? "success" : "")
td.simulator-leaderboard-cell= user.rank
td.name-col-cell= user.get('name') || "Anonymous"
td.simulator-leaderboard-cell= user.get('simulatedBy')
//td.simulator-leaderboard-cell= user.get('simulatedFor')
//td.simulator-leaderboard-cell= _.isNaN(ratio) || ratio == Infinity ? '' : ratio.toFixed(1)

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()