toggle analysis comments with keyboard

This commit is contained in:
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> <ul>
<li><strong>h</strong>/<strong>l</strong> or <strong></strong>/<strong></strong> move backward/forward</li> <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>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>c</strong> show/hide comments</li>
<li><strong>p</strong> show/hide comments</li>
</ul> </ul>
You can also scroll over the board to move in the game. You can also scroll over the board to move in the game.
</div> </div>

View file

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

View file

@ -30,4 +30,13 @@ module.exports = function(ctrl) {
control.last(ctrl); control.last(ctrl);
m.redraw(); 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) { function renderMeta(ctrl, move, path) {
if (!ctrl.vm.comments) return;
var opening = ctrl.data.game.opening; var opening = ctrl.data.game.opening;
opening = (move && opening && opening.size == move.ply) ? renderOpening(ctrl, opening) : null; opening = (move && opening && opening.size == move.ply) ? renderOpening(ctrl, opening) : null;
if (!move || (!opening && !move.comments.length && !move.variations.length)) return; if (!move || (!opening && !move.comments.length && !move.variations.length)) return;