toggle analysis comments with keyboard

pull/132/head
Thibault Duplessis 2014-11-09 22:59:47 +01:00
parent b9728e9d5b
commit f32d659d17
4 changed files with 13 additions and 3 deletions

View File

@ -32,8 +32,7 @@ i18n: @round.jsI18n()
<ul>
<li><strong>h</strong>/<strong>l</strong> or <strong></strong>/<strong></strong> move backward/forward</li>
<li><strong>j</strong>/<strong>k</strong> or <strong></strong>/<strong></strong> go to start/end</li>
<li><strong>i</strong>/<strong>o</strong> go to previous/next mistake</li>
<li><strong>p</strong> show/hide comments</li>
<li><strong>c</strong> show/hide comments</li>
</ul>
You can also scroll over the board to move in the game.
</div>

View File

@ -17,7 +17,8 @@ module.exports = function(cfg, router, i18n, onChange) {
path: initialPath,
pathStr: treePath.write(initialPath),
situation: null,
continue: false
continue: false,
comments: true
};
var situationCache = {};

View File

@ -30,4 +30,13 @@ module.exports = function(ctrl) {
control.last(ctrl);
m.redraw();
}));
k.bind('c', preventing(function() {
ctrl.vm.comments = !ctrl.vm.comments;
if (!ctrl.vm.comments && ctrl.vm.path.length > 1) {
path = [ctrl.vm.path[0]];
path[0].variation = null;
ctrl.jump(path);
}
m.redraw();
}));
};

View File

@ -78,6 +78,7 @@ function renderOpening(ctrl, opening) {
}
function renderMeta(ctrl, move, path) {
if (!ctrl.vm.comments) return;
var opening = ctrl.data.game.opening;
opening = (move && opening && opening.size == move.ply) ? renderOpening(ctrl, opening) : null;
if (!move || (!opening && !move.comments.length && !move.variations.length)) return;