BUGFIX: fix disable of prev/next button in trick selector
[e-DoKo.git] / js / game.js
1 /* some code to highlight the current trick and to switch between different tricks */
2 /* which trick is currently highlighted*/
3 var current=0;
4
5 /* do the higlighting */
6 function hl(num) {
7     var i;
8     for(i=0;i<14;i++){  $("#trick"+i).hide(); $("#tricks"+i).removeClass('active'); }
9     $("#trick"+num).css('display', 'block');
10     $("#tricks"+num).addClass('active');
11     current=num;
12
13     if(document.getElementById("tricks0"))
14         min=0;
15     else
16         min=1;
17
18     if(document.getElementById("tricks13"))
19         max=13;
20     else
21         max=12;
22
23     if(current==min)
24         $("#prevtr").addClass('disabled');
25     else
26         $("#prevtr").removeClass('disabled');
27     if(current==max)
28         $("#nexttr").addClass('disabled');
29     else
30         $("#nexttr").removeClass('disabled');
31
32 }
33
34 /* highlight the last trick, useful when a page is called the first time*/
35 function high_last(){
36     if(document.getElementById){
37         var i;
38         for(i=13;i>=0;i--) {
39             if(document.getElementById("trick"+i))
40                 {
41                     hl(i);
42                     current=i;
43                     break;
44                 }
45         }
46     }
47 }
48
49 /* highlight the next trick */
50 function hl_next()
51 {
52     if(document.getElementById("trick"+(current+1)))
53         hl(current+1);
54 }
55
56 /* highlight the previous trick */
57 function hl_prev()
58 {
59     if(document.getElementById("trick"+(current-1)))
60         hl(current-1);
61 }
62
63 $(document).ready(
64     function()
65     {
66         $("#ScoreTable").tablesorter({ widgets: ['zebra']});
67
68         $(".gameshidesession").click( function () {
69             $(this).parent().children(".gamessession").hide(300);
70             $(this).parent().children(".gamesshowsession").show();
71             $(this).hide();
72         });
73
74         $(".gamesshowsession").click( function () {
75             $(this).parent().children(".gamessession").show(300);
76             $(this).parent().children(".gameshidesession").show();
77             $(this).hide();
78         });
79
80         $(".gameshowall").click( function () {
81             $(".gamessession").show(300);
82             $(".gamesshowsession").hide();
83             $(".gameshidesession").show();
84         });
85         $(".gamehideall").click( function () {
86             $(".gamessession").hide(300);
87             $(".gamesshowsession").show();
88             $(".gameshidesession").hide();
89         });
90
91         $(".message div div").parent().click ( function() { $(this).hide(); });
92
93     });