this/that fixes
authorJack Allnutt <m2ys4u@gmail.com>
Fri, 25 Jan 2013 16:59:19 +0000 (16:59 +0000)
committerDarren <darren@darrenwhitlen.com>
Thu, 31 Jan 2013 14:58:43 +0000 (14:58 +0000)
server/irc/binder.js
server/irc/commands.js

index a4fab42486e0c941a9311ccd0baee8fe33bc8b38..7f3f0e58927aaae997e82dcbf6c945fdc02642b0 100755 (executable)
@@ -1,24 +1,27 @@
+var _ = require('lodash');
+
 var Binder = function () {};
 
 module.exports = Binder;
 
 Binder.prototype.bindEvents = function () {
     var that = this;
-    this.irc_events.forEach(function (fn, event_name, irc_events) {
+    _.each(this.irc_events, function (fn, event_name, irc_events) {
         // Bind the event to `that` context, storing it with the event listing
         if (!irc_events[event_name].bound_fn) {
             irc_events[event_name].bound_fn = fn.bind(that);
         }
 
-        this.irc_connection.on(this.scope + ':' + event_name, irc_events[event_name].bound_fn);
+        that.irc_connection.on(that.scope + ':' + event_name, irc_events[event_name].bound_fn);
     });
 };
 
 
 Binder.prototype.unbindEvents = function () {
-    this.irc_events.forEach(function(fn, event_name, irc_events) {
+    var that = this;
+    _.each(this.irc_events, function(fn, event_name, irc_events) {
         if (irc_events[event_name].bound_fn) {
-            this.irc_connection.removeListener(this.scope + ':' + event_name, irc_events[event_name].bound_fn);
+            that.irc_connection.removeListener(that.scope + ':' + event_name, irc_events[event_name].bound_fn);
         }
     });
 };
\ No newline at end of file
index 13581e3de16d5605fa3acea582b01570da70a9e2..e806ddbf7c2af0878ea4a26bf88642fbde395dd0 100644 (file)
@@ -220,7 +220,7 @@ var listeners = {
             member_list.push({nick: member, modes: modes});
         });
 
-        that.irc_connection.emit('channel:' + command.params[2] + ':userlist', {
+        this.irc_connection.emit('channel:' + command.params[2] + ':userlist', {
             users: member_list,
             channel: command.params[2]
         });
@@ -228,7 +228,7 @@ var listeners = {
 
     
     'RPL_ENDOFNAMES': function (command) {
-        that.irc_connection.emit('channel:' + command.params[1] + ':userlist_end', {
+        this.irc_connection.emit('channel:' + command.params[1] + ':userlist_end', {
             channel: command.params[1]
         });
     },