]> git.sesse.net Git - remoteglot/blobdiff - www/js/chessboard-0.3.0.js
Support a ding sound per move. Off by default, of course.
[remoteglot] / www / js / chessboard-0.3.0.js
index 8f1ac2d4ab61e1d1f2f1b179e0e50e484c09cf02..4b24ec04d5fe3a29845da396f9a1e8c10bb79d57 100644 (file)
@@ -185,7 +185,11 @@ function objToFen(obj) {
   return fen;
 }
 
-window['ChessBoard'] = window['ChessBoard'] || function(containerElOrId, cfg) {
+/** @struct */
+var cfg;
+
+/** @constructor */
+window.ChessBoard = function(containerElOrId, cfg) {
 'use strict';
 
 cfg = cfg || {};
@@ -202,7 +206,6 @@ var MINIMUM_JQUERY_VERSION = '1.7.0',
 // and simplify selectors
 var CSS = {
   alpha: 'alpha-d2270',
-  black: 'black-3c85d',
   board: 'board-b72b1',
   chessboard: 'chessboard-63f37',
   clearfix: 'clearfix-7da63',
@@ -215,9 +218,11 @@ var CSS = {
   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
@@ -292,6 +297,11 @@ function compareSemVer(version, minimum) {
 // 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 ||
@@ -562,7 +572,7 @@ function buildBoardContainer() {
 
 /*
 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 + '">';
 
@@ -597,7 +607,7 @@ function buildBoard(orientation) {
     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] + '" ' +
@@ -651,6 +661,11 @@ function buildPieceImgSrc(piece) {
   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') {
@@ -1391,6 +1406,10 @@ widget.orientation = function(arg) {
   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) {