Tint game-tile material bars with custom piece colours.
Left/right fills follow each side's piece skin; the grey bar border stays unchanged.
@@ -1588,7 +1588,7 @@ dialog .avatar-credits {
1588
1588
margin-top: 5px;
1589
1589
border: 1px solid #879187;
1590
1590
border-radius: 5px;
1591
background: #202823;
1591
background: var(--material-right, #202823);
1592
1592
overflow: hidden;
1593
1593
direction: ltr
1594
1594
}
@@ -1597,7 +1597,7 @@ dialog .avatar-credits {
1597
1597
display: block;
1598
1598
width: 100%;
1599
1599
height: 100%;
1600
background: #fffefb;
1600
background: var(--material-left, #fffefb);
1601
1601
transform: scaleX(.5);
1602
1602
transform-origin: left center
1603
1603
}
@@ -1588,7 +1588,7 @@ dialog .avatar-credits {1588
margin-top: 5px;1588
margin-top: 5px;1589
border: 1px solid #879187;1589
border: 1px solid #879187;1590
border-radius: 5px;1590
border-radius: 5px;1591
background: #202823;1591
background: var(--material-right, #202823);1592
overflow: hidden;1592
overflow: hidden;1593
direction: ltr1593
direction: ltr1594
}1594
}@@ -1597,7 +1597,7 @@ dialog .avatar-credits {1597
display: block;1597
display: block;1598
width: 100%;1598
width: 100%;1599
height: 100%;1599
height: 100%;1600
background: #fffefb;1600
background: var(--material-left, #fffefb);1601
transform: scaleX(.5);1601
transform: scaleX(.5);1602
transform-origin: left center1602
transform-origin: left center1603
}1603
}@@ -281,13 +281,33 @@ function card (g)
281
281
else content = board(g) + `<div class="card-footer"><span class="${g.yourTurn ? 'turn-label' : ''}">${g.check ? 'Check · ' : ''}${g.yourTurn ? 'Your move' : 'Waiting for a move'}</span>${g.yourTurn ? `<button class="text-button" data-game-action="options" aria-label="Game options">${g.drawOffer === 'opponent' ? 'Draw offered · ' : ''}•••</button>` : `<span>Move ${Math.floor(g.state.ply / 2) + 1}</span>`}</div>`;
282
282
return `<article class="game-card ${!g.yourTurn && g.status === 'active' ? 'waiting' : ''}" data-game="${g.id}" aria-label="Game with ${esc(g.opponent)}"><div class="card-header">${avatarMarkup(g.opponent, g.opponentAvatar)}<div class="opponent-info"><strong><button class="opponent-name" data-opponent="${esc(g.opponentId)}">${esc(g.opponent)}</button> <small class="rating" aria-label="${g.opponentRating} Elo">${g.opponentRating}</small></strong>${g.status !== 'pending' ? materialBar(g) : ''}</div>${g.status !== 'pending' ? colorTagMarkup(g) : ''}${g.inactiveDays >= 7 ? '<button class="stop-inactive" data-game-action="stop-confirm" aria-label="Stop inactive game" title="Stop inactive game">×</button>' : ''}</div>${content}</article>`;
283
283
}
284
const MATERIAL_BAR_FILL = {
285
White: '#fffefb',
286
Black: '#202823',
287
Red: '#c62828',
288
Blue: '#1565c0',
289
Green: '#2e7d32',
290
Yellow: '#f9a825'
291
};
292
function materialBarSkins (g)
293
{
294
if (customColoursDisabled()) return { left: 'White', right: 'Black' };
295
return { left: g.pieceSkinWhite || 'White', right: g.pieceSkinBlack || 'Black' };
296
}
284
297
function materialBar (g)
285
298
{
286
299
const totals = { w: 0, b: 0 };
287
300
for (const p of g.state.board) if (p !== '.') totals[p === p.toUpperCase() ? 'w' : 'b'] += materialValues[p.toLowerCase()];
288
301
const total = totals.w + totals.b, share = total ? totals.w / total : .5;
289
const label = `White: ${totals.w} material points. Black: ${totals.b} material points. You play ${g.color === 'w' ? 'White' : 'Black'}.`;
290
return `<div class="material-bar" data-share="${share}" role="meter" aria-label="Material balance, White on the left and Black on the right" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${Math.round(share * 100)}" aria-valuetext="${esc(label)}" title="${esc(label)} Pawn 1 · Knight/Bishop 3 · Rook 5 · Queen 9. Kings are not counted." tabindex="0"><span class="material-white"></span></div>`;
302
const { left, right } = materialBarSkins(g);
303
const leftFill = MATERIAL_BAR_FILL[left] || MATERIAL_BAR_FILL.White;
304
const rightFill = MATERIAL_BAR_FILL[right] || MATERIAL_BAR_FILL.Black;
305
const you = g.color === 'w' ? left : right;
306
const label = `${left}: ${totals.w} material points. ${right}: ${totals.b} material points. You play ${you}${you === 'White' || you === 'Black' ? '' : ` (${g.color === 'w' ? 'White' : 'Black'})`}.`;
307
const ariaSides = left === 'White' && right === 'Black'
308
? 'White on the left and Black on the right'
309
: `${left} (White) on the left and ${right} (Black) on the right`;
310
return `<div class="material-bar" data-share="${share}" style="--material-left:${leftFill};--material-right:${rightFill}" role="meter" aria-label="Material balance, ${esc(ariaSides)}" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${Math.round(share * 100)}" aria-valuetext="${esc(label)}" title="${esc(label)} Pawn 1 · Knight/Bishop 3 · Rook 5 · Queen 9. Kings are not counted." tabindex="0"><span class="material-white"></span></div>`;
291
311
}
292
312
function renderMoveFeedback (now, reduced)
293
313
{
@@ -281,13 +281,33 @@ function card (g)281
else content = board(g) + `<div class="card-footer"><span class="${g.yourTurn ? 'turn-label' : ''}">${g.check ? 'Check · ' : ''}${g.yourTurn ? 'Your move' : 'Waiting for a move'}</span>${g.yourTurn ? `<button class="text-button" data-game-action="options" aria-label="Game options">${g.drawOffer === 'opponent' ? 'Draw offered · ' : ''}•••</button>` : `<span>Move ${Math.floor(g.state.ply / 2) + 1}</span>`}</div>`;281
else content = board(g) + `<div class="card-footer"><span class="${g.yourTurn ? 'turn-label' : ''}">${g.check ? 'Check · ' : ''}${g.yourTurn ? 'Your move' : 'Waiting for a move'}</span>${g.yourTurn ? `<button class="text-button" data-game-action="options" aria-label="Game options">${g.drawOffer === 'opponent' ? 'Draw offered · ' : ''}•••</button>` : `<span>Move ${Math.floor(g.state.ply / 2) + 1}</span>`}</div>`;282
return `<article class="game-card ${!g.yourTurn && g.status === 'active' ? 'waiting' : ''}" data-game="${g.id}" aria-label="Game with ${esc(g.opponent)}"><div class="card-header">${avatarMarkup(g.opponent, g.opponentAvatar)}<div class="opponent-info"><strong><button class="opponent-name" data-opponent="${esc(g.opponentId)}">${esc(g.opponent)}</button> <small class="rating" aria-label="${g.opponentRating} Elo">${g.opponentRating}</small></strong>${g.status !== 'pending' ? materialBar(g) : ''}</div>${g.status !== 'pending' ? colorTagMarkup(g) : ''}${g.inactiveDays >= 7 ? '<button class="stop-inactive" data-game-action="stop-confirm" aria-label="Stop inactive game" title="Stop inactive game">×</button>' : ''}</div>${content}</article>`;282
return `<article class="game-card ${!g.yourTurn && g.status === 'active' ? 'waiting' : ''}" data-game="${g.id}" aria-label="Game with ${esc(g.opponent)}"><div class="card-header">${avatarMarkup(g.opponent, g.opponentAvatar)}<div class="opponent-info"><strong><button class="opponent-name" data-opponent="${esc(g.opponentId)}">${esc(g.opponent)}</button> <small class="rating" aria-label="${g.opponentRating} Elo">${g.opponentRating}</small></strong>${g.status !== 'pending' ? materialBar(g) : ''}</div>${g.status !== 'pending' ? colorTagMarkup(g) : ''}${g.inactiveDays >= 7 ? '<button class="stop-inactive" data-game-action="stop-confirm" aria-label="Stop inactive game" title="Stop inactive game">×</button>' : ''}</div>${content}</article>`;283
}283
}284
const MATERIAL_BAR_FILL = {285
White: '#fffefb',286
Black: '#202823',287
Red: '#c62828',288
Blue: '#1565c0',289
Green: '#2e7d32',290
Yellow: '#f9a825'291
};292
function materialBarSkins (g)293
{294
if (customColoursDisabled()) return { left: 'White', right: 'Black' };295
return { left: g.pieceSkinWhite || 'White', right: g.pieceSkinBlack || 'Black' };296
}284
function materialBar (g)297
function materialBar (g)285
{298
{286
const totals = { w: 0, b: 0 };299
const totals = { w: 0, b: 0 };287
for (const p of g.state.board) if (p !== '.') totals[p === p.toUpperCase() ? 'w' : 'b'] += materialValues[p.toLowerCase()];300
for (const p of g.state.board) if (p !== '.') totals[p === p.toUpperCase() ? 'w' : 'b'] += materialValues[p.toLowerCase()];288
const total = totals.w + totals.b, share = total ? totals.w / total : .5;301
const total = totals.w + totals.b, share = total ? totals.w / total : .5;289
const label = `White: ${totals.w} material points. Black: ${totals.b} material points. You play ${g.color === 'w' ? 'White' : 'Black'}.`;302
const { left, right } = materialBarSkins(g);290
return `<div class="material-bar" data-share="${share}" role="meter" aria-label="Material balance, White on the left and Black on the right" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${Math.round(share * 100)}" aria-valuetext="${esc(label)}" title="${esc(label)} Pawn 1 · Knight/Bishop 3 · Rook 5 · Queen 9. Kings are not counted." tabindex="0"><span class="material-white"></span></div>`;303
const leftFill = MATERIAL_BAR_FILL[left] || MATERIAL_BAR_FILL.White;304
const rightFill = MATERIAL_BAR_FILL[right] || MATERIAL_BAR_FILL.Black;305
const you = g.color === 'w' ? left : right;306
const label = `${left}: ${totals.w} material points. ${right}: ${totals.b} material points. You play ${you}${you === 'White' || you === 'Black' ? '' : ` (${g.color === 'w' ? 'White' : 'Black'})`}.`;307
const ariaSides = left === 'White' && right === 'Black'308
? 'White on the left and Black on the right'309
: `${left} (White) on the left and ${right} (Black) on the right`;310
return `<div class="material-bar" data-share="${share}" style="--material-left:${leftFill};--material-right:${rightFill}" role="meter" aria-label="Material balance, ${esc(ariaSides)}" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${Math.round(share * 100)}" aria-valuetext="${esc(label)}" title="${esc(label)} Pawn 1 · Knight/Bishop 3 · Rook 5 · Queen 9. Kings are not counted." tabindex="0"><span class="material-white"></span></div>`;291
}311
}292
function renderMoveFeedback (now, reduced)312
function renderMoveFeedback (now, reduced)293
{313
{