-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: janusweb
action: commit
revision:
path_from:
revision_from: e39ef923c5347b91b0f5693efc50984ce808fa63:
path_to:
revision_to:

git.thebackupbox.net

janusweb

git://git.thebackupbox.net/janusweb

commit e39ef923c5347b91b0f5693efc50984ce808fa63
Author: James Baicoianu <james_github@baicoianu.com>
Date:   Tue Oct 31 05:28:22 2017 -0700

    Register and unregister room events on enable/disable

diff --git a/scripts/room.js b/scripts/room.js

index a6c58ef314677ae49b83e804f2fdf3fabd3f76d1..

index ..f5cc077250e3084d1dce423c1f7e7aeecf281662 100644

--- a/scripts/room.js
+++ b/scripts/room.js
@@ -79,20 +79,20 @@ elation.require([
       this.unknownElements = {};
       this.eventlistenerproxies = {};

-      if (this.engine.systems.admin) {
-        elation.events.add(this.engine.systems.admin, 'admin_edit_change', elation.bind(this, this.onRoomEdit));
-      }
-      //this.showDebug();
-      elation.events.add(window, 'click', elation.bind(this, this.onClick));
-      elation.events.add(window, 'keydown', elation.bind(this, this.onKeyDown));
-      elation.events.add(window, 'keyup', elation.bind(this, this.onKeyUp));
-
-      elation.events.add(this, 'click', elation.bind(this, this.onObjectClick));
-
-      elation.events.add(this.engine.client.container, 'mousedown,touchstart', elation.bind(this, this.onMouseDown));
-      elation.events.add(this.engine.client.container, 'mouseup,touchend', elation.bind(this, this.onMouseUp));
-      elation.events.add(this, 'dragover', elation.bind(this, this.handleDragOver));
-      elation.events.add(this, 'drop', elation.bind(this, this.handleDrop));
+      // FIXME - binding functions to this instance so we can unbind events later.  Should be done at a lower level
+      this.onRoomEdit = elation.bind(this, this.onRoomEdit);
+      this.onClick = elation.bind(this, this.onClick);
+      this.onKeyDown = elation.bind(this, this.onKeyDown);
+      this.onKeyUp = elation.bind(this, this.onKeyUp);
+      this.onObjectClick = elation.bind(this, this.onObjectClick);
+      this.onMouseDown = elation.bind(this, this.onMouseDown);
+      this.onMouseUp = elation.bind(this, this.onMouseUp);
+      this.handleDragOver = elation.bind(this, this.handleDragOver);
+      this.handleDragDrop = elation.bind(this, this.handleDragDrop);
+      this.editObjectMousemove = elation.bind(this, this.editObjectMousemove);
+      this.editObjectClick = elation.bind(this, this.editObjectClick);
+      this.editObjectHandlePointerlock = elation.bind(this, this.editObjectHandlePointerlock);
+      this.onScriptTick = elation.bind(this, this.onScriptTick);

       this.roomedit = {
         snap: .1,
@@ -120,12 +120,6 @@ elation.require([
         'togglemove':       [ 'keyboard_shift', elation.bind(this, this.editObjectToggleMove)],
       });

-      // FIXME - these should be bound at the component level
-      this.editObjectMousemove = elation.bind(this, this.editObjectMousemove);
-      this.editObjectClick = elation.bind(this, this.editObjectClick);
-      this.editObjectHandlePointerlock = elation.bind(this, this.editObjectHandlePointerlock);
-      this.onScriptTick = elation.bind(this, this.onScriptTick);
-
       if (this.url) {
         this.roomid = md5(this.url);
         this.load(this.url, this.baseurl);
@@ -709,6 +703,18 @@ elation.require([
         elation.events.fire({type: 'room_enable', data: this});
       }
       elation.events.add(this, 'thing_think', this.onScriptTick);
+      if (this.engine.systems.admin) {
+        elation.events.add(this.engine.systems.admin, 'admin_edit_change', elation.bind(this, this.onRoomEdit));
+      }
+      //this.showDebug();
+      elation.events.add(window, 'click', this.onClick);
+      elation.events.add(window, 'keydown', this.onKeyDown);
+      elation.events.add(window, 'keyup', this.onKeyUp);
+      elation.events.add(this.engine.client.container, 'mousedown,touchstart', this.onMouseDown);
+      elation.events.add(this.engine.client.container, 'mouseup,touchend', this.onMouseUp);
+      elation.events.add(this, 'click', this.onObjectClick);
+      elation.events.add(this, 'dragover', this.handleDragOver);
+      elation.events.add(this, 'drop', this.handleDrop);
     }
     this.disable = function() {
       var keys = Object.keys(this.children);
@@ -724,6 +730,14 @@ elation.require([
         this.enabled = false;
       }
       elation.events.remove(this, 'thing_think', this.onScriptTick);
+      elation.events.remove(window, 'click', this.onClick);
+      elation.events.remove(window, 'keydown', this.onKeyDown);
+      elation.events.remove(window, 'keyup', this.onKeyUp);
+      elation.events.remove(this.engine.client.container, 'mousedown,touchstart', this.onMouseDown);
+      elation.events.remove(this.engine.client.container, 'mouseup,touchend', this.onMouseUp);
+      elation.events.remove(this, 'click', this.onObjectClick);
+      elation.events.remove(this, 'dragover', this.handleDragOver);
+      elation.events.remove(this, 'drop', this.handleDrop);
     }
     this.setTitle = function(title) {
       if (!title) title = 'Untitled Page';

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 18:09:46 2024