diff --git a/js/chess.js b/js/chess.js index 5fa2132..187ce10 100644 --- a/js/chess.js +++ b/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']; } }