1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| event = { on: function (eventName, callback) { if(!this.handles){ Object.defineProperty(this, "handles", { value: {}, enumerable: false, configurable: true, writable: true }) }
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]); } } } }
|