From 51e3ccc452c854c6a372d51ab5ecab854bdc29c0 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Sat, 19 Apr 2008 15:07:41 +0000 Subject: [PATCH] Update copyright, addEvent and removeEvent functions added --- web/commons.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/web/commons.js b/web/commons.js index 189effc..342fc99 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) -- 2.17.1