return fen;
}
-window['ChessBoard'] = window['ChessBoard'] || function(containerElOrId, cfg) {
+/** @struct */
+var cfg;
+
+/** @constructor */
+window.ChessBoard = function(containerElOrId, cfg) {
'use strict';
cfg = cfg || {};
// and simplify selectors
var CSS = {
alpha: 'alpha-d2270',
- black: 'black-3c85d',
board: 'board-b72b1',
chessboard: 'chessboard-63f37',
clearfix: 'clearfix-7da63',
sparePieces: 'spare-pieces-7492f',
sparePiecesBottom: 'spare-pieces-bottom-ae20f',
sparePiecesTop: 'spare-pieces-top-4028b',
- square: 'square-55d63',
- white: 'white-1e1d7'
+ square: 'square-55d63'
};
+var CSSColor = {};
+CSSColor['white'] = 'white-1e1d7';
+CSSColor['black'] = 'black-3c85d';
//------------------------------------------------------------------------------
// Module Scope Variables
// Validation / Errors
//------------------------------------------------------------------------------
+/**
+ * @param {!number} code
+ * @param {!string} msg
+ * @param {Object=} obj
+ */
function error(code, msg, obj) {
// do nothing if showErrors is not set
if (cfg.hasOwnProperty('showErrors') !== true ||
/*
var buildSquare = function(color, size, id) {
- var html = '<div class="' + CSS.square + ' ' + CSS[color] + '" ' +
+ var html = '<div class="' + CSS.square + ' ' + CSSColor[color] + '" ' +
'style="width: ' + size + 'px; height: ' + size + 'px" ' +
'id="' + id + '">';
for (var j = 0; j < 8; j++) {
var square = alpha[j] + row;
- html += '<div class="' + CSS.square + ' ' + CSS[squareColor] + ' ' +
+ html += '<div class="' + CSS.square + ' ' + CSSColor[squareColor] + ' ' +
'square-' + square + '" ' +
'style="width: ' + SQUARE_SIZE + 'px; height: ' + SQUARE_SIZE + 'px" ' +
'id="' + SQUARE_ELS_IDS[square] + '" ' +
return '';
}
+/**
+ * @param {!string} piece
+ * @param {boolean=} hidden
+ * @param {!string=} id
+ */
function buildPiece(piece, hidden, id) {
var html = '<img src="' + buildPieceImgSrc(piece) + '" ';
if (id && typeof id === 'string') {
error(5482, 'Invalid value passed to the orientation method.', arg);
};
+/**
+ * @param {!string|!Object} position
+ * @param {boolean=} useAnimation
+ */
widget.position = function(position, useAnimation) {
// no arguments, return the current position
if (arguments.length === 0) {