X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Fcommons.js;h=3b79ddc1f4f45ed19223c08134e5707e5927ecd5;hb=0d462f547c388b20d72a9de96955484636736108;hp=189effcbee06459fbb8e08cb87d95e5da53dd0d9;hpb=96b3b0c2196bea834cfc3e7d77283029782f87d7;p=brisk.git diff --git a/web/commons.js b/web/commons.js index 189effc..3b79ddc 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,6 +110,32 @@ 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, x, y) @@ -812,6 +841,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 +863,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") ); } /*