diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/render-msg.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js index 1cb0936..9b69603 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -1045,7 +1045,7 @@ function chessLocToIdxs(loc) { function lookupPiece(board, loc) { var idxs = chessLocToIdxs(loc) - return board[idxs[0]] && board[idxs[0]][idxs[1]] + return idxs && board[idxs[0]] && board[idxs[0]][idxs[1]] } function chessIdxsToLoc(i, j) { @@ -1053,6 +1053,7 @@ function chessIdxsToLoc(i, j) { } RenderMsg.prototype.chessBoard = function (board) { + if (!board) return '' return h('table.chess-board', board.map(function (rank, i) { return h('tr', rank.map(function (piece, j) { @@ -1112,6 +1113,14 @@ RenderMsg.prototype.chessInviteAccept = function (cb) { RenderMsg.prototype.chessGameEnd = function (cb) { var self = this var c = self.c + if (c.status === 'resigned') return self.link(self.c.root, function (err, rootLink) { + if (err) return cb(err) + self.wrap([ + h('div', h('small', '> ', rootLink)), + h('p', h('strong', 'resigned')) + ], cb) + }) + var fen = c.fen && c.fen.length === 2 ? c.pgnMove : c.fen var game = parseChess(fen) var piece = game && lookupPiece(game.board, c.dest) |