Merge pull request #9265 from benediktwerner/fix-setup-fen-validation

Fix setup fen validation
pull/9271/head
Thibault Duplessis 2021-06-26 17:28:42 +02:00 committed by GitHub
commit 15bb5fc26e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -66,8 +66,6 @@ $c-slider: $c-setup;
}
.fen_position {
display: none;
.board_editor {
display: block;
width: 50%;

View File

@ -162,9 +162,10 @@ export default class Setup {
}
$rated.prop('disabled', !!cantBeRated).siblings('label').toggleClass('disabled', cantBeRated);
const timeOk = timeMode != '1' || limit > 0 || inc > 0,
aiOk = typ != 'ai' || variantId != '3' || limit >= 1 || timeMode != '1';
aiOk = typ != 'ai' || variantId != '3' || limit >= 1 || timeMode != '1',
fenOk = variantId !== '3' || $fenInput.hasClass('success');
const disable = ($e: Cash, d: boolean) => $e.prop('disabled', d).toggleClass('disabled', d);
if (timeOk && aiOk) {
if (timeOk && aiOk && fenOk) {
disable($submits, false);
if (rated && randomColorVariants.includes(variantId)) {
disable($submits.filter(':not(.random)'), true);
@ -394,13 +395,13 @@ export default class Setup {
$fenPosition.find('a.board_editor').each(function (this: HTMLAnchorElement) {
this.href = this.href.replace(/editor\/.+$/, 'editor/' + fen);
});
$submits.removeClass('nope');
toggleButtons();
lichess.contentLoaded();
},
_ => {
$fenInput.addClass('failure');
$fenPosition.find('.preview').html('');
$submits.addClass('nope');
toggleButtons();
}
);
}
@ -415,6 +416,7 @@ export default class Setup {
$modeChoicesWrap.toggle(!isFen);
if (isFen) {
$casual.trigger('click');
validateFen();
requestAnimationFrame(() => document.body.dispatchEvent(new Event('chessground.resize')));
}
showRating();