improve word-splitting in history list, and don't show lone pawns
This commit is contained in:
parent
bd450b3322
commit
b9de793ce8
12
js/chess.js
12
js/chess.js
|
|
@ -354,14 +354,19 @@ function renderHistory(board) {
|
|||
board = board['prior'];
|
||||
}
|
||||
|
||||
const NBSP = '\u00a0'; /* non-breaking space */
|
||||
const SHY = '\u00ad' /* soft hyphen */
|
||||
const ZWSP = '\u200b'; /* zero-width space */
|
||||
|
||||
var result = '';
|
||||
var n = 0;
|
||||
|
||||
while (list.length > 0) {
|
||||
const move = list.pop();
|
||||
if (move['from'] === 'phantom') {
|
||||
const piece = move['type'] === 'p' ? '' : move['type'].toUpperCase();
|
||||
const took = move['took'] ? 'x' : '';
|
||||
result += '*' + move['type'].toUpperCase() + took + move['to'];
|
||||
result += SHY + '*' + piece + took + move['to'];
|
||||
} else {
|
||||
if (n > 0 || move['side'] === 'dark') {
|
||||
result += ' ';
|
||||
|
|
@ -369,7 +374,7 @@ function renderHistory(board) {
|
|||
|
||||
if (move['side'] === 'light') {
|
||||
++n;
|
||||
result += String(n) + '. ';
|
||||
result += String(n) + '.' + NBSP;
|
||||
}
|
||||
|
||||
if (move['pass']) {
|
||||
|
|
@ -385,8 +390,9 @@ function renderHistory(board) {
|
|||
} else if (move['queen_castle']) {
|
||||
result += 'O-O-O';
|
||||
} else {
|
||||
const piece = move['type'] === 'p' ? '' : move['type'].toUpperCase();
|
||||
const took = move['took'] ? 'x' : '';
|
||||
result += move['type'].toUpperCase() + move['from'] + took + move['to'];
|
||||
result += piece + move['from'] + took + move['to'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue