API Docs for:
Show:

Main Class

Defined in: js/script.js:6
Module: Main

Main methods This is not actually a class, but a necessary convention to get YUIdoc to document standalone items.

Methods

cancelGame

()

Defined in js/script.js:263

hides #cancel-search div, shows #start-search and sends stop search request to the server

connect

() Object

Defined in js/script.js:163

ajax request to connect to the server

Returns:

Object:

ajax result

displayDrawOffer

(
  • offer
)

Defined in js/script.js:311

display draw offer menu

Parameters:

  • offer String

    offer side, valid values are 'white', 'black' or 'none'

finishGame

(
  • result
  • message
)

Defined in js/script.js:334

displays the game result and prompts user to start new game

Parameters:

  • result String

    result of the game, valid values are 'white', 'black' or 'draw'

  • message String

    the reason to finish the game

load

()

Defined in js/script.js:216

document.load event

playAgain

()

Defined in js/script.js:275

hides #start-search div, shows #cancel-search and requests for the game

render

()

Defined in js/script.js:187

renders the chess board in case of initial window load or window resize events

reqGame

() Object

Defined in js/script.js:23

Recursively calls ajax request to check for the start of the game

Returns:

Object:

ajax result

reqGame

(
  • game_id
)
Object

Defined in js/script.js:56

Recursively calls ajax request to check for an opponent move

Parameters:

  • game_id Number

    the id of the game

Returns:

Object:

ajax result

requestGame

()

Defined in js/script.js:251

hides #play-again div, shows #cancel-search and requests for the game

requestHistory

(
  • game_id
)
Object

Defined in js/script.js:136

ajax request to retrieve game history

Parameters:

  • game_id Number

    the id of the game

Returns:

Object:

ajax result

setClock

(
  • wc
  • bc
)

Defined in js/script.js:365

sets a clock

Parameters:

  • wc Number

    white side clock

  • bc Number

    black side clock

stopSearch

() Object

Defined in js/script.js:175

ajax request to stop the search for the game

Returns:

Object:

ajax result

submitMove

(
  • game_id
  • fen
  • move
  • castling
  • enpassant
  • draw_moves
  • wlc
  • wsc
  • blc
  • bsc
  • result
  • gameFinished
)

Defined in js/script.js:91

Sends ajax request to submit a move

Parameters:

  • game_id Number

    the id of the game

  • fen String

    Forsyth–Edwards notation of the current state of the chess game

  • move String

    notation representation of the move

  • castling String

    valid values are 'long', 'short' or 'none'

  • enpassant String

    the notation coordinates of the pawn which can be taken en passant

  • draw_moves Number

    number of moves to finish a game under 50 moves rule

  • wlc String

    white long castling right, valid values 'true' and 'false'

  • wsc String

    white short castling right, valid values 'true' and 'false'

  • blc String

    black short castling right, valid values 'true' and 'false'

  • bsc String

    black short castling right, valid values 'true' and 'false'

  • result String

    the result of the game in case the game has finished, valid values are 'white', 'black or 'draw'

  • gameFinished String

    the reason to finish the game

submitResult

(
  • result
  • game_finished
)
Object

Defined in js/script.js:149

ajax request to submit the result of the game

Parameters:

  • result String

    the result of the game, valid values are 'black', 'white' or 'draw'

  • game_finished String

    the reason to finish the game

Returns:

Object:

ajax result

updateHistoryTable

(
  • res
)

Defined in js/script.js:287

updates history table

Parameters:

  • res Object

    data to be colected from the requestHistory ajax request