Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/analyse/src/ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export default class AnalyseCtrl {
flip = () => {
this.flipped = !this.flipped;
this.study?.onFlip();
this.chessground.set({
this.chessground?.set({
orientation: this.bottomColor(),
});
if (this.retro && this.data.game.variant.key !== 'racingKings') {
Expand Down
48 changes: 24 additions & 24 deletions ui/analyse/src/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,30 @@ export const bind = (ctrl: AnalyseCtrl) => {
this.dispatchEvent(new MouseEvent(eventName));
})
);

//'Request computer analysis' & 'Learn From Your Mistakes' (mutually exclusive)
keyToMouseEvent(
'r',
'click',
'.analyse__underboard__panels .computer-analysis button, .analyse__round-training .advice-summary a.button'
);
//'Next' button ("in Learn From Your Mistake")
keyToMouseEvent('enter', 'click', '.analyse__tools .training-box a.continue');

//First explorer move
kbd.bind('shift+space', () => {
const move = document
.querySelector('.explorer-box:not(.loading) .moves tbody tr')
?.attributes.getNamedItem('data-uci')?.value;
if (move) ctrl.explorerMove(move);
});

[
['b', '??'],
['m', '?'],
['i', '?!'],
].forEach(([key, symbol]) => kbd.bind(key, () => ctrl.jumpToGlyphSymbol(ctrl.bottomColor(), symbol)));

if (ctrl.study) {
keyToMouseEvent('d', 'mousedown', '.study__buttons .comments');
keyToMouseEvent('g', 'mousedown', '.study__buttons .glyphs');
Expand All @@ -88,30 +112,6 @@ export const bind = (ctrl: AnalyseCtrl) => {
kbd.bind('p', ctrl.study.goToPrevChapter);
kbd.bind('n', ctrl.study.goToNextChapter);
for (let i = 1; i < 7; i++) kbd.bind(i.toString(), () => ctrl.study?.glyphForm.toggleGlyph(i));
} else {
//not study
//'Request computer analysis' & 'Learn From Your Mistakes' (mutually exclusive)
keyToMouseEvent(
'r',
'click',
'.analyse__underboard__panels .computer-analysis button, .analyse__round-training .advice-summary a.button'
);
//'Next' button ("in Learn From Your Mistake")
keyToMouseEvent('enter', 'click', '.analyse__tools .training-box a.continue');

//First explorer move
kbd.bind('shift+space', () => {
const move = document
.querySelector('.explorer-box:not(.loading) .moves tbody tr')
?.attributes.getNamedItem('data-uci')?.value;
if (move) ctrl.explorerMove(move);
});

[
['b', '??'],
['m', '?'],
['i', '?!'],
].forEach(([key, symbol]) => kbd.bind(key, () => ctrl.jumpToGlyphSymbol(ctrl.bottomColor(), symbol)));
}
};

Expand Down