cm-chessboard 7.7.8 → 7.7.10
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/index.html +4 -1
- package/package.json +1 -1
- package/src/lib/Svg.js +6 -2
package/index.html
CHANGED
|
@@ -48,8 +48,11 @@ It works, it is cool and it is easy to use. 👍</p>
|
|
|
48
48
|
const interval = setInterval(() => {
|
|
49
49
|
makeRandomMove()
|
|
50
50
|
board.setPosition(chess.fen(), true)
|
|
51
|
-
},
|
|
51
|
+
}, 500)
|
|
52
52
|
function makeRandomMove() {
|
|
53
|
+
if(chess.game_over()) {
|
|
54
|
+
chess.reset()
|
|
55
|
+
}
|
|
53
56
|
const possibleMoves = chess.moves()
|
|
54
57
|
if (possibleMoves.length === 0) {
|
|
55
58
|
clearInterval(interval)
|
package/package.json
CHANGED
package/src/lib/Svg.js
CHANGED
|
@@ -24,7 +24,7 @@ export class Svg {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Add an Element to
|
|
27
|
+
* Add an Element to an SVG DOM
|
|
28
28
|
* @param parent
|
|
29
29
|
* @param name
|
|
30
30
|
* @param attributes
|
|
@@ -50,10 +50,14 @@ export class Svg {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* Remove an
|
|
53
|
+
* Remove an element from an SVG DOM
|
|
54
54
|
* @param element
|
|
55
55
|
*/
|
|
56
56
|
static removeElement(element) {
|
|
57
|
+
if(!element) {
|
|
58
|
+
console.warn("removeElement, element is", element)
|
|
59
|
+
return
|
|
60
|
+
}
|
|
57
61
|
if (element.parentNode) {
|
|
58
62
|
element.parentNode.removeChild(element)
|
|
59
63
|
} else {
|