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/autoplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class Autoplay {
this.stop();
this.delay = delay;
this.schedule();
if (delay == 'realtime') this.redrawInterval = setInterval(this.ctrl.redraw, 100);
if (delay === 'realtime') this.redrawInterval = setInterval(this.ctrl.redraw, 100);
}

stop(): void {
Expand Down
6 changes: 3 additions & 3 deletions ui/analyse/src/ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default class AnalyseCtrl {
this.tree = makeTree(treeReconstruct(this.data.treeParts, this.data.sidelines));
if (prevTree) this.tree.merge(prevTree);
const mainline = treeOps.mainlineNodeList(this.tree.root);
if (this.data.game.status.name == 'draw') add3or5FoldGlyphs(mainline);
if (this.data.game.status.name === 'draw') add3or5FoldGlyphs(mainline);

this.autoplay = new Autoplay(this);
if (this.socket) this.socket.clearCache();
Expand Down Expand Up @@ -251,7 +251,7 @@ export default class AnalyseCtrl {
this.onMainline = this.tree.pathIsMainline(path);
this.fenInput = undefined;
this.pgnInput = undefined;
if (this.wiki && this.data.game.variant.key == 'standard') this.wiki(this.nodeList);
if (this.wiki && this.data.game.variant.key === 'standard') this.wiki(this.nodeList);
this.persistence?.save();
};

Expand Down Expand Up @@ -396,7 +396,7 @@ export default class AnalyseCtrl {

jump(path: Tree.Path): void {
const pathChanged = path !== this.path,
isForwardStep = pathChanged && path.length == this.path.length + 2;
isForwardStep = pathChanged && path.length === this.path.length + 2;
this.setPath(path);
if (pathChanged) {
if (this.study) this.study.setPath(path, this.node);
Expand Down
14 changes: 7 additions & 7 deletions ui/analyse/src/explorer/explorerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ export class ExplorerConfigCtrl {
}

selectPlayer = (name?: string) => {
name = name == 'me' ? this.myName : name;
name = name === 'me' ? this.myName : name;
if (!name) return;
if (name != this.myName && !this.participants.includes(name)) {
if (name !== this.myName && !this.participants.includes(name)) {
const previous = this.data.playerName.previous().filter(n => n !== name);
previous.unshift(name);
this.data.playerName.previous(previous.slice(0, 20));
Expand Down Expand Up @@ -125,17 +125,17 @@ export class ExplorerConfigCtrl {
toggleOpen = () => {
this.data.open(!this.data.open());
if (!this.data.open()) {
if (this.data.db() == 'player' && !this.data.playerName.value()) this.data.db('lichess');
if (this.data.db() === 'player' && !this.data.playerName.value()) this.data.db('lichess');
this.onClose();
}
};

fullHouse = () =>
this.data.byDb().since() <= `${minYear}-01` &&
(!this.data.byDb().until() || new Date().toISOString().slice(0, 7) <= this.data.byDb().until()) &&
(this.data.db() === 'masters' || this.data.speed().length == allSpeeds.length) &&
(this.data.db() !== 'lichess' || this.data.rating().length == allRatings.length) &&
(this.data.db() !== 'player' || this.data.mode().length == allModes.length);
(this.data.db() === 'masters' || this.data.speed().length === allSpeeds.length) &&
(this.data.db() !== 'lichess' || this.data.rating().length === allRatings.length) &&
(this.data.db() !== 'player' || this.data.mode().length === allModes.length);
}

export function view(ctrl: ExplorerConfigCtrl): VNode[] {
Expand Down Expand Up @@ -182,7 +182,7 @@ const playerDb = (ctrl: ExplorerConfigCtrl) => {
attrs: dataIcon(licon.ChasingArrows),
hook: bind('click', ctrl.toggleColor, ctrl.root.redraw),
},
` ${i18n.site[ctrl.data.color() == 'white' ? 'asWhite' : 'asBlack']}`,
` ${i18n.site[ctrl.data.color() === 'white' ? 'asWhite' : 'asBlack']}`,
),
]),
]),
Expand Down
10 changes: 5 additions & 5 deletions ui/analyse/src/explorer/explorerCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ export default class ExplorerCtrl {

private checkHash = (e?: HashChangeEvent) => {
const parts = location.hash.split('/');
if (parts[0] == '#explorer' || parts[0] == '#opening') {
if (parts[0] === '#explorer' || parts[0] === '#opening') {
this.enabled(true);
if (parts[1] == 'lichess' || parts[1] === 'masters') this.config.data.db(parts[1]);
if (parts[1] === 'lichess' || parts[1] === 'masters') this.config.data.db(parts[1]);
else if (parts[1]?.match(/[A-Za-z0-9_-]{2,30}/)) {
this.config.selectPlayer(parts[1]);
this.config.data.color(parts[2] == 'black' ? 'black' : 'white');
this.config.data.color(parts[2] === 'black' ? 'black' : 'white');
}
if (e) this.reload();
}
Expand Down Expand Up @@ -195,7 +195,7 @@ export default class ExplorerCtrl {
this.root.setAutoShapes();
};
onFlip = () => {
if (this.db() == 'player') {
if (this.db() === 'player') {
this.cache = {};
this.setNode();
}
Expand All @@ -218,7 +218,7 @@ export default class ExplorerCtrl {
fetchTablebaseHit = async (fen: FEN): Promise<SimpleTablebaseHit> => {
const res = await xhr.tablebase(this.opts.tablebaseEndpoint, this.effectiveVariant, fen);
const move = res.moves[0];
if (move && move.dtz == null) throw 'unknown tablebase position';
if (move && move.dtz === null) throw 'unknown tablebase position';
return {
fen,
best: move && move.uci,
Expand Down
16 changes: 8 additions & 8 deletions ui/analyse/src/explorer/explorerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const showResult = (winner?: Color): VNode =>
function showGameTable(ctrl: AnalyseCtrl, fen: FEN, title: string, games: OpeningGame[]): VNode | null {
if (!ctrl.explorer.withGames || !games.length) return null;
const openedId = ctrl.explorer.gameMenu(),
isMasters = ctrl.explorer.db() == 'masters';
isMasters = ctrl.explorer.db() === 'masters';
return h('table.games', [
h('thead', [h('tr', [h('th.title', { attrs: { colspan: isMasters ? 4 : 5 } }, title)])]),
h(
Expand Down Expand Up @@ -162,7 +162,7 @@ function gameActions(ctrl: AnalyseCtrl, game: OpeningGame): VNode {
ctrl.redraw();
};
return h('tr', { key: game.id + '-m' }, [
h('td.game_menu', { attrs: { colspan: ctrl.explorer.db() == 'masters' ? 4 : 5 } }, [
h('td.game_menu', { attrs: { colspan: ctrl.explorer.db() === 'masters' ? 4 : 5 } }, [
h(
'div.game_title',
`${game.white.name} - ${game.black.name}, ${showResult(game.winner).text}, ${game.year}`,
Expand Down Expand Up @@ -263,7 +263,7 @@ function show(ctrl: AnalyseCtrl): MaybeVNode {
data.fen,
title,
tooltip,
data.moves.filter(m => m.category == category),
data.moves.filter(m => m.category === category),
);
if (data.moves.length)
lastShow = h('div.data', [
Expand Down Expand Up @@ -320,7 +320,7 @@ const explorerTitle = (explorer: ExplorerCtrl) => {
'span.active.text.' + db,
{
attrs: { title, ...dataIcon(licon.Book) },
hook: db == 'player' ? bind('click', explorer.config.toggleColor, explorer.reload) : undefined,
hook: db === 'player' ? bind('click', explorer.config.toggleColor, explorer.reload) : undefined,
},
nodes,
);
Expand All @@ -330,18 +330,18 @@ const explorerTitle = (explorer: ExplorerCtrl) => {
const data = explorer.current();
const queuePosition = data && isOpening(data) && data.queuePosition;
return h('div.explorer-title', [
db == 'masters'
db === 'masters'
? active([h('strong', 'Masters'), ' database'], masterDbExplanation)
: explorer.config.allDbs.includes('masters') && otherLink('Masters', masterDbExplanation),
db == 'lichess'
db === 'lichess'
? active([h('strong', 'Lichess'), ' database'], lichessDbExplanation)
: otherLink('Lichess', lichessDbExplanation),
db == 'player'
db === 'player'
? playerName
? active(
[
h(`strong${playerName.length > 14 ? '.long' : ''}`, playerName),
` ${i18n.site[explorer.config.data.color() == 'white' ? 'asWhite' : 'asBlack']}`,
` ${i18n.site[explorer.config.data.color() === 'white' ? 'asWhite' : 'asBlack']}`,
explorer.isIndexing() &&
!explorer.config.data.open() &&
h('i.ddloader', {
Expand Down
2 changes: 1 addition & 1 deletion ui/analyse/src/ground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const render = (ctrl: AnalyseCtrl): VNode =>

export function promote(ground: CgApi, key: Key, role: Role) {
const piece = ground.state.pieces.get(key);
if (piece && piece.role == 'pawn') {
if (piece && piece.role === 'pawn') {
ground.setPieces(new Map([[key, { color: piece.color, role, promoted: true }]]));
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/analyse/src/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const bind = (ctrl: AnalyseCtrl) => {
for (let i = 1; i < 7; i++) kbd.bind(i.toString(), () => ctrl.study?.glyphForm.toggleGlyph(i));
// = ∞ ⩲ ⩱ ± ∓ +- -+
for (let i = 1; i < 9; i++)
kbd.bind(`shift+${i}`, () => ctrl.study?.glyphForm.toggleGlyph(i == 1 ? 10 : 11 + i));
kbd.bind(`shift+${i}`, () => ctrl.study?.glyphForm.toggleGlyph(i === 1 ? 10 : 11 + i));
}
};

Expand Down
4 changes: 2 additions & 2 deletions ui/analyse/src/retrospect/retroCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function make(root: AnalyseCtrl, color: Color): RetroCtrl {
}

function findNextNode(): Tree.Node | undefined {
const colorModulo = color == 'white' ? 1 : 0;
const colorModulo = color === 'white' ? 1 : 0;
candidateNodes = evalSwings(
root.mainline,
n => n.ply % 2 === colorModulo && !explorerCancelPlies.includes(n.ply),
Expand Down Expand Up @@ -248,7 +248,7 @@ export function make(root: AnalyseCtrl, color: Color): RetroCtrl {
},
preventGoingToNextMove: () => {
const cur = current();
return isSolving() && !!cur && root.path == cur.prev.path;
return isSolving() && !!cur && root.path === cur.prev.path;
},
close: root.toggleRetro,
node: () => root.node,
Expand Down
4 changes: 2 additions & 2 deletions ui/analyse/src/serverSideUnderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ export default function (element: HTMLElement, ctrl: AnalyseCtrl) {
.removeClass('active')
.filter('.' + panel)
.addClass('active');
if ((panel == 'move-times' || ctrl.opts.hunter) && !timeChartLoaded)
if ((panel === 'move-times' || ctrl.opts.hunter) && !timeChartLoaded)
site.asset.loadEsm<ChartGame>('chart.game').then(m => {
timeChartLoaded = true;
m.movetime($('#movetimes-chart')[0] as HTMLCanvasElement, data, ctrl.opts.hunter);
});
if ((panel == 'computer-analysis' || ctrl.opts.hunter) && $('#acpl-chart-container').length)
if ((panel === 'computer-analysis' || ctrl.opts.hunter) && $('#acpl-chart-container').length)
setTimeout(startAdvantageChart, 200);
};
$menu.on('mousedown', 'span', function (this: HTMLElement) {
Expand Down
2 changes: 1 addition & 1 deletion ui/analyse/src/study/chapterNewForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class StudyChapterNewForm {

setTab = (key: ChapterTab) => {
this.tab(key);
if (key != 'pgn' && this.orientation == 'automatic') this.orientation = 'white';
if (key != 'pgn' && this.orientation === 'automatic') this.orientation = 'white';
this.root.redraw();
};

Expand Down
6 changes: 3 additions & 3 deletions ui/analyse/src/study/gamebook/gamebookPlayView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { richHTML } from 'common/richText';
export function render(ctrl: GamebookPlayCtrl): VNode {
const state = ctrl.state;
return h('div.gamebook', { hook: { insert: _ => site.asset.loadCssPath('analyse.gamebook.play') } }, [
(state.comment || state.feedback == 'play' || state.feedback == 'end') &&
(state.comment || state.feedback === 'play' || state.feedback === 'end') &&
h('div.comment', { class: { hinted: state.showHint } }, [
state.comment
? h('div.content', { hook: richHTML(state.comment) })
: h(
'div.content',
state.feedback == 'play'
state.feedback === 'play'
? i18n.study.whatWouldYouPlay
: state.feedback == 'end' && i18n.study.youCompletedThisLesson,
: state.feedback === 'end' && i18n.study.youCompletedThisLesson,
),
hintZone(ctrl),
]),
Expand Down
20 changes: 11 additions & 9 deletions ui/analyse/src/study/multiBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export class MultiBoardCtrl {

private chapterFilter = (c: ChapterPreview) => {
const t = this.teamSelect();
return (!this.playing() || c.playing) && (!t || c.players?.white.team == t || c.players?.black.team == t);
return (
(!this.playing() || c.playing) && (!t || c.players?.white.team === t || c.players?.black.team === t)
);
};

setMaxPerPage = (nb: string) => {
Expand Down Expand Up @@ -130,7 +132,7 @@ function renderPagerNav(pager: Paginator<ChapterPreview>, ctrl: MultiBoardCtrl):
'select.study__multiboard__pager__max-per-page',
{ hook: bind('change', (e: Event) => ctrl.setMaxPerPage((e.target as HTMLOptionElement).value)) },
[4, 6, 8, 10, 12, 16, 20, 24, 32].map(nb =>
h('option', { attrs: { value: nb, selected: nb == max } }, i18n.study.perPage(nb)),
h('option', { attrs: { value: nb, selected: nb === max } }, i18n.study.perPage(nb)),
),
),
]);
Expand All @@ -146,7 +148,7 @@ const teamSelector = (ctrl: MultiBoardCtrl) => {
hook: bind('change', e => ctrl.teamSelect((e.target as HTMLOptionElement).value), ctrl.redraw),
},
[i18n.broadcast.allTeams, ...allTeams].map((t, i) =>
h('option', { attrs: { value: i ? t : '', selected: i && t == currentTeam } }, t),
h('option', { attrs: { value: i ? t : '', selected: i && t === currentTeam } }, t),
),
)
: undefined;
Expand Down Expand Up @@ -229,13 +231,13 @@ const makePreview =
};

export const verticalEvalGauge = (chap: ChapterPreview, cloudEval: MultiCloudEval): MaybeVNode => {
const tag = `span.mini-game__gauge${chap.orientation == 'black' ? ' mini-game__gauge--flip' : ''}${
chap.check == '#' ? ' mini-game__gauge--set' : ''
const tag = `span.mini-game__gauge${chap.orientation === 'black' ? ' mini-game__gauge--flip' : ''}${
chap.check === '#' ? ' mini-game__gauge--set' : ''
}`;
return chap.check == '#'
return chap.check === '#'
? h(tag, { attrs: { 'data-id': chap.id, title: 'Checkmate' } }, [
h('span.mini-game__gauge__black', {
attrs: { style: `height: ${fenColor(chap.fen) == 'white' ? 100 : 0}%` },
attrs: { style: `height: ${fenColor(chap.fen) === 'white' ? 100 : 0}%` },
}),
h('tick'),
])
Expand Down Expand Up @@ -276,7 +278,7 @@ const renderUser = (player: StudyPlayer): VNode =>
export const renderClock = (chapter: ChapterPreview, color: Color) => {
const turnColor = fenColor(chapter.fen);
const timeleft = computeTimeLeft(chapter, color);
const ticking = turnColor == color && otbClockIsRunning(chapter.fen);
const ticking = turnColor === color && otbClockIsRunning(chapter.fen);
return defined(timeleft)
? h(
'span.mini-game__clock.mini-game__clock',
Expand All @@ -289,7 +291,7 @@ export const renderClock = (chapter: ChapterPreview, color: Color) => {
const computeTimeLeft = (preview: ChapterPreview, color: Color): number | undefined => {
const clock = preview.players?.[color]?.clock;
if (notNull(clock)) {
if (defined(preview.lastMoveAt) && fenColor(preview.fen) == color) {
if (defined(preview.lastMoveAt) && fenColor(preview.fen) === color) {
const spent = (Date.now() - preview.lastMoveAt) / 1000;
return Math.max(0, clock / 100 - spent);
} else {
Expand Down
2 changes: 1 addition & 1 deletion ui/analyse/src/study/relay/relayCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class RelayCtrl {
});
};

roundById = (id: string) => this.data.rounds.find(r => r.id == id);
roundById = (id: string) => this.data.rounds.find(r => r.id === id);
currentRound = () => this.roundById(this.id)!;
roundName = () => this.currentRound().name;

Expand Down
8 changes: 4 additions & 4 deletions ui/analyse/src/study/relay/relayGames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ export const gamesList = (study: StudyCtrl, relay: RelayCtrl) => {
},
},
},
chapters.length == 1 && chapters[0].name == 'Chapter 1'
chapters.length === 1 && chapters[0].name === 'Chapter 1'
? []
: chapters.map((c, i) => {
const status =
!c.status || c.status == '*' ? renderClocks(c) : [c.status.slice(2, 3), c.status.slice(0, 1)];
!c.status || c.status === '*' ? renderClocks(c) : [c.status.slice(2, 3), c.status.slice(0, 1)];
const players = [c.players?.black, c.players?.white];
if (c.orientation == 'black') {
if (c.orientation === 'black') {
players.reverse();
status.reverse();
}
Expand All @@ -58,7 +58,7 @@ export const gamesList = (study: StudyCtrl, relay: RelayCtrl) => {
playerFed(p.fed),
h('span.name', [userTitle(p), p.name]),
]),
h(s == '1' ? 'good' : s == '0' ? 'bad' : 'status', [s]),
h(s === '1' ? 'good' : s === '0' ? 'bad' : 'status', [s]),
]
: [h('span.mini-game__user', h('span.name', 'Unknown player'))],
);
Expand Down
10 changes: 8 additions & 2 deletions ui/analyse/src/study/relay/relayPlayers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const playerView = (ctrl: RelayPlayers, show: PlayerToShow, tour: RelayTour): VN
h('div.relay-tour__player__cards', [
...(p.fide?.ratings
? ratingCategs.map(([key, name]) =>
h(`div.relay-tour__player__card${key == tc ? '.active' : ''}`, [
h(`div.relay-tour__player__card${key === tc ? '.active' : ''}`, [
h('em', name),
h('span', [p.fide?.ratings[key] || '-']),
]),
Expand Down Expand Up @@ -368,7 +368,13 @@ const renderPlayerGames = (ctrl: RelayPlayers, p: RelayPlayerWithGames, withTips
h('td.is.color-icon.' + game.color),
h(
'td.tpp__games__status',
points ? (points == '1' ? h('good', '1') : points == '0' ? h('bad', '0') : h('span', '½')) : '*',
points
? points === '1'
? h('good', '1')
: points === '0'
? h('bad', '0')
: h('span', '½')
: '*',
),
h('td', defined(game.ratingDiff) ? ratingDiff(game) : undefined),
],
Expand Down
6 changes: 3 additions & 3 deletions ui/analyse/src/study/relay/relayTeams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const renderTeams = (
const players = chap?.players;
if (!players) return;
const sortedPlayers =
game.pov == 'white' ? [players.white, players.black] : [players.black, players.white];
game.pov === 'white' ? [players.white, players.black] : [players.black, players.white];
return (
chap &&
h('a.relay-tour__team-match__game', { attrs: gameLinkAttrs(roundPath, chap) }, [
Expand All @@ -114,10 +114,10 @@ const playerView = (players: RelayPlayers, p: StudyPlayer) =>
]);

const statusView = (g: ChapterPreview, pov: Color, chapters: StudyChapters, cloudEval?: MultiCloudEval) => {
const status = pov == 'white' ? g.status : (g.status?.split('').reverse().join('') as StatusStr);
const status = pov === 'white' ? g.status : (g.status?.split('').reverse().join('') as StatusStr);
return h(
'span.relay-tour__team-match__game__status',
status && status != '*' ? status : cloudEval ? evalGauge(g, pov, chapters, cloudEval) : '*',
status && status !== '*' ? status : cloudEval ? evalGauge(g, pov, chapters, cloudEval) : '*',
);
};

Expand Down
Loading