properly render equal eval in analysis UI
This commit is contained in:
parent
d076375c8c
commit
31f987ee17
|
@ -1,4 +1,5 @@
|
|||
var treePath = require('./path');
|
||||
var defined = require('./util').defined;
|
||||
|
||||
module.exports = function(game, analysis) {
|
||||
|
||||
|
@ -16,8 +17,8 @@ module.exports = function(game, analysis) {
|
|||
var applyAnalysis = function(tree, analysed) {
|
||||
analysed.forEach(function(ana, i) {
|
||||
if (!tree[i]) return;
|
||||
if (ana.mate) tree[i].mate = ana.mate;
|
||||
else if (ana.eval) tree[i].eval = ana.eval;
|
||||
if (defined(ana.mate)) tree[i].mate = ana.mate;
|
||||
else if (defined(ana.eval)) tree[i].eval = ana.eval;
|
||||
if (ana.comment) tree[i].comments.push(ana.comment);
|
||||
if (ana.variation) tree[i].variations.push(makeTree(ana.variation.split(' '), i + 1));
|
||||
});
|
||||
|
|
5
ui/analyse/src/util.js
Normal file
5
ui/analyse/src/util.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
defined: function(v) {
|
||||
return typeof v !== 'undefined';
|
||||
}
|
||||
};
|
|
@ -1,6 +1,7 @@
|
|||
var m = require('mithril');
|
||||
var chessground = require('chessground');
|
||||
var classSet = require('chessground').util.classSet;
|
||||
var defined = require('./util').defined;
|
||||
var game = require('game').game;
|
||||
var partial = require('chessground').util.partial;
|
||||
var renderStatus = require('game').view.status;
|
||||
|
@ -43,8 +44,8 @@ function renderMove(ctrl, move, path) {
|
|||
'href': '#' + path[0].ply
|
||||
},
|
||||
children: [
|
||||
move.eval ? renderEvalTag(renderEval(move.eval)) : (
|
||||
move.mate ? renderEvalTag('#' + move.mate) : null
|
||||
defined(move.eval) ? renderEvalTag(renderEval(move.eval)) : (
|
||||
defined(move.mate) ? renderEvalTag('#' + move.mate) : null
|
||||
),
|
||||
move.san
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue