BUGFIX: check for 2nd 10 of hearts in wedding and poverty games
[e-DoKo.git] / js / game.js
index 3a1a0803257fa61bd5899f5687c6dd14441595a3..06457bea4b6a1104c7286ab5ca027ca968ee8432 100644 (file)
@@ -5,9 +5,30 @@ var current=0;
 /* do the higlighting */
 function hl(num) {
     var i;
 /* do the higlighting */
 function hl(num) {
     var i;
-    for(i=0;i<14;i++){ $("#trick"+i).hide(); }
+    for(i=0;i<14;i++){ $("#trick"+i).hide(); $("#tricks"+i).removeClass('active'); }
     $("#trick"+num).css('display', 'block');
     $("#trick"+num).css('display', 'block');
+    $("#tricks"+num).addClass('active');
     current=num;
     current=num;
+
+    if(document.getElementById("tricks0"))
+       min=0;
+    else
+       min=1;
+
+    if(document.getElementById("tricks13"))
+       max=13;
+    else
+       max=12;
+
+    if(current==min)
+       $("#prevtr").addClass('disabled');
+    else
+       $("#prevtr").removeClass('disabled');
+    if(current==max)
+       $("#nexttr").addClass('disabled');
+    else
+       $("#nexttr").removeClass('disabled');
+
 }
 
 /* highlight the last trick, useful when a page is called the first time*/
 }
 
 /* highlight the last trick, useful when a page is called the first time*/
@@ -39,6 +60,18 @@ function hl_prev()
        hl(current-1);
 }
 
        hl(current-1);
 }
 
+/* check for swipes */
+var down_x = null;
+var up_x = null;
+
+/* advance trick according to swipe direction */
+function do_swipe()
+{
+    if ((down_x - up_x) > 50)  { hl_prev(); }
+    if ((up_x - down_x) > 50)  { hl_next(); }
+}
+
+
 $(document).ready(
     function()
     {
 $(document).ready(
     function()
     {
@@ -67,11 +100,25 @@ $(document).ready(
            $(".gameshidesession").hide();
        });
 
            $(".gameshidesession").hide();
        });
 
-       $("ul.loginregister").click(function () {
-           $(".dologin").slideToggle();
-           $(".doregister").slideToggle();
-       });
-
        $(".message div div").parent().click ( function() { $(this).hide(); });
        $(".message div div").parent().click ( function() { $(this).hide(); });
-
     });
     });
+
+/* look for swipes left/right */
+$().ready(function(){
+       $("div.table").mousedown(function(e){
+           down_x = e.pageX;
+       });
+       $("div.table").mouseup(function(e){
+           up_x = e.pageX;
+           do_swipe();
+       });
+       $("div.table").bind('touchstart', function(e){
+           down_x = e.originalEvent.touches[0].pageX;
+       });
+       $("div.table").bind('touchmove', function(e){
+           up_x = e.originalEvent.touches[0].pageX;
+       });
+       $("div.table").bind('touchend', function(e){
+           do_swipe();
+       });
+});