Adding network object to network panel and query panel - fixes channel links in the...
authorCory Chaplin <cory.chaplin@laposte.net>
Sat, 10 May 2014 23:26:58 +0000 (01:26 +0200)
committerCory Chaplin <cory.chaplin@laposte.net>
Sat, 10 May 2014 23:26:58 +0000 (01:26 +0200)
client/src/models/network.js
client/src/views/channel.js

index 4cfcad5e39f1180dcc2cc87733e36d94a6688d3f..cca4716417acf85e3d0f4f6f5272e9a754eb7137 100644 (file)
@@ -77,7 +77,7 @@
             //this.panels.network = this;
 
             // Automatically create a server tab
-            var server_panel = new _kiwi.model.Server({name: 'Server'});
+            var server_panel = new _kiwi.model.Server({name: 'Server', network: this});
             this.panels.add(server_panel);
             this.panels.server = this.panels.active = server_panel;
         },
             // If a panel isn't found for this PM, create one
             panel = this.panels.getByName(event.nick);
             if (!panel) {
-                panel = new _kiwi.model.Query({name: event.nick});
+                panel = new _kiwi.model.Query({name: event.nick, network: this});
                 this.panels.add(panel);
             }
 
index 1f24f7cea4ad7869cf69d452d2e8058df0ccffd8..1ebc66626246b5a2c1230df58fd06bc6ee15e05f 100644 (file)
@@ -59,7 +59,7 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({
             time_difference,
             sb = this.model.get('scrollback'),
             prev_msg = sb[sb.length-2],
-            network, hour, pm;
+            network, hour, pm, extra_space = '';
 
         // Nick highlight detecting
         if ((new RegExp('(^|\\W)(' + escapeRegex(_kiwi.app.connections.active_connection.get('nick')) + ')(\\W|$)', 'i')).test(msg.msg)) {
@@ -74,7 +74,10 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({
         if ((network = this.model.get('network'))) {
             re = new RegExp('(?:^|\\s)([' + escapeRegex(network.get('channel_prefix')) + '][^ ,\\007]+)', 'g');
             msg.msg = msg.msg.replace(re, function (match) {
-                return '<a class="chan" data-channel="' + _.escape(match.trim()) + '">' + _.escape(match.trim()) + '</a>';
+                if(match.match(/^\s+/g)) {
+                    extra_space = ' ';
+                }
+                return extra_space + '<a class="chan" data-channel="' + _.escape(match.trim()) + '">' + _.escape(match.trim()) + '</a>';
             });
         }