From 67daeba99e863b71f9852364b8fcbc135eefbf18 Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Sat, 14 Mar 2020 13:07:10 -0500 Subject: [PATCH] use plain identifiers to initialize objects rather than strings --- js/chess.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/js/chess.js b/js/chess.js index d4a5f52..5e6881a 100644 --- a/js/chess.js +++ b/js/chess.js @@ -8,7 +8,7 @@ var gun = Gun({ let initialBoard = (function (){ var init = JSON.stringify({ - 'light': [ + light: [ 'rnbqkbnr', 'pppppppp', ' ', @@ -18,7 +18,7 @@ let initialBoard = (function (){ ' ', ' ', ], - 'dark': [ + dark: [ ' ', ' ', ' ', @@ -28,8 +28,8 @@ let initialBoard = (function (){ 'pppppppp', 'rnbqkbnr', ], - 'player': 'light', - 'timestamp': new Date().getTime(), + player: 'light', + timestamp: new Date().getTime(), }); return function (){ return JSON.parse(init); } })(); @@ -274,10 +274,10 @@ function movePiece(priorBoard, side, from, to){ board.timestamp = new Date().getTime(); board.move = { - 'side': normalizeSide(side), - 'type': type, - 'from': from, - 'to': to + side: normalizeSide(side), + type: type, + from: from, + to: to }; if (took !== ' ') { board.move.took = took; @@ -340,7 +340,7 @@ function movePiece(priorBoard, side, from, to){ if (replaced === ' ') { board.player = otherSide(board.player); } else { - board.phantom = { 'from': to, 'type': replaced + side[0] }; + board.phantom = { from: to, type: replaced + side[0] }; } return board; @@ -434,7 +434,7 @@ function placePiece(where, type, count){ var piece = $($('#' + piece_id)[0] || $('#cb_piece_' + type + ' img').clone()); piece.attr('style', ''); piece.attr('id', piece_id); - piece.data({ 'type': type, 'location': where }); + piece.data({ type: type, location: where }); piece.appendTo('#cb_' + where); piece.draggable({ disabled: true, @@ -561,7 +561,7 @@ function putState(board){ var game = gun.get(PacoSakoUUID).get('games').get(gameId); var state = JSON.stringify(board); $('#cb_board').data('skip_notify', state); - game.put({ 'board': state }); + game.put({ board: state }); putMeta(); } @@ -573,12 +573,12 @@ function putMeta(){ var meta = gun.get(PacoSakoUUID).get('meta').get(gameId); var stat = (board.move && board.move.took === 'k') ? 'mate' : null; meta.put({ - 'gameId': gameId, - 'lightName': lightName, - 'darkName': darkName, - 'moves': countMoves(board), - 'timestamp': board.timestamp || new Date().getTime(), - 'status': stat, + gameId: gameId, + lightName: lightName, + darkName: darkName, + moves: countMoves(board), + timestamp: board.timestamp || new Date().getTime(), + status: stat, }); } @@ -799,7 +799,7 @@ $(function (){ if (!board.phantom) { var newBoard = cloneJSON(board); newBoard.prior = board; - newBoard.move = { 'side': board.player, 'pass': true }; + newBoard.move = { side: board.player, pass: true }; newBoard.player = otherSide(board.player); newBoard.timestamp = new Date().getTime(); putState(newBoard);