diff --git a/data/releases.json b/data/releases.json index dbcec679..1b9f5933 100644 --- a/data/releases.json +++ b/data/releases.json @@ -1,53 +1,53 @@ -[ -"-----------------------------------------------------------------", -{ - "released":false, - "version":"0.3.1", - "date":"10 Aug 2013", - "changes":[ - "Orientation methods now return current orientation (GitHub Issue #64)" - ], - "files":[ - { "name":"chessboardjs-0.3.1.zip", "size":"44.6 KB" } - ] -}, -"-----------------------------------------------------------------", -{ - "version":"0.3.0", - "date":"10 Aug 2013", - "changes":[ - "Added appearSpeed animation config", - "Added onSnapbackEnd event", - "Added onMoveEnd event" - ], - "files":[ - { "name":"chessboardjs-0.3.0.zip", "size":"44.6 KB" } - ] -}, -"-----------------------------------------------------------------", -{ - "version":"0.2.0", - "date":"05 Aug 2013", - "changes":[ - "Added onMouseoverSquare and onMouseoutSquare events", - "Added onSnapEnd event", - "Added square code as CSS class on the squares", - "chess.js integration examples" - ], - "files":[ - { "name":"chessboardjs-0.2.0.zip", "size":"44.6 KB" } - ] -}, -"-----------------------------------------------------------------", -{ - "version":"0.1.0", - "date":"21 Jul 2013", - "changes":[ - "Initial release" - ], - "files":[ - { "name":"chessboard-0.1.0.zip", "size":"44.0 KB" } - ] -}, -"-----------------------------------------------------------------" +[ +"-----------------------------------------------------------------", +{ + "released":false, + "version":"0.3.1", + "date":"10 Aug 2013", + "changes":[ + "Orientation methods now return current orientation (GitHub Issue #64)" + ], + "files":[ + { "name":"chessboardjs-0.3.1.zip", "size":"44.6 KB" } + ] +}, +"-----------------------------------------------------------------", +{ + "version":"0.3.0", + "date":"10 Aug 2013", + "changes":[ + "Added appearSpeed animation config", + "Added onSnapbackEnd event", + "Added onMoveEnd event" + ], + "files":[ + { "name":"chessboardjs-0.3.0.zip", "size":"44.6 KB" } + ] +}, +"-----------------------------------------------------------------", +{ + "version":"0.2.0", + "date":"05 Aug 2013", + "changes":[ + "Added onMouseoverSquare and onMouseoutSquare events", + "Added onSnapEnd event", + "Added square code as CSS class on the squares", + "chess.js integration examples" + ], + "files":[ + { "name":"chessboardjs-0.2.0.zip", "size":"44.6 KB" } + ] +}, +"-----------------------------------------------------------------", +{ + "version":"0.1.0", + "date":"21 Jul 2013", + "changes":[ + "Initial release" + ], + "files":[ + { "name":"chessboard-0.1.0.zip", "size":"44.0 KB" } + ] +}, +"-----------------------------------------------------------------" ] \ No newline at end of file diff --git a/examples/1000-empty-board.example b/examples/1000-empty-board.example index b065604c..19c7f32c 100644 --- a/examples/1000-empty-board.example +++ b/examples/1000-empty-board.example @@ -2,13 +2,13 @@ 1000 ===== Name -Empty Board - +Empty Board + ===== Description Chessboard.js initializes to an empty board with no second argument. - + ===== HTML
- + ===== JS var board = Chessboard('myBoard') diff --git a/examples/1001-start-position.example b/examples/1001-start-position.example index d95b132b..d1ac9cee 100644 --- a/examples/1001-start-position.example +++ b/examples/1001-start-position.example @@ -1,15 +1,15 @@ ===== id 1001 -===== Name -Start Position - +===== Name +Start Position + ===== Description Pass'start' as the second argument to initialize
the board to the start position.
-
+
===== HTML
-
+
===== JS
var board = Chessboard('myBoard', 'start')
diff --git a/examples/1002-fen.example b/examples/1002-fen.example
index fa7718a2..a3776e05 100644
--- a/examples/1002-fen.example
+++ b/examples/1002-fen.example
@@ -1,16 +1,16 @@
===== id
1002
-===== Name
-FEN String
-
+===== Name
+FEN String
+
===== Description
Pass a FEN String as the second argument to
initialize the board to a specific position.
-
+
===== HTML
-
+
===== JS
var ruyLopez = 'r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R'
var board = Chessboard('myBoard', ruyLopez)
diff --git a/examples/1003-position-object.example b/examples/1003-position-object.example
index 6bfa237e..f5926f03 100644
--- a/examples/1003-position-object.example
+++ b/examples/1003-position-object.example
@@ -1,16 +1,16 @@
===== id
1003
-===== Name
-Position Object
-
-===== Description
-Pass a Position Object as the second argument to initialize the board to a specific position.
-
-===== HTML
-
-
-===== JS
+===== Name
+Position Object
+
+===== Description
+Pass a Position Object as the second argument to initialize the board to a specific position.
+
+===== HTML
+
+
+===== JS
var position = {
d6: 'bK',
d4: 'wP',
diff --git a/examples/1004-multiple-boards.example b/examples/1004-multiple-boards.example
index 54c45e6d..88e7ddd3 100644
--- a/examples/1004-multiple-boards.example
+++ b/examples/1004-multiple-boards.example
@@ -1,25 +1,25 @@
===== id
1004
-===== Name
-Multiple Boards
-
-===== Description
-You can have multiple boards on the same page.
-
+===== Name
+Multiple Boards
+
+===== Description
+You can have multiple boards on the same page.
+
===== CSS
.small-board {
display: inline-block;
margin-right: 5px;
width: 200px;
}
-
+
===== HTML
-
-===== JS
+
+===== JS
var board1 = Chessboard('board1', {
position: 'start',
showNotation: false
diff --git a/examples/2000-config-position.example b/examples/2000-config-position.example
index ed5ba568..81e0d661 100644
--- a/examples/2000-config-position.example
+++ b/examples/2000-config-position.example
@@ -1,17 +1,17 @@
===== id
2000
-===== Name
-Start Position
-
-===== Description
-Set the position property to 'start' to initialize the board to the start position.
-
-===== HTML
-
-
-===== JS
-var config = {
- position: 'start'
+===== Name
+Start Position
+
+===== Description
+Set the position property to 'start' to initialize the board to the start position.
+
+===== HTML
+
+
+===== JS
+var config = {
+ position: 'start'
}
-var board = Chessboard('myBoard', config)
+var board = Chessboard('myBoard', config)
diff --git a/examples/2001-config-orientation.example b/examples/2001-config-orientation.example
index 1ce4048b..e8ec9cdc 100644
--- a/examples/2001-config-orientation.example
+++ b/examples/2001-config-orientation.example
@@ -1,18 +1,18 @@
===== id
2001
-===== Name
-Orientation
-
-===== Description
-Use the orientation property to set board orientation.
-
-===== HTML
-
-
-===== JS
-var config = {
- orientation: 'black',
- position: 'start'
+===== Name
+Orientation
+
+===== Description
+Use the orientation property to set board orientation.
+
+===== HTML
+
+
+===== JS
+var config = {
+ orientation: 'black',
+ position: 'start'
}
-var board = Chessboard('myBoard', config)
+var board = Chessboard('myBoard', config)
diff --git a/examples/2002-config-notation.example b/examples/2002-config-notation.example
index a4585bed..c188ce44 100644
--- a/examples/2002-config-notation.example
+++ b/examples/2002-config-notation.example
@@ -1,18 +1,18 @@
===== id
2002
-===== Name
-Notation
-
-===== Description
-Use the showNotation property to turn board notation on or off.
-
-===== HTML
-
-
-===== JS
-var config = {
- showNotation: false,
- position: 'start'
+===== Name
+Notation
+
+===== Description
+Use the showNotation property to turn board notation on or off.
+
+===== HTML
+
+
+===== JS
+var config = {
+ showNotation: false,
+ position: 'start'
}
-var board = Chessboard('myBoard', config)
+var board = Chessboard('myBoard', config)
diff --git a/examples/2003-draggable-snapback.example b/examples/2003-draggable-snapback.example
index 194e8580..71ffedb9 100644
--- a/examples/2003-draggable-snapback.example
+++ b/examples/2003-draggable-snapback.example
@@ -1,19 +1,19 @@
===== id
2003
-===== Name
-Draggable Snapback
-
-===== Description
-Set draggable to true to allow drag and drop of pieces. Pieces will return to their original square when dropped off the board (ie: the default for dropOffBoard is 'snapback').
-
-===== HTML
-
-
-===== JS
-var config = {
- draggable: true,
- dropOffBoard: 'snapback', // this is the default
- position: 'start'
+===== Name
+Draggable Snapback
+
+===== Description
+Set draggable to true to allow drag and drop of pieces. Pieces will return to their original square when dropped off the board (ie: the default for dropOffBoard is 'snapback').
+
+===== HTML
+
+
+===== JS
+var config = {
+ draggable: true,
+ dropOffBoard: 'snapback', // this is the default
+ position: 'start'
}
-var board = Chessboard('myBoard', config)
+var board = Chessboard('myBoard', config)
diff --git a/examples/3000-get-position.example b/examples/3000-get-position.example
index 6aadc63d..eecf76fe 100644
--- a/examples/3000-get-position.example
+++ b/examples/3000-get-position.example
@@ -1,17 +1,17 @@
===== id
3000
-===== Name
-Get Position
-
-===== Description
-Use the position and fen methods to retrieve the current position of the board.
-
-===== HTML
-
+===== Name
+Get Position
+
+===== Description
+Use the position and fen methods to retrieve the current position of the board.
+
+===== HTML
+
-
-===== JS
+
+===== JS
var config = {
draggable: true,
position: 'start'
diff --git a/examples/3001-set-position.example b/examples/3001-set-position.example
index e999f107..3194466b 100644
--- a/examples/3001-set-position.example
+++ b/examples/3001-set-position.example
@@ -1,19 +1,19 @@
===== id
3001
-===== Name
-Set Position
-
-===== Description
-Use the start and position methods to set the board position.
-
-===== HTML
-
+===== Name
+Set Position
+
+===== Description
+Use the start and position methods to set the board position.
+
+===== HTML
+
-
-===== JS
+
+===== JS
var board = Chessboard('myBoard')
$('#setRuyLopezBtn').on('click', function () {
diff --git a/examples/3002-set-position-instant.example b/examples/3002-set-position-instant.example
index 08e5ad15..283e4d44 100644
--- a/examples/3002-set-position-instant.example
+++ b/examples/3002-set-position-instant.example
@@ -1,19 +1,19 @@
===== id
3002
-===== Name
-Set Position Instantly
-
-===== Description
-Pass false as the second argument to the start and position methods to set the board position instantly.
-
-===== HTML
-
+===== Name
+Set Position Instantly
+
+===== Description
+Pass false as the second argument to the start and position methods to set the board position instantly.
+
+===== HTML
+
-
-===== JS
+
+===== JS
var board = Chessboard('myBoard')
$('#setRuyLopezBtn').on('click', function () {
diff --git a/examples/3003-clear.example b/examples/3003-clear.example
index d1243b68..2effbb08 100644
--- a/examples/3003-clear.example
+++ b/examples/3003-clear.example
@@ -1,19 +1,19 @@
===== id
3003
-===== Name
-Clear Board
-
-===== Description
-Use the clear method to remove all the pieces from the board.
-
-===== HTML
-
+===== Name
+Clear Board
+
+===== Description
+Use the clear method to remove all the pieces from the board.
+
+===== HTML
+
-
-===== JS
+
+===== JS
var board = Chessboard('myBoard', 'start')
$('#clearBoardBtn').on('click', board.clear)
diff --git a/examples/3004-move-pieces.example b/examples/3004-move-pieces.example
index c380527d..89956e59 100644
--- a/examples/3004-move-pieces.example
+++ b/examples/3004-move-pieces.example
@@ -1,19 +1,19 @@
===== id
3004
-===== Name
-Move Pieces
-
-===== Description
-Use the move method to make one or more moves on the board.
-
-===== HTML
-
+===== Name
+Move Pieces
+
+===== Description
+Use the move method to make one or more moves on the board.
+
+===== HTML
+
-===== JS
+===== JS
var board = Chessboard('myBoard', 'start')
$('#move1Btn').on('click', function () {
diff --git a/examples/3005-orientation.example b/examples/3005-orientation.example
index b3221564..a64101f2 100644
--- a/examples/3005-orientation.example
+++ b/examples/3005-orientation.example
@@ -1,21 +1,21 @@
===== id
3005
-===== Name
-Orientation
-
-===== Description
-Use the orientation method to retrieve and set the orientation. Use the flip method to flip orientation.
-
-===== HTML
-
+===== Name
+Orientation
+
+===== Description
+Use the orientation method to retrieve and set the orientation. Use the flip method to flip orientation.
+
+===== HTML
+
onChange event fires when the board position changes.
-
-===== HTML
+
+===== HTML
-===== JS
+===== JS
function onChange (oldPos, newPos) {
console.log('Position changed:')
console.log('Old position: ' + Chessboard.objToFen(oldPos))
diff --git a/examples/5004-piece-highlight1.example b/examples/5004-piece-highlight1.example
index 5195335f..2536f59f 100644
--- a/examples/5004-piece-highlight1.example
+++ b/examples/5004-piece-highlight1.example
@@ -1,23 +1,23 @@
===== id
5004
-===== Name
-Piece Highlighting 1
-
-===== Description
-Use CSS to show piece highlighting.
-
-===== HTML
-
-
-
+
+
===== JS
// NOTE: this example uses the chess.js library:
// https://github.com/jhlywa/chess.js
diff --git a/lib/chessboard.css b/lib/chessboard.css
index 27ffdccb..2add196e 100644
--- a/lib/chessboard.css
+++ b/lib/chessboard.css
@@ -1,54 +1,54 @@
/*! chessboard.js v@VERSION | (c) 2019 Chris Oakman | MIT License chessboardjs.com/license */
-
+
.clearfix-7da63 {
- clear: both;
-}
-
+ clear: both;
+}
+
.board-b72b1 {
border: 2px solid #404040;
box-sizing: content-box;
-}
-
+}
+
.square-55d63 {
- float: left;
- position: relative;
-
- /* disable any native browser highlighting */
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
-}
-
+ float: left;
+ position: relative;
+
+ /* disable any native browser highlighting */
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+
.white-1e1d7 {
- background-color: #f0d9b5;
- color: #b58863;
-}
-
+ background-color: #f0d9b5;
+ color: #b58863;
+}
+
.black-3c85d {
- background-color: #b58863;
- color: #f0d9b5;
-}
+ background-color: #b58863;
+ color: #f0d9b5;
+}
.highlight1-32417, .highlight2-9c5d2 {
- box-shadow: inset 0 0 3px 3px yellow;
-}
+ box-shadow: inset 0 0 3px 3px yellow;
+}
-.notation-322f9 {
- cursor: default;
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
- font-size: 14px;
- position: absolute;
+.notation-322f9 {
+ cursor: default;
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 14px;
+ position: absolute;
}
-.alpha-d2270 {
- bottom: 1px;
- right: 3px;
+.alpha-d2270 {
+ bottom: 1px;
+ right: 3px;
}
-.numeric-fc462 {
- top: 2px;
- left: 2px;
+.numeric-fc462 {
+ top: 2px;
+ left: 2px;
}
diff --git a/lib/chessboard.js b/lib/chessboard.js
index ed27db18..47ccf3f0 100644
--- a/lib/chessboard.js
+++ b/lib/chessboard.js
@@ -4,9 +4,9 @@
// Copyright (c) 2019, Chris Oakman
// Released under the MIT license
// https://github.com/oakmac/chessboardjs/blob/master/LICENSE.md
-
-// start anonymous scope
-;(function () {
+
+// start anonymous scope
+;(function () {
'use strict'
var $ = window['jQuery']
@@ -179,20 +179,20 @@
rate >= 1
}
- function validMove (move) {
- // move should be a string
+ function validMove (move) {
+ // move should be a string
if (!isString(move)) return false
-
- // move should be in the form of "e2-e4", "f6-d5"
+
+ // move should be in the form of "e2-e4", "f6-d5"
var squares = move.split('-')
if (squares.length !== 2) return false
-
+
return validSquare(squares[0]) && validSquare(squares[1])
- }
-
+ }
+
function validSquare (square) {
return isString(square) && square.search(/^[a-h][1-8]$/) !== -1
- }
+ }
if (RUN_ASSERTS) {
console.assert(validSquare('a1'))
@@ -207,7 +207,7 @@
function validPieceCode (code) {
return isString(code) && code.search(/^[bw][KQRNBP]$/) !== -1
- }
+ }
if (RUN_ASSERTS) {
console.assert(validPieceCode('bP'))
@@ -224,28 +224,28 @@
function validFen (fen) {
if (!isString(fen)) return false
-
- // cut off any move, castling, etc info from the end
- // we're only interested in position information
- fen = fen.replace(/ .+$/, '')
+
+ // cut off any move, castling, etc info from the end
+ // we're only interested in position information
+ fen = fen.replace(/ .+$/, '')
// expand the empty square numbers to just 1s
fen = expandFenEmptySquares(fen)
- // FEN should be 8 sections separated by slashes
- var chunks = fen.split('/')
+ // FEN should be 8 sections separated by slashes
+ var chunks = fen.split('/')
if (chunks.length !== 8) return false
// check each section
for (var i = 0; i < 8; i++) {
if (chunks[i].length !== 8 ||
chunks[i].search(/[^kqrnbpKQRNBP1]/) !== -1) {
- return false
- }
- }
-
- return true
- }
+ return false
+ }
+ }
+
+ return true
+ }
if (RUN_ASSERTS) {
console.assert(validFen(START_FEN))
@@ -263,17 +263,17 @@
function validPositionObject (pos) {
if (!$.isPlainObject(pos)) return false
-
- for (var i in pos) {
- if (!pos.hasOwnProperty(i)) continue
-
- if (!validSquare(i) || !validPieceCode(pos[i])) {
- return false
- }
- }
-
- return true
- }
+
+ for (var i in pos) {
+ if (!pos.hasOwnProperty(i)) continue
+
+ if (!validSquare(i) || !validPieceCode(pos[i])) {
+ return false
+ }
+ }
+
+ return true
+ }
if (RUN_ASSERTS) {
console.assert(validPositionObject(START_POSITION))
@@ -326,76 +326,76 @@
return pieceCodeLetters[1].toLowerCase()
}
- // convert FEN string to position object
- // returns false if the FEN string is invalid
- function fenToObj (fen) {
+ // convert FEN string to position object
+ // returns false if the FEN string is invalid
+ function fenToObj (fen) {
if (!validFen(fen)) return false
-
- // cut off any move, castling, etc info from the end
- // we're only interested in position information
- fen = fen.replace(/ .+$/, '')
-
- var rows = fen.split('/')
- var position = {}
-
- var currentRow = 8
- for (var i = 0; i < 8; i++) {
- var row = rows[i].split('')
+
+ // cut off any move, castling, etc info from the end
+ // we're only interested in position information
+ fen = fen.replace(/ .+$/, '')
+
+ var rows = fen.split('/')
+ var position = {}
+
+ var currentRow = 8
+ for (var i = 0; i < 8; i++) {
+ var row = rows[i].split('')
var colIdx = 0
-
- // loop through each character in the FEN section
- for (var j = 0; j < row.length; j++) {
- // number / empty squares
- if (row[j].search(/[1-8]/) !== -1) {
+
+ // loop through each character in the FEN section
+ for (var j = 0; j < row.length; j++) {
+ // number / empty squares
+ if (row[j].search(/[1-8]/) !== -1) {
var numEmptySquares = parseInt(row[j], 10)
colIdx = colIdx + numEmptySquares
} else {
- // piece
+ // piece
var square = COLUMNS[colIdx] + currentRow
- position[square] = fenToPieceCode(row[j])
+ position[square] = fenToPieceCode(row[j])
colIdx = colIdx + 1
- }
- }
+ }
+ }
currentRow = currentRow - 1
- }
-
- return position
+ }
+
+ return position
}
- // position object to FEN string
- // returns false if the obj is not a valid position object
- function objToFen (obj) {
+ // position object to FEN string
+ // returns false if the obj is not a valid position object
+ function objToFen (obj) {
if (!validPositionObject(obj)) return false
-
- var fen = ''
-
- var currentRow = 8
- for (var i = 0; i < 8; i++) {
- for (var j = 0; j < 8; j++) {
- var square = COLUMNS[j] + currentRow
-
- // piece exists
+
+ var fen = ''
+
+ var currentRow = 8
+ for (var i = 0; i < 8; i++) {
+ for (var j = 0; j < 8; j++) {
+ var square = COLUMNS[j] + currentRow
+
+ // piece exists
if (obj.hasOwnProperty(square)) {
fen = fen + pieceCodeToFen(obj[square])
- } else {
- // empty space
+ } else {
+ // empty space
fen = fen + '1'
- }
- }
-
+ }
+ }
+
if (i !== 7) {
fen = fen + '/'
}
-
+
currentRow = currentRow - 1
- }
-
+ }
+
// squeeze the empty numbers together
fen = squeezeFenEmptySquares(fen)
- return fen
- }
+ return fen
+ }
if (RUN_ASSERTS) {
console.assert(objToFen(START_POSITION) === START_FEN)
@@ -663,8 +663,8 @@
var $sparePiecesBottom = null
// constructor return object
- var widget = {}
-
+ var widget = {}
+
// -------------------------------------------------------------------------
// Stateful
// -------------------------------------------------------------------------
@@ -684,44 +684,44 @@
// -------------------------------------------------------------------------
// Validation / Errors
// -------------------------------------------------------------------------
-
- function error (code, msg, obj) {
- // do nothing if showErrors is not set
- if (
+
+ function error (code, msg, obj) {
+ // do nothing if showErrors is not set
+ if (
config.hasOwnProperty('showErrors') !== true ||
config.showErrors === false
- ) {
- return
- }
-
+ ) {
+ return
+ }
+
var errorText = 'Chessboard Error ' + code + ': ' + msg
-
- // print to console
- if (
+
+ // print to console
+ if (
config.showErrors === 'console' &&
- typeof console === 'object' &&
- typeof console.log === 'function'
- ) {
- console.log(errorText)
- if (arguments.length >= 2) {
- console.log(obj)
- }
- return
- }
-
- // alert errors
+ typeof console === 'object' &&
+ typeof console.log === 'function'
+ ) {
+ console.log(errorText)
+ if (arguments.length >= 2) {
+ console.log(obj)
+ }
+ return
+ }
+
+ // alert errors
if (config.showErrors === 'alert') {
- if (obj) {
- errorText += '\n\n' + JSON.stringify(obj)
- }
- window.alert(errorText)
- return
- }
-
+ if (obj) {
+ errorText += '\n\n' + JSON.stringify(obj)
+ }
+ window.alert(errorText)
+ return
+ }
+
// custom function
if (isFunction(config.showErrors)) {
config.showErrors(code, msg, obj)
- }
+ }
}
function setInitialState () {
@@ -748,50 +748,50 @@
// -------------------------------------------------------------------------
// DOM Misc
// -------------------------------------------------------------------------
-
+
// calculates square size based on the width of the container
// got a little CSS black magic here, so let me explain:
// get the width of the container element (could be anything), reduce by 1 for
// fudge factor, and then keep reducing until we find an exact mod 8 for
// our square size
- function calculateSquareSize () {
+ function calculateSquareSize () {
var containerWidth = parseInt($container.width(), 10)
-
+
// defensive, prevent infinite loop
if (!containerWidth || containerWidth <= 0) {
- return 0
- }
-
+ return 0
+ }
+
// pad one pixel
- var boardWidth = containerWidth - 1
-
+ var boardWidth = containerWidth - 1
+
while (boardWidth % 8 !== 0 && boardWidth > 0) {
boardWidth = boardWidth - 1
- }
-
- return boardWidth / 8
- }
-
+ }
+
+ return boardWidth / 8
+ }
+
// create random IDs for elements
function createElIds () {
// squares on the board
for (var i = 0; i < COLUMNS.length; i++) {
for (var j = 1; j <= 8; j++) {
- var square = COLUMNS[i] + j
+ var square = COLUMNS[i] + j
squareElsIds[square] = square + '-' + uuid()
- }
- }
-
+ }
+ }
+
// spare pieces
var pieces = 'KQRNBP'.split('')
for (i = 0; i < pieces.length; i++) {
- var whitePiece = 'w' + pieces[i]
- var blackPiece = 'b' + pieces[i]
+ var whitePiece = 'w' + pieces[i]
+ var blackPiece = 'b' + pieces[i]
sparePiecesElsIds[whitePiece] = whitePiece + '-' + uuid()
sparePiecesElsIds[blackPiece] = blackPiece + '-' + uuid()
- }
- }
-
+ }
+ }
+
// -------------------------------------------------------------------------
// Markup Building
// -------------------------------------------------------------------------
@@ -853,158 +853,158 @@
return interpolateTemplate(html, CSS)
}
-
- function buildPieceImgSrc (piece) {
+
+ function buildPieceImgSrc (piece) {
if (isFunction(config.pieceTheme)) {
return config.pieceTheme(piece)
- }
-
+ }
+
if (isString(config.pieceTheme)) {
return interpolateTemplate(config.pieceTheme, {piece: piece})
- }
-
+ }
+
// NOTE: this should never happen
error(8272, 'Unable to build image source for config.pieceTheme.')
- return ''
- }
-
+ return ''
+ }
+
function buildPieceHTML (piece, hidden, id) {
- var html = '