-
-
Save magcius/f83deda903311d49edba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Base Module Class | |
function Module(){ | |
this.id = "baseModule"; | |
this.heading = "Base Module"; | |
//Creates a module from the base class. arguments (moduleId and paramsObject{heading,heSig}) | |
//Eg:baseModule.createModule("cm",{heading:"CM Module",heSig: cmHandleEvent}); | |
this.createModule = function(id, obj){ | |
var tmpModule = new Object(); | |
tmpModule.id=id; | |
tmpModule.heading=obj.heading; | |
tmpModule.init=function(){ | |
if (obj.heSig != null) | |
registerModule(this.id,obj.heSig); | |
} | |
tmpModule.handleEvent=function(){ | |
logwr('warn',"handleEvent of Module : "+this.id+". This is an abstract method. It was not meant to be called for the derived class."); | |
} | |
tmpModule.raiseEvent=function(eve,params){ | |
logwr('debug',"raised Event in "+this.id+" Event:"+eve); | |
// logwr('debug',"raised Event in "+this.id+" Event:"+eve+ | |
// (params == null ? "" : " Params Received:"+params.length)); | |
try{ | |
raiseEvent(this.id,eve,params); | |
}catch(e){ | |
logwr('error',"Exception while raising Event "+eve+" by "+this.id+" Ex:"+e); | |
} | |
} | |
return tmpModule; | |
} | |
} | |
//Factory method to get the base module class | |
function getBaseModule(){ | |
if(Module != 'undefined'){ | |
var bm = new Module(); | |
return bm; | |
} | |
else{ | |
alert("baseModule object is missing. Please make sure you include Module() class from baseModule.js"); | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment