cm-chessboard 3.17.4 → 3.17.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/favicon.ico CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "3.17.4",
3
+ "version": "3.17.6",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -39,6 +39,14 @@ export const piecesTranslations = {
39
39
  }
40
40
  }
41
41
 
42
+ export function renderPieceTitle(lang, name, color = undefined) {
43
+ let title = piecesTranslations[lang].pieces_long[name]
44
+ if(color) {
45
+ title += " " + piecesTranslations[lang].colors_long[color]
46
+ }
47
+ return title
48
+ }
49
+
42
50
  export const SQUARE_COORDINATES = [
43
51
  "a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1",
44
52
  "a2", "b2", "c2", "d2", "e2", "f2", "g2", "h2",
@@ -3,7 +3,7 @@
3
3
  * Repository: https://github.com/shaack/cm-chessboard
4
4
  * License: MIT, see file 'LICENSE'
5
5
  */
6
- import {ChessboardView} from "./ChessboardView.js"
6
+ import {ChessboardView, renderPieceTitle} from "./ChessboardView.js"
7
7
  import {COLOR} from "./Chessboard.js"
8
8
  import {piecesTranslations} from "./ChessboardView.js"
9
9
 
@@ -54,9 +54,9 @@ export class ChessboardViewAccessible extends ChessboardView {
54
54
  let listB = ""
55
55
  for (const piece of pieces) {
56
56
  if (piece.color === "w") {
57
- listW += `<li class="list-inline-item">${this.t.pieces_long[piece.name]} ${piece.position}</li>`
57
+ listW += `<li class="list-inline-item">${renderPieceTitle(this.lang, piece.name)} ${piece.position}</li>`
58
58
  } else {
59
- listB += `<li class="list-inline-item">${this.t.pieces_long[piece.name]} ${piece.position}</li>`
59
+ listB += `<li class="list-inline-item">${renderPieceTitle(this.lang, piece.name)} ${piece.position}</li>`
60
60
  }
61
61
  }
62
62
  count++
@@ -89,7 +89,7 @@ export class ChessboardViewAccessible extends ChessboardView {
89
89
  if(pieceCode) {
90
90
  color = pieceCode.charAt(0)
91
91
  name = pieceCode.charAt(1)
92
- html += `<td>${this.t.pieces_long[name]} ${this.t.colors_long[color]}</td>`
92
+ html += `<td>${renderPieceTitle(this.lang, name, color)}</td>`
93
93
  } else {
94
94
  html += `<td></td>`
95
95
  }