diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-06-10 12:52:33 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-06-10 12:52:33 -0700 |
commit | 9e57de76df9ccb49527806febf5ab03dc81804c7 (patch) | |
tree | a927db446843bae4be1783a64166be87949a1400 /src/headless.js | |
parent | 5f4cb2c1463c6b738f2dc00ab2c478602c0a2b5d (diff) |
add event listening to headless
Diffstat (limited to 'src/headless.js')
-rw-r--r-- | src/headless.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/headless.js b/src/headless.js index d81fb5a3..097a42f7 100644 --- a/src/headless.js +++ b/src/headless.js @@ -4,6 +4,20 @@ // TODO: sync from bananabread headless.js var window = { + eventListeners: {}, + addEventListener: function(id, func) { + var listeners = this.eventListeners[id]; + if (!listeners) { + listeners = this.eventListeners[id] = []; + } + listeners.push(func); + }, + callEventListeners: function(id) { + var listeners = this.eventListeners[id]; + if (listeners) { + listeners.forEach(function(listener) { listener() }); + } + }, location: { toString: function() { return '%s'; |