Skip to content

Commit

Permalink
lib: big bang cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zackschuster committed Oct 6, 2022
1 parent 29cf0b6 commit b0e00cb
Show file tree
Hide file tree
Showing 13 changed files with 307 additions and 329 deletions.
2 changes: 1 addition & 1 deletion examples/2005-animation-speed.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ const board = new Chessboard('myBoard', {
const ruyLopezFen = 'r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R';

document.getElementById('ruyLopezBtn')
.onclick = () => board.position(ruyLopezFen)
.onclick = () => board.setPosition(ruyLopezFen)
document.getElementById('startBtn')
.onclick = () => board.start()
4 changes: 2 additions & 2 deletions examples/3000-get-position.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ var board = new Chessboard('myBoard', config)

function clickShowPositionBtn () {
console.log('Current position as an Object:')
console.log(board.position())
console.log(board.position)

console.log('Current position as a FEN string:')
console.log(board.fen())
console.log(board.fen)
}

document.getElementById('showPositionBtn').onclick = (evt) => clickShowPositionBtn(evt)
4 changes: 2 additions & 2 deletions examples/3001-set-position.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ Use the <a href="docs.html#methods:start"><code class="js plain">start</code></a
===== JS
const board = new Chessboard('myBoard')

document.getElementById('setRuyLopezBtn').onclick = () => board.position('r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R')
document.getElementById('setRuyLopezBtn').onclick = () => board.setPosition('r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R')
document.getElementById('setStartBtn').onclick = () => board.start()
document.getElementById('setRookCheckmateBtn').onclick = () => board.position({ a4: 'bK', c4: 'wK', a7: 'wR' })
document.getElementById('setRookCheckmateBtn').onclick = () => board.setPosition({ a4: 'bK', c4: 'wK', a7: 'wR' })
4 changes: 2 additions & 2 deletions examples/3002-set-position-instant.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ Pass <code class="js keyword">false</code> as the second argument to the <a href
===== JS
const board = new Chessboard('myBoard')

document.getElementById('setRuyLopezBtn').onclick = () => board.position('r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R', false)
document.getElementById('setRuyLopezBtn').onclick = () => board.setPosition('r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R', false)
document.getElementById('setStartBtn').onclick = () => board.start(false)
document.getElementById('setRookCheckmateBtn').onclick = () => board.position({ a4: 'bK', c4: 'wK', a7: 'wR' }, false)
document.getElementById('setRookCheckmateBtn').onclick = () => board.setPosition({ a4: 'bK', c4: 'wK', a7: 'wR' }, false)
2 changes: 1 addition & 1 deletion examples/4000-onchange.example
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ const board = new Chessboard('myBoard', {
const ruyLopezFen = 'r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R';

document.getElementById('ruyLopezBtn')
.onclick = () => board.position(ruyLopezFen)
.onclick = () => board.setPosition(ruyLopezFen)
document.getElementById('startPositionBtn')
.onclick = () => board.start()
2 changes: 1 addition & 1 deletion examples/4012-onmoveend.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const board = new Chessboard('myBoard', {
const ruyLopezFen = 'r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R';

document.getElementById('ruyLopezBtn')
.onclick = () => board.position(ruyLopezFen)
.onclick = () => board.setPosition(ruyLopezFen)
document.getElementById('moveBtn')
.onclick = () => board.move('a2-a4', 'h7-h5')
document.getElementById('startBtn')
Expand Down
2 changes: 1 addition & 1 deletion examples/5000-legal-moves.example
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function onDrop (source, target) {
// update the board position after the piece snap
// for castling, en passant, pawn promotion
function onSnapEnd () {
board.position(game.fen())
board.setPosition(game.fen())
}

function updateStatus () {
Expand Down
4 changes: 2 additions & 2 deletions examples/5001-play-random-computer.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function makeRandomMove () {

var randomIdx = Math.floor(Math.random() * possibleMoves.length)
game.move(possibleMoves[randomIdx])
board.position(game.fen())
board.setPosition(game.fen())
}

function onDrop (source, target) {
Expand All @@ -54,7 +54,7 @@ function onDrop (source, target) {
// update the board position after the piece snap
// for castling, en passant, pawn promotion
function onSnapEnd () {
board.position(game.fen())
board.setPosition(game.fen())
}

var config = {
Expand Down
2 changes: 1 addition & 1 deletion examples/5002-random-vs-random.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function makeRandomMove () {

var randomIdx = Math.floor(Math.random() * possibleMoves.length)
game.move(possibleMoves[randomIdx])
board.position(game.fen())
board.setPosition(game.fen())

window.setTimeout(makeRandomMove, 500)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/5003-highlight-legal-moves.example
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function onMouseoutSquare (square, piece) {
}

function onSnapEnd () {
board.position(game.fen())
board.setPosition(game.fen())
}

var config = {
Expand Down
2 changes: 1 addition & 1 deletion examples/5004-piece-highlight1.example
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function makeRandomMove () {
}

game.move(possibleMoves[randomIdx].san)
board.position(game.fen())
board.setPosition(game.fen())

window.setTimeout(makeRandomMove, 1200)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/5005-piece-highlight2.example
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function makeRandomMove () {
squareToHighlight = move.to

// update the board to the new position
board.position(game.fen())
board.setPosition(game.fen())
}

function onDrop (source, target) {
Expand Down Expand Up @@ -90,7 +90,7 @@ function onMoveEnd () {
// update the board position after the piece snap
// for castling, en passant, pawn promotion
function onSnapEnd () {
board.position(game.fen())
board.setPosition(game.fen())
}

var config = {
Expand Down
Loading

0 comments on commit b0e00cb

Please sign in to comment.