attivato cambio di pointer nell'asta e aggiunta la funzione per risettare il valore...
[brisk.git] / web / commons.js
index 860c03c..2eb5e01 100644 (file)
  */
 
 var PLAYERS_N = 3;
-var EXIT_BAN_TIME = 15;
+var EXIT_BAN_TIME = 900;
 
 function $(id) { return document.getElementById(id); }
 
+function getStyle(x,IEstyleProp, MozStyleProp) 
+{
+    if (x.currentStyle) {
+       var y = x.currentStyle[IEstyleProp];
+    } else if (window.getComputedStyle) {
+       var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(MozStyleProp);
+    }
+    return y;
+}
+
 /* replacement of setInterval on IE */
 (function(){
     /*if not IE, do nothing*/
@@ -258,7 +268,7 @@ function safelogout()
     var res;
     
     if (g_exitlock < 3) 
-       res = window.confirm("Sei sicuro di volere abbandonare la partita?\nATTENZIONE: se esci adesso senza il consenso degli altri giocatori non potrai sederti ai tavoli per "+EXIT_BAN_TIME+" minuti.");    
+       res = window.confirm("Sei sicuro di volere abbandonare la partita?\nATTENZIONE: se esci adesso senza il consenso degli altri giocatori non potrai sederti ai tavoli per "+(Math.floor(EXIT_BAN_TIME/60))+" minuti.");    
     else 
        res = window.confirm("Sei sicuro di volere abbandonare la partita?");
     if (res)
@@ -299,11 +309,6 @@ function act_shutdown()
        c++;
 }
 
-function act_preout()
-{
-    act_logout();
-}
-
 function postact_logout()
 {
     // alert("postact_logout");
@@ -338,9 +343,11 @@ function sleep(st, delay)
 function slowimg(img,x1,y1,deltat,free,action,srcend) {
     this.img = img;
 
-    this.x0  = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("left"));
-    // alert("img.x0 = "+this.x0);
-    this.y0  = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("top"));
+    // this.x0  = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("left"));
+    this.x0 = parseInt(getStyle(this.img,"left", "left"));
+// alert("img.x0 = "+this.x0);
+    // this.y0  = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("top"));
+    this.y0  = parseInt(getStyle(this.img,"top", "top"));
     this.x1  = x1;
     this.y1  = y1;
     this.deltat = deltat;
@@ -379,13 +386,14 @@ slowimg.prototype = {
        this.action = act;
     },
     
+
     settime: function(time) 
     {
-       this.time = time;
-       this.step_n = parseInt(time / this.deltat);
+       this.time = (time < this.deltat ? this.deltat : time);
+       this.step_n = parseInt(this.time / this.deltat);
        this.dx = (this.x1 - this.x0) / this.step_n;
        this.dy = (this.y1 - this.y0) / this.step_n;
-       if (this.step_n * this.deltat == time) {
+       if (this.step_n * this.deltat == this.time) {
            this.step_n--;
        }
        this.step_free = parseInt(this.step_n * this.free);
@@ -454,10 +462,12 @@ function dispose_asta(idx, pnt, nopoint)
        btn = $("asta"+i);
        if (i < idx) {
            btn.src = "img/astapasso"+(pnt >= 0 ? "" : "_ro")+".png";
+            btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
            pass = -1;
        }
        else {
            btn.src = "img/asta"+i+(pnt >= 0 ? "" : "_ro")+".png";
+            btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
            pass = i;
        }
        if (i < 19)
@@ -465,15 +475,15 @@ function dispose_asta(idx, pnt, nopoint)
        else
            btn.style.left = asta_xarr[(i+1) % 3];
        
-       btn.style.top  = parseInt(i / 3) * 50+1;
+       btn.style.top  = parseInt(i / 3) * 50 + (i == 9 ? 0 : 1);
 
        if (pnt >= 0) {
            eval("btn.onclick = function () { act_asta("+pass+",61); }");
-           btn.style.hover_cursor = "pointer";
+           btn.style.cursor = "pointer";
        }
        else {
            btn.onclick = null;
-           btn.style.hover_cursor = "";
+           btn.style.cursor = "default";
        }
     }
     
@@ -491,14 +501,14 @@ function dispose_asta(idx, pnt, nopoint)
     btn.style.left = asta_xarr[i % 3];
     btn.style.top = 25 + parseInt(i / 3) * 50 - 1;
     btn.src = "img/astaptsub"+(pnt >= 0 ? "" : "_ro")+".png";
-    // btn.style.visibility  = "visible";
+    btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
     if (pnt >= 0) {
        btn.onclick = function () { act_asta(9,$("astapt").value); };
-       // btn.stylehover.cursor = "pointer";
+       btn.style.cursor = "pointer";
     }
     else {
        btn.onclick = null;
-       // btn.stylehover.cursor = "";
+       btn.style.cursor = "default";
     }
     
     i+=1;
@@ -507,13 +517,12 @@ function dispose_asta(idx, pnt, nopoint)
        btn.style.left = asta_xarr[i % 3];
        btn.style.top = parseInt(i / 3) * 50;
        btn.src = "img/astapashalf"+(pnt >= 0 ? "" : "_ro")+".png";
+        btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
        if (pnt >= 0) {
            btn.onclick = function () { act_asta(-1,0); };
-           // btn.stylehover.cursor = "pointer";
        }
        else {          
            btn.onclick = null;
-           // btn.stylehover.cursor = "";
        }
 
        btn = $("astalascio");
@@ -528,13 +537,12 @@ function dispose_asta(idx, pnt, nopoint)
        btn.style.left = asta_xarr[i % 3];
        btn.style.top = parseInt(i / 3) * 50;;
        btn.src = "img/astapasso"+(pnt >= 0 ? "" : "_ro")+".png";
+        btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
        if (pnt >= 0) {
            btn.onclick = function () { act_asta(-1,0); };
-           // btn.stylehover.cursor = "pointer";
        }
        else {
            btn.onclick = null;
-           // btn.stylehover.cursor = "";
        }
 
        btn = $("astalascio");
@@ -545,6 +553,13 @@ function dispose_asta(idx, pnt, nopoint)
     $("asta").style.visibility = "visible";
 }
 
+function asta_pnt_set(pnt)
+{
+    btn = $("astapt");
+    var rpnt = (pnt < 0 ? -pnt : pnt);
+    btn.value = (rpnt < 61 ? 61 : (rpnt > 120 ? 120 : rpnt));
+}
+
 function hide_asta()
 {
     $("asta").style.visibility = "hidden"; 
@@ -579,6 +594,7 @@ function notify(st, text, tout, butt, w, h)
     box.innerHTML = text;
     box.style.zIndex = 200;
     box.style.width  = w+"px";
+    box.style.marginLeft  = -parseInt(w/2)+"px";
     box.style.height = h+"px";
     box.appendChild(clodiv);
     box.style.visibility = "visible";
@@ -868,7 +884,7 @@ function room_checkspace(emme,tables,inpe)
 
     stand = "<table class=\"table_standup\"><tbody><tr>";
     for (i = 0 ; i < inpe ; i++) {
-       stand += "<td class=\"td_standup\">"+nome+"</td>";
+       stand += "<td>"+nome+"</td>";
        if ((i+1) % 4 == 0) {
            stand += "</tr><tr>";
        }
@@ -876,7 +892,7 @@ function room_checkspace(emme,tables,inpe)
     stand += "</tr>";
     $("standup").innerHTML = stand;
 
-    $("esco").innerHTML = "<input name=\"logout\" type=\"button\" value=\"Esco.\" onclick=\"window.onunload = null; act_logout();\" type=\"button\">";
+    $("esco").innerHTML = "<input class=\"button\" name=\"logout\" type=\"button\" value=\"Esco.\" onclick=\"window.onunload = null; act_logout();\" type=\"button\">";
 }
 
 function playsound(tag, sound) {