12345678910111213141516171819202122232425 |
- var EventCenter = {
- addEventHandler: function (eventName, callback) {
- if(!this.handles){
- this.handles={};
- }
- if(!this.handles[eventName]){
- this.handles[eventName]=[];
- }
- this.handles[eventName].push(callback);
- },
- emit: function (eventName) {
- if(this.handles[arguments[0]]){
- for(var i=0;i<this.handles[arguments[0]].length;i++){
- this.handles[arguments[0]][i](arguments[1]);
- }
- }
- },
- removeEventHandler: function (eventName) {
- if(this.handles[eventName]){
- delete this.handles[eventName];
- }
- }
- };
|