X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcommons.js;h=e305e990d76639a0804919611a9d25b6b28eb5bb;hb=a3a94bbfaa5b0484a6d32bb04bde148f5f95347b;hp=1849705b0006cd8e0304255e21733045a09a5fef;hpb=1e580150bca7f599af6fc4c52f079fafd98ff94f;p=brisk.git
diff --git a/web/commons.js b/web/commons.js
index 1849705..e305e99 100644
--- a/web/commons.js
+++ b/web/commons.js
@@ -1,7 +1,10 @@
/*
* brisk - commons.js
*
- * Copyright (C) 2006 matteo.nastasi@milug.org
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -107,17 +110,47 @@ function getStyle(x,IEstyleProp, MozStyleProp)
})()
+function addEvent(obj,type,fn)
+{
+ if (obj.addEventListener) {
+ obj.addEventListener( type, fn, false);
+ }
+ else if (obj.attachEvent) {
+ obj["e"+type+fn] = fn;
+ obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
+ obj.attachEvent( "on"+type, obj[type+fn] );
+ }
+ else
+ throw new Error("Event registration not supported");
+}
+
+function removeEvent(obj,type,fn)
+{
+ if (obj.removeEventListener) {
+ obj.removeEventListener( type, fn, false );
+ }
+ else if (obj.detachEvent) {
+ obj.detachEvent( "on"+type, obj[type+fn] );
+ obj[type+fn] = null;
+ obj["e"+type+fn] = null;
+ }
+}
+
// var card_pos = RANGE 0 <= x < cards_ea_n
-function show_bigpict(obj, act)
+function show_bigpict(obj, act, x, y)
{
- var big;
+ var big, sfx;
+
+ if (arguments.length > 4)
+ sfx = arguments[4];
+ else
+ sfx = '';
- // alert("offsetTop: "+obj.offsetTop+" offsetLeft: "+obj.offsetLeft+"obj.id: "+obj.id);
- big = $(obj.id+"_big");
+ big = $(obj.id+"_big"+sfx);
if (act == "over") {
- big.style.left = obj.offsetLeft + 100+"px";
- big.style.top = obj.offsetTop + 10+"px";
+ big.style.left = obj.offsetLeft + x+"px";
+ big.style.top = obj.offsetTop + y+"px";
big.style.visibility = "visible";
}
else {
@@ -193,12 +226,17 @@ function createXMLHttpRequest() {
function send_mesg(mesg)
{
var xhr_wr = createXMLHttpRequest();
-
+ var is_conn = (sess == "not_connected" ? false : true);
- xhr_wr.open('GET', 'index_wr.php?sess='+sess+'&mesg='+mesg, true);
+ xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, (is_conn ? true : false));
xhr_wr.onreadystatechange = function() { return; };
xhr_wr.send(null);
+ if (!is_conn) {
+ if (xhr_wr.responseText != null) {
+ eval(xhr_wr.responseText);
+ }
+ }
}
/* Stat: CHAT and TABLE */
@@ -273,11 +311,27 @@ function act_help()
send_mesg("help");
}
+function act_tav()
+{
+ act_chatt('/tav '+$('txt_in').value);
+ $('txt_in').value = '';
+}
+
function act_about()
{
send_mesg("about");
}
+function act_roadmap()
+{
+ send_mesg("roadmap");
+}
+
+function act_whysupport()
+{
+ send_mesg("whysupport");
+}
+
function act_exitlock()
{
send_mesg("exitlock");
@@ -416,7 +470,9 @@ slowimg.prototype = {
if (this.step_n * this.deltat == this.time) {
this.step_n--;
}
- this.step_free = parseInt(this.step_n * this.free);
+ if (this.free < 1) {
+ this.step_free = parseInt(this.step_n * this.free);
+ }
},
start: function(st)
@@ -442,7 +498,7 @@ slowimg.prototype = {
this.step_cur++;
setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
if (this.step_cur == this.step_free && this.st != null) {
- if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
+ if (this.st.st_loc < this.st.st_loc_new) {
// alert("QUI1 " + this.step_cur + " ZZ "+ this.step_free);
this.st.st_loc++;
this.st = null;
@@ -455,14 +511,16 @@ slowimg.prototype = {
// $("logz").innerHTML += "xxxxxxxxxxxxxxxCLEAR
";
var date = new Date();
// $("logz").innerHTML += "Timestop: " + date + "
";
+
+ if (this.action != null) {
+ eval(this.action);
+ }
+
if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
// alert("QUI2");
this.st.st_loc++;
this.st = null;
}
- if (this.action != null) {
- eval(this.action);
- }
if (this.srcend != null) {
this.img.src = this.srcend;
}
@@ -779,6 +837,8 @@ var fin = 0;
function table_init() {
var sux = new Array("", "_ea", "_ne", "_nw", "_we");
+ // console.log("table_init");
+
remark_off();
$("asta").style.visibility = "hidden";
$("caller").style.visibility = "hidden";
@@ -789,6 +849,7 @@ function table_init() {
$("card"+sux[e]+i).style.visibility = "hidden";
}
for (i=0 ; i < PLAYERS_N ; i++) {
+ // console.log("shut: "+"takes"+sux[i]);
$("takes"+sux[i]).style.visibility = "hidden";
}
@@ -812,6 +873,13 @@ var CHATT_MAXLINES = 40;
/* PRO CHATT */
function chatt_sub(name,str)
{
+ var must_scroll = false;
+
+ // alert ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight);
+
+ if ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight >= 0)
+ must_scroll = true;
+
// alert("ARRIVA NAME: "+ name + " STR:"+str);
if (chatt_lines_n == CHATT_MAXLINES) {
$("txt").innerHTML = "";
@@ -827,8 +895,13 @@ function chatt_sub(name,str)
$("txt").innerHTML += chatt_lines[chatt_lines_n];
chatt_lines_n++;
}
- $("txt").innerHTML;
- $("txt").scrollTop = 10000000;
+ // $("txt").innerHTML;
+
+
+ if (must_scroll) {
+ $("txt").scrollTop = 10000000;
+ }
+ // alert("scTOP "+$("txt").scrollTop+" scHEIGHT: "+$("txt").scrollHeight+" HEIGHT: "+getStyle($("txt"),"height", "height") );
}
/*