From 96885dd7c8186ebc6c2c14981e07cffe4adaf16c Mon Sep 17 00:00:00 2001 From: Hector Fernando Ricardez Lara Date: Sat, 6 Jul 2024 18:19:08 -0600 Subject: [PATCH] Arreglar referencia al mismo EventTarget (#172) * Arreglar referencia al mismo EventTarget * lint? * hopefully this lints, bc I cant run the linter * last lint attempt * Lint --- js/karel.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/js/karel.js b/js/karel.js index a3af799..8c8473d 100644 --- a/js/karel.js +++ b/js/karel.js @@ -85,10 +85,9 @@ var Runtime = function (world) { self.disableStackEvents = false; self.load([['HALT']]); + self.events = new EventTarget(); }; -Runtime.prototype = new EventTarget(); - Runtime.HALT = 0; Runtime.LINE = 1; Runtime.LEFT = 2; @@ -118,6 +117,22 @@ Runtime.CALL = 25; Runtime.RET = 26; Runtime.PARAM = 27; +Runtime.prototype.addEventListener = function (type, listener) { + this.events.addEventListener(type, listener); +}; + +Runtime.prototype.removeEventListener = function (type, listener) { + this.events.removeEventListener(type, listener); +}; + +Runtime.prototype.dispatchEvent = function (evt) { + this.events.dispatchEvent(evt); +}; + +Runtime.prototype.fireEvent = function (type, properties) { + this.events.fireEvent(type, properties); +}; + Runtime.prototype.load = function (opcodes) { var self = this; var opcode_mapping = [