Skip to content

Commit

Permalink
Merge branch 'master' into bulkPgnImportChapterNames
Browse files Browse the repository at this point in the history
* master:
  New Crowdin updates (lichess-org#12994)
  fix glaring timer bug
  fix round board menu keyboardMove toggle
  make it more obvious that boolPrefXhrToggle reloads the page by default
  enable voice/keyboard move from puzzles
  • Loading branch information
ornicar committed Jun 12, 2023
2 parents ec56188 + 915eeec commit 45865fc
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 20 deletions.
8 changes: 4 additions & 4 deletions translation/dest/site/de-DE.xml
Original file line number Diff line number Diff line change
Expand Up @@ -683,11 +683,11 @@
<string name="keyGoToStartOrEnd">zum Anfang/Ende</string>
<string name="keyShowOrHideComments">zeige/verberge Kommentare</string>
<string name="keyEnterOrExitVariation">Variante wählen/verlassen</string>
<string name="keyRequestComputerAnalysis">Fordere eine Computer-Analyse an, lerne aus deinen Fehlern</string>
<string name="keyRequestComputerAnalysis">Hole dir eine Computer-Analyse, lerne aus deinen Fehlern</string>
<string name="keyNextLearnFromYourMistakes">Als Nächstes (Lerne aus deinen Fehlern)</string>
<string name="keyNextBlunder">Nächster grober Patzer</string>
<string name="keyNextMistake">Nächster Fehler</string>
<string name="keyNextInaccuracy">Nächste Ungenauigkeit</string>
<string name="keyNextBlunder">Der nächste schwere Fehler</string>
<string name="keyNextMistake">Der nächste Fehler</string>
<string name="keyNextInaccuracy">Die nächste Ungenauigkeit</string>
<string name="newTournament">Neues Turnier</string>
<string name="tournamentHomeTitle">Schachturnier mit verschiedenen Zeitkontrollen und Schachvarianten</string>
<string name="tournamentHomeDescription">Spiele rasante Turniere! Trete einem geplanten Turnier bei oder erstelle ein neues. Bullet, Blitz, Klassisch, Chess960, King of the Hill, Threecheck und weitere Schachvarianten für grenzenlosen Spaß.</string>
Expand Down
7 changes: 7 additions & 0 deletions translation/dest/site/ja-JP.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<string name="openingExplorer">オープニング探索</string>
<string name="openingEndgameExplorer">序盤/終盤エクスプローラー</string>
<string name="xOpeningExplorer">%s オープニング探索</string>
<string name="playFirstOpeningEndgameExplorerMove">序盤/終盤エクスプローラーの最初の手を指す</string>
<string name="winPreventedBy50MoveRule">勝勢ながら 50 手ルールでドロー</string>
<string name="lossSavedBy50MoveRule">敗勢ながら 50 手ルールでドロー</string>
<string name="winOr50MovesByPriorMistake">勝ち、または以前の悪手のため50手ドロー</string>
Expand Down Expand Up @@ -646,6 +647,11 @@
<string name="keyGoToStartOrEnd">最初/最後に戻る</string>
<string name="keyShowOrHideComments">コメントを表示する/隠す</string>
<string name="keyEnterOrExitVariation">変化に入る/出る</string>
<string name="keyRequestComputerAnalysis">コンピュータ解析の要請、自分の悪手に学ぶ</string>
<string name="keyNextLearnFromYourMistakes">次(自分の悪手に学ぶ)</string>
<string name="keyNextBlunder">次の大悪手</string>
<string name="keyNextMistake">次の悪手</string>
<string name="keyNextInaccuracy">次のやや悪手</string>
<string name="newTournament">新しいトーナメント</string>
<string name="tournamentHomeTitle">さまざまな持時間とルールのチェストーナメント</string>
<string name="tournamentHomeDescription">早指しのチェストーナメントに参加しよう! 定時のトーナメントに参加するほか、自分で作ることもできます。ブレット、ブリッツ、クラシック、チェス960、キングオブザヒル、3チェックなどチェスの無限の楽しみを。</string>
Expand Down Expand Up @@ -741,6 +747,7 @@
<string name="invalidFen">無効な FEN</string>
<string name="custom">自由設定</string>
<string name="notifications">通知</string>
<string name="notificationsX">通知:%1$s</string>
<string name="perfRatingX">レーティング: %s</string>
<plurals name="nbSecondsToPlayTheFirstMove">
<item quantity="other">あと %s 秒以内に初手を指してください</item>
Expand Down
3 changes: 3 additions & 0 deletions ui/board/css/_menu.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.board-menu {
@extend %flex-column, %dropdown-shadow;
@if $theme == 'transp' {
backdrop-filter: blur(6px);
}
background: $c-bg-popup;
padding: 0.5em 1.5em;
user-select: none;
Expand Down
2 changes: 1 addition & 1 deletion ui/common/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ export const scrollTo = (el: HTMLElement, target: HTMLElement | null) => {

export const onClickAway = (f: () => void) => (el: HTMLElement) => {
const listen: () => void = () => $(document).one('click', e => (el.contains(e.target) ? listen() : f()));
setTimeout(listen, 100);
setTimeout(listen, 300);
};
8 changes: 8 additions & 0 deletions ui/common/src/controls.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { h, Hooks } from 'snabbdom';
import { bind, onInsert } from './snabbdom';
import { toggle as baseToggle } from './common';
import * as xhr from './xhr';

export interface ToggleSettings {
name: string;
Expand Down Expand Up @@ -43,3 +45,9 @@ export const rangeConfig = (read: () => number, write: (value: number) => void):
el.addEventListener('input', _ => write(parseInt(el.value)));
el.addEventListener('mouseout', _ => el.blur());
});

export const boolPrefXhrToggle = (prefKey: string, val: boolean, effect: () => void = lichess.reload) =>
baseToggle(val, async v => {
await xhr.text(`/pref/${prefKey}`, { method: 'post', body: xhr.form({ [prefKey]: v ? '1' : '0' }) });
effect();
});
1 change: 1 addition & 0 deletions ui/puzzle/src/ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default function (opts: PuzzleOpts, redraw: Redraw): Controller {
streakFailStorage.listen(_ => failStreak(streak));
}
const session = new PuzzleSession(opts.data.angle.key, opts.data.user?.id, hasStreak);

const menu = boardMenuToggle(redraw);

// required by ceval
Expand Down
5 changes: 3 additions & 2 deletions ui/puzzle/src/view/boardMenu.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { h } from 'snabbdom';
import { menu as menuDropdown } from 'board/menu';
import { Controller } from '../interfaces';
import { boolPrefXhrToggle } from 'common/controls';

export default function (ctrl: Controller) {
return menuDropdown(ctrl.trans, ctrl.redraw, ctrl.menu, menu => [
h('section', [menu.flip(ctrl.trans.noarg('flipBoard'), ctrl.flipped(), ctrl.flip)]),
h('section', [
menu.zenMode(true),
// menu.voiceInput(ctrl.voiceMoveEnabled, !spectator),
// menu.keyboardInput(ctrl.keyboardMoveEnabled, !spectator),
menu.voiceInput(boolPrefXhrToggle('voice', !!ctrl.voiceMove), true),
menu.keyboardInput(boolPrefXhrToggle('keyboardMove', !!ctrl.keyboardMove), true),
]),
h('section.board-menu__links', [
h('a', { attrs: { target: '_blank', href: '/account/preferences/display' } }, 'Game display preferences'),
Expand Down
10 changes: 0 additions & 10 deletions ui/round/src/ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export default class RoundController {
firstSeconds = true;
flip = false;
menu: ToggleWithUsed;
voiceMoveEnabled: Toggle;
keyboardMoveEnabled: Toggle;
confirmMoveEnabled: Toggle = toggle(true);
loading = false;
loadingTimeout: number;
Expand Down Expand Up @@ -144,14 +142,6 @@ export default class RoundController {
this.transientMove = new TransientMove(this.socket);

this.menu = boardMenuToggle(redraw);
this.voiceMoveEnabled = toggle(d.pref.voiceMove, async v => {
await xhr.setPreference('voice', v ? '1' : '0');
lichess.reload();
});
this.keyboardMoveEnabled = toggle(d.pref.keyboardMove, async v => {
await xhr.setPreference('keyboardMove', v ? '1' : '0');
lichess.reload();
});

this.trans = lichess.trans(opts.i18n);
this.noarg = this.trans.noarg;
Expand Down
5 changes: 3 additions & 2 deletions ui/round/src/view/boardMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { h } from 'snabbdom';
import RoundController from '../ctrl';
import { game as gameRoute } from 'game/router';
import { menu as menuDropdown } from 'board/menu';
import { boolPrefXhrToggle } from 'common/controls';

export default function (ctrl: RoundController) {
return menuDropdown(ctrl.trans, ctrl.redraw, ctrl.menu, menu => {
Expand All @@ -17,8 +18,8 @@ export default function (ctrl: RoundController) {
]),
h('section', [
menu.zenMode(!spectator),
menu.voiceInput(ctrl.voiceMoveEnabled, !spectator),
menu.keyboardInput(ctrl.keyboardMoveEnabled, !spectator),
menu.voiceInput(boolPrefXhrToggle('voice', !!ctrl.voiceMove), !spectator),
menu.keyboardInput(boolPrefXhrToggle('keyboardMove', !!ctrl.keyboardMove), !spectator),
!spectator && d.pref.submitMove ? menu.confirmMove(ctrl.confirmMoveEnabled) : undefined,
]),
h('section.board-menu__links', [
Expand Down
2 changes: 1 addition & 1 deletion ui/voice/src/move/moveCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export default (window as any).LichessVoiceMove = function (
}

choices = new Map<string, Uci>();
const preferred = options.length === 1 || options[0][1] < options[1][1];
const preferred = options.length === 1 || options[0][1].cost < options[1][1].cost;
if (preferred) choices.set('yes', options[0][0]);
if (colorsPref()) {
const colorNames = [...brushes.keys()];
Expand Down

0 comments on commit 45865fc

Please sign in to comment.