/
ctrl.js
36 lines (33 loc) · 878 Bytes
/
ctrl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$(function()
{
if ($game = $('#dm_page div.dm_chess_game').orNot())
{
var options = dm_configuration.dm_chess_game;
if(options.opponent)
{
$game.game(options);
}
else
{
$('a.toggle_join_url').click(function()
{
$('div.dm_chess_join_url').toggle(100);
});
setTimeout(waitForOpponent = function()
{
$.ajax({
url: $.dm.ctrl.getHref('+/dmChessGame/getNbPlayers')+'?game='+options.game.code,
success: function(response)
{
response == 2 ? location.reload() : setTimeout(waitForOpponent, options.beat.delay);
}
});
}, options.beat.delay);
}
}
else if($waiting = $('div.dm_chess_not_created').orNot())
{
$waiting.find('.yescript').show();
location.href = $.dm.ctrl.getHref('+/dmChessGame/create');
}
});