Skip to content

Commit

Permalink
fix return to tournament button
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Oct 23, 2014
1 parent 53ba0c4 commit 72e2325
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions ui/round/src/view/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ var renderUser = require('./user');
var button = require('./button');
var c = require('chess.js');

function compact(elems) {
return Object.prototype.toString.call(elems) === '[object Array]' ? elems.filter(function(n) {
return n !== undefined
}) : [];
function compact(x) {
if (Object.prototype.toString.call(x) === '[object Array]') {
var elems = x.filter(function(n) {
return n !== undefined
});
return elems.length > 0 ? elems : null;
}
return x;
}

function renderPlayer(ctrl, player) {
Expand Down Expand Up @@ -57,7 +61,7 @@ function renderTableEnd(ctrl) {
button.newGame(ctrl)
]));
return [
buttons.length > 0 ? m('div.control.buttons', buttons) : null,
buttons ? m('div.control.buttons', buttons) : null,
renderReplay(ctrl.replay)
];
}
Expand All @@ -69,7 +73,7 @@ function renderTableWatch(ctrl) {
button.viewTournament(ctrl)
]);
return [
buttons.length > 0 ? m('div.control.buttons', buttons) : null,
buttons ? m('div.control.buttons', buttons) : null,
renderReplay(ctrl.replay),
renderPlayer(ctrl, d.player)
];
Expand All @@ -94,10 +98,10 @@ function renderTablePlay(ctrl) {
button.standard(ctrl, round.drawable, '2', 'offerDraw', 'draw-yes'),
button.standard(ctrl, round.resignable, 'b', 'resign', 'resign')
]),
buttons.length > 0 ? m('div.control.buttons', buttons) : null,
buttons ? m('div.control.buttons', buttons) : null,
renderReplay(ctrl.replay),
m('div.whos_turn',
ctrl.trans(d.game.player == d.player.color ? 'yourTurn' : 'waitingForOpponent'))
ctrl.trans(d.game.player == d.player.color ? 'yourTurn' : 'waitingForOpponent'))
];
}

Expand Down

0 comments on commit 72e2325

Please sign in to comment.