From ebe3b981306bd830047b336c7a9dab884aa7e957 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Sun, 26 Apr 2015 16:22:24 +0200 Subject: [PATCH] computer analysis comment colors - closes #433 --- public/stylesheets/analyse.css | 9 +++++++++ ui/analyse/src/view.js | 20 ++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/public/stylesheets/analyse.css b/public/stylesheets/analyse.css index 189bbdfba6..02f44fe815 100644 --- a/public/stylesheets/analyse.css +++ b/public/stylesheets/analyse.css @@ -211,6 +211,15 @@ div.game_control .jumps { padding: 3px 0 0 5px; border-top: 1px solid #ccc; } +.lichess_ground .inaccuracy { + border-left: 3px solid #909090!important; +} +.lichess_ground .mistake { + border-left: 3px solid #cf8a02!important; +} +.lichess_ground .blunder { + border-left: 3px solid #c1080f!important; +} .lichess_ground .opening { padding-bottom: 3px; border-bottom: 1px solid #ccc; diff --git a/ui/analyse/src/view.js b/ui/analyse/src/view.js index b33e097939..2b820bd74c 100644 --- a/ui/analyse/src/view.js +++ b/ui/analyse/src/view.js @@ -55,9 +55,9 @@ function plyToTurn(ply) { return Math.floor((ply - 1) / 2) + 1; } -function renderVariation(ctrl, variation, path, border) { +function renderVariation(ctrl, variation, path, border, klass) { return m('div', { - class: 'variation' + (border ? ' border' : '') + class: 'variation' + (border ? ' border' : '') + (klass ? ' ' + klass : '') }, renderVariationContent(ctrl, variation, path)); } @@ -129,12 +129,24 @@ function renderMeta(ctrl, move, path) { if (!move || (!opening && !move.comments.length && !move.variations.length)) return; var children = []; if (opening) children.push(opening); + var commentClass; if (move.comments.length) move.comments.forEach(function(comment) { - children.push(m('div.comment', comment)); + if (comment.indexOf('Inaccuracy.') === 0) commentClass = 'inaccuracy'; + else if (comment.indexOf('Mistake.') === 0) commentClass = 'mistake'; + else if (comment.indexOf('Blunder.') === 0) commentClass = 'blunder'; + children.push(m('div', { + class: 'comment ' + commentClass + }, comment)); }); var border = children.length === 0; if (move.variations.length) move.variations.forEach(function(variation, i) { - children.push(renderVariation(ctrl, variation, treePath.withVariation(path, i + 1), border)); + children.push(renderVariation( + ctrl, + variation, + treePath.withVariation(path, i + 1), + border, + i === 0 ? commentClass : null + )); border = false; }); return children;