Update copyright, addEvent and removeEvent functions added
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Sat, 19 Apr 2008 15:07:41 +0000 (15:07 +0000)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Sat, 19 Apr 2008 15:07:41 +0000 (15:07 +0000)
web/commons.js

index 189effc..342fc99 100644 (file)
@@ -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)