rifattorizzata la chat (keypress event)
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Sun, 24 Dec 2006 08:54:43 +0000 (08:54 +0000)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Sun, 24 Dec 2006 08:54:43 +0000 (08:54 +0000)
web/commons.js
web/table.php

index 6c6fc79..2140281 100644 (file)
@@ -137,17 +137,33 @@ function send_mesg(mesg)
 
 /* Stat: CHAT and TABLE */
 
-function act_chatt()
+function chatt_checksend(obj,e)
 {
-    var obj = $("txt_in");
-    if (obj.value == "")
-       return (false);
-    send_mesg("chatt|"+encodeURIComponent(obj.value));
+    var keynum;
+    var keychar;
+    var numcheck;
+
+    if(window.event) { // IE
+       keynum = e.keyCode;
+    }
+    else if(e.which) { // Netscape/Firefox/Opera
+       keynum = e.which;
+    }
+    // alert("OBJ: "+obj);
+    if (keynum == 13 && obj.value != "") { // Enter
+       act_chatt(obj.value);
+       obj.value = "";
+    }
+}
+function act_chatt(value)
+{
+    send_mesg("chatt|"+encodeURIComponent(value));
+    /*
     obj.disabled = true;
     obj.value = "";
     obj.disabled = false;
     obj.focus();
-
+    */
     return false;
 }
 
index c70f783..8a43630 100644 (file)
@@ -196,7 +196,7 @@ Hai vinto l'asta.<br> Scegli il seme:
 
 <div class="subarea">
 <div id="txt" class="chattshort"></div>
-<table><tr><td><div id="myname" class="txtt"></div></td><td><input id="txt_in" type="text" size="80" maxlength="256" onchange="act_chatt();" class="txtt"></td></tr></table>
+<table><tr><td><div id="myname" class="txtt"></div></td><td><input id="txt_in" type="text" size="80" maxlength="256" onkeypress="chatt_checksend(this,event);" class="txtt"></td></tr></table>
 <hr>
 <div id="imgct"></div>
 <hr>