From 39f33b670d29fb2b79afd36fcfc05a2052632847 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Tue, 8 May 2012 15:58:54 +0100 Subject: [PATCH] added functions for binding functions to a context and for concating them --- WebContent/utils/OSRM.classes.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/WebContent/utils/OSRM.classes.js b/WebContent/utils/OSRM.classes.js index 4b21d653c..b97be6770 100644 --- a/WebContent/utils/OSRM.classes.js +++ b/WebContent/utils/OSRM.classes.js @@ -15,8 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or see http://www.gnu.org/licenses/agpl.txt. */ -// OSRM base class -// [support for inheritance] +// OSRM classes +// [support for inheritance and other function related functionality] // declare one class to be a subclass of another class // (runs anonymous function to prevent local functions cluttering global namespace) @@ -39,6 +39,24 @@ OSRM.extend = function( target_class, properties ) { }; +// bind a function to an execution context, i.e. an object (needed for correcting this pointers) +OSRM.bind = function( context, fct1, fct2 ) { + return function() { + if(fct1) fct1.apply(context, arguments); + if(fct2) fct2.apply(context, arguments); + }; +}; + + +// concatenate the execution of two functions with the same set of parameters +OSRM.concat = function( fct1, fct2 ) { + return function() { + fct1.apply(this,arguments); + fct2.apply(this,arguments); + }; +}; + + // [usage of convenience functions] // SubClass = function() { // SubClass.prototype.base.constructor.apply(this, arguments);