aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-06-10 12:52:33 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-06-10 12:52:33 -0700
commit9e57de76df9ccb49527806febf5ab03dc81804c7 (patch)
treea927db446843bae4be1783a64166be87949a1400
parent5f4cb2c1463c6b738f2dc00ab2c478602c0a2b5d (diff)
add event listening to headless
-rw-r--r--src/headless.js14
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';