Created
May 12, 2014 21:37
-
-
Save BobGneu/269ce6d7840a88b8a4d5 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
if (typeof Object.addEventListener !== 'function') | |
{ | |
Object.addEventListener = function (name, fn) | |
{ | |
// If this object has yet to have any events attached, create a new object. | |
if (!this.events) | |
this.events = {}; | |
// If this event listing has not yet been notified of this event, create a new array. | |
this.events[name] = this.events[name] || []; | |
// add this callback to the list | |
this.events[name].push(fn); | |
}; | |
} | |
if (typeof Object.dispatchEvent !== 'function') | |
{ | |
Object.dispatchEvent = function (ev) | |
{ | |
// if there are no events, we don't care | |
if (!this.events) | |
return; | |
// if this event has no listeners registered, we don't care either. | |
if (!this.events[ev.Name]) | |
return; | |
// add this callback to the list | |
this.events[ev.Name].forEach(function (element) | |
{ | |
element(ev.detail); | |
}); | |
}; | |
} | |
var CustomEvent = function (name, params) | |
{ | |
params = params || | |
{ | |
bubbles: false, | |
cancelable: false, | |
detail: undefined | |
}; | |
this.Name = name; | |
this.bubbles = params.bubbles || false; | |
this.detail = params.detail || | |
{}; | |
this.cancelable = params.cancelable || false; | |
}; | |
var test = Object.create(Object); | |
test.addEventListener("initialized", function (details) | |
{ | |
game.log("Inititialized.", v8.version, v8.bindingVersion); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment