1 _kiwi
.model
.Application = function () {
2 // Set to a reference to this object within initialize()
6 var model = function () {
7 /** _kiwi.view.Application */
10 /** _kiwi.view.StatusMessage */
13 /* Address for the kiwi server */
14 this.kiwi_server
= null;
16 this.initialize = function (options
) {
19 if (options
[0].container
) {
20 this.set('container', options
[0].container
);
23 // The base url to the kiwi server
24 this.set('base_path', options
[0].base_path
? options
[0].base_path
: '/kiwi');
26 // Any options sent down from the server
27 this.server_settings
= options
[0].server_settings
|| {};
28 this.translations
= options
[0].translations
|| {};
30 // Best guess at where the kiwi server is
31 this.detectKiwiServer();
33 // Takes instances of model_network
34 this.connections
= new _kiwi
.model
.NetworkPanelList();
38 this.start = function () {
39 // Only debug if set in the querystring
40 if (!getQueryVariable('debug')) {
47 _kiwi
.gateway
= new _kiwi
.model
.Gateway();
48 this.bindGatewayCommands(_kiwi
.gateway
);
50 this.initializeClient();
51 this.initializeGlobals();
52 this.applyDefaultClientSettings(this.server_settings
.client
.settings
);
54 this.view
.barsHide(true);
56 this.showIntialConenctionDialog();
60 this.detectKiwiServer = function () {
61 // If running from file, default to localhost:7777 by default
62 if (window
.location
.protocol
=== 'file:') {
63 this.kiwi_server
= 'http://localhost:7778';
65 // Assume the kiwi server is on the same server
66 this.kiwi_server
= window
.location
.protocol
+ '//' + window
.location
.host
;
71 this.showIntialConenctionDialog = function() {
72 var connection_dialog
= new _kiwi
.model
.NewConnection();
73 this.populateDefaultServerSettings(connection_dialog
);
75 connection_dialog
.view
.$el
.addClass('initial');
76 this.view
.$el
.find('.panel_container:first').append(connection_dialog
.view
.$el
);
78 var $info
= $($('#tmpl_new_connection_info').html().trim());
81 connection_dialog
.view
.infoBoxSet($info
);
82 connection_dialog
.view
.infoBoxShow();
85 // TODO: Shouldn't really be here but it's not working in the view.. :/
86 // Hack for firefox browers: Focus is not given on this event loop iteration
87 setTimeout(function(){
88 connection_dialog
.view
.$el
.find('.nick').select();
91 // Once connected, close this dialog and remove its own event
93 connection_dialog
.view
.$el
.slideUp(function() {
94 connection_dialog
.view
.dispose();
95 connection_dialog
= null;
97 _kiwi
.gateway
.off('onconnect', fn
);
101 _kiwi
.gateway
.on('onconnect', fn
);
105 this.initializeClient = function () {
106 this.view
= new _kiwi
.view
.Application({model
: this, el
: this.get('container')});
108 // Applets panel list
109 this.applet_panels
= new _kiwi
.model
.PanelList();
110 this.applet_panels
.view
.$el
.addClass('panellist applets');
111 this.view
.$el
.find('.tabs').append(this.applet_panels
.view
.$el
);
114 * Set the UI components up
116 this.controlbox
= new _kiwi
.view
.ControlBox({el
: $('#kiwi .controlbox')[0]});
117 this.bindControllboxCommands(this.controlbox
);
119 this.topicbar
= new _kiwi
.view
.TopicBar({el
: this.view
.$el
.find('.topic')[0]});
121 new _kiwi
.view
.AppToolbar({el
: _kiwi
.app
.view
.$el
.find('.toolbar .app_tools')[0]});
123 this.message
= new _kiwi
.view
.StatusMessage({el
: this.view
.$el
.find('.status_message')[0]});
125 this.resize_handle
= new _kiwi
.view
.ResizeHandler({el
: this.view
.$el
.find('.memberlists_resize_handle')[0]});
127 // Rejigg the UI sizes
128 this.view
.doLayout();
132 this.initializeGlobals = function () {
133 _kiwi
.global
.connections
= this.connections
;
135 _kiwi
.global
.panels
= this.panels
;
136 _kiwi
.global
.panels
.applets
= this.applet_panels
;
138 _kiwi
.global
.components
.Applet
= _kiwi
.model
.Applet
;
139 _kiwi
.global
.components
.Panel
=_kiwi
.model
.Panel
;
143 this.applyDefaultClientSettings = function (settings
) {
144 _
.each(settings
, function (value
, setting
) {
145 if (typeof _kiwi
.global
.settings
.get(setting
) === 'undefined') {
146 _kiwi
.global
.settings
.set(setting
, value
);
152 this.populateDefaultServerSettings = function (new_connection_dialog
) {
166 * Get any settings set by the server
167 * These settings may be changed in the server selection dialog or via URL parameters
169 if (this.server_settings
.client
) {
170 if (this.server_settings
.client
.nick
)
171 defaults
.nick
= this.server_settings
.client
.nick
;
173 if (this.server_settings
.client
.server
)
174 defaults
.server
= this.server_settings
.client
.server
;
176 if (this.server_settings
.client
.port
)
177 defaults
.port
= this.server_settings
.client
.port
;
179 if (this.server_settings
.client
.ssl
)
180 defaults
.ssl
= this.server_settings
.client
.ssl
;
182 if (this.server_settings
.client
.channel
)
183 defaults
.channel
= this.server_settings
.client
.channel
;
189 * Get any settings passed in the URL
190 * These settings may be changed in the server selection dialog
193 // Any query parameters first
194 if (getQueryVariable('nick'))
195 defaults
.nick
= getQueryVariable('nick');
197 if (window
.location
.hash
)
198 defaults
.channel
= window
.location
.hash
;
201 // Process the URL part by part, extracting as we go
202 parts
= window
.location
.pathname
.toString().replace(this.get('base_path'), '').split('/');
204 if (parts
.length
> 0) {
207 if (parts
.length
> 0 && parts
[0]) {
208 // Check to see if we're dealing with an irc: uri, or whether we need to extract the server/channel info from the HTTP URL path.
209 uricheck
= parts
[0].substr(0, 7).toLowerCase();
210 if ((uricheck
=== 'ircs%3a') || (uricheck
.substr(0,6) === 'irc%3a')) {
211 parts
[0] = decodeURIComponent(parts
[0]);
212 // irc[s]://<host>[:<port>]/[<channel>[?<password>]]
213 uricheck
= /^irc(s)?:(?:\/\/?)?([^:\/]+)(?::([0-9]+))?(?:(?:\/)([^\?]*)(?:(?:\?)(.*))?)?$/.exec(parts
[0]);
215 uricheck[1] = ssl (optional)
217 uricheck[3] = port (optional)
218 uricheck[4] = channel (optional)
219 uricheck[5] = channel key (optional, channel must also be set)
222 if (typeof uricheck
[1] !== 'undefined') {
224 if (defaults
.port
=== 6667) {
225 defaults
.port
= 6697;
228 defaults
.server
= uricheck
[2];
229 if (typeof uricheck
[3] !== 'undefined') {
230 defaults
.port
= uricheck
[3];
232 if (typeof uricheck
[4] !== 'undefined') {
233 defaults
.channel
= '#' + uricheck
[4];
234 if (typeof uricheck
[5] !== 'undefined') {
235 defaults
.channel_key
= uricheck
[5];
241 // Extract the port+ssl if we find one
242 if (parts
[0].search(/:/) > 0) {
243 defaults
.port
= parts
[0].substring(parts
[0].search(/:/) + 1);
244 defaults
.server
= parts
[0].substring(0, parts
[0].search(/:/));
245 if (defaults
.port
[0] === '+') {
246 defaults
.port
= parseInt(defaults
.port
.substring(1), 10);
249 defaults
.ssl
= false;
253 defaults
.server
= parts
[0];
260 if (parts
.length
> 0 && parts
[0]) {
261 defaults
.channel
= '#' + parts
[0];
266 // If any settings have been given by the server.. override any auto detected settings
268 * Get any server restrictions as set in the server config
269 * These settings can not be changed in the server selection dialog
271 if (this.server_settings
&& this.server_settings
.connection
) {
272 if (this.server_settings
.connection
.server
) {
273 defaults
.server
= this.server_settings
.connection
.server
;
276 if (this.server_settings
.connection
.port
) {
277 defaults
.port
= this.server_settings
.connection
.port
;
280 if (this.server_settings
.connection
.ssl
) {
281 defaults
.ssl
= this.server_settings
.connection
.ssl
;
284 if (this.server_settings
.connection
.channel
) {
285 defaults
.channel
= this.server_settings
.connection
.channel
;
288 if (this.server_settings
.connection
.nick
) {
289 defaults
.nick
= this.server_settings
.connection
.nick
;
293 // Set any random numbers if needed
294 defaults
.nick
= defaults
.nick
.replace('?', Math
.floor(Math
.random() * 100000).toString());
296 // Populate the server select box with defaults
297 new_connection_dialog
.view
.populateFields(defaults
);
301 this.panels
= (function() {
302 var fn = function(panel_type
) {
305 // Default panel type
306 panel_type
= panel_type
|| 'connections';
308 switch (panel_type
) {
310 panels
= this.connections
.panels();
313 panels
= this.applet_panels
.models
;
317 // Active panels / server
318 panels
.active
= this.connections
.active_panel
;
319 panels
.server
= this.connections
.active_connection
?
320 this.connections
.active_connection
.panels
.server
:
326 _
.extend(fn
, Backbone
.Events
);
332 this.bindGatewayCommands = function (gw
) {
333 gw
.on('onconnect', function (event
) {
334 that
.view
.barsShow();
339 * Handle the reconnections to the kiwi server
344 gw
.on('disconnect', function (event
) {
345 var msg
= _kiwi
.global
.i18n
.translate('client_models_application_reconnecting').fetch() + '...';
346 that
.message
.text(msg
, {timeout
: 10000});
348 that
.view
.$el
.removeClass('connected');
350 // Mention the disconnection on every channel
351 _kiwi
.app
.connections
.forEach(function(connection
) {
352 connection
.panels
.server
.addMsg('', msg
, 'action quit');
354 connection
.panels
.forEach(function(panel
) {
355 if (!panel
.isChannel())
358 panel
.addMsg('', msg
, 'action quit');
366 gw
.on('reconnecting', function (event
) {
367 var msg
= _kiwi
.global
.i18n
.translate('client_models_application_reconnect_in_x_seconds').fetch(event
.delay
/1000) + '...';
369 // Only need to mention the repeating re-connection messages on server panels
370 _kiwi
.app
.connections
.forEach(function(connection
) {
371 connection
.panels
.server
.addMsg('', msg
, 'action quit');
376 gw
.on('onconnect', function (event
) {
377 that
.view
.$el
.addClass('connected');
378 if (gw_stat
!== 1) return;
380 var msg
= _kiwi
.global
.i18n
.translate('client_models_application_reconnect_successfully').fetch() + ':)';
381 that
.message
.text(msg
, {timeout
: 5000});
383 // Mention the disconnection on every channel
384 _kiwi
.app
.connections
.forEach(function(connection
) {
385 connection
.panels
.server
.addMsg('', msg
, 'action join');
387 connection
.panels
.forEach(function(panel
) {
388 if (!panel
.isChannel())
391 panel
.addMsg('', msg
, 'action join');
404 * Bind to certain commands that may be typed into the control box
406 this.bindControllboxCommands = function (controlbox
) {
408 $.extend(controlbox
.preprocessor
.aliases
, {
411 '/me': '/action $1+',
415 '/raw': '/quote $1+',
417 // Op related aliases
418 '/op': '/quote mode $channel +o $1+',
419 '/deop': '/quote mode $channel -o $1+',
420 '/hop': '/quote mode $channel +h $1+',
421 '/dehop': '/quote mode $channel -h $1+',
422 '/voice': '/quote mode $channel +v $1+',
423 '/devoice': '/quote mode $channel -v $1+',
424 '/k': '/kick $channel $1+',
427 '/slap': '/me slaps $1 around a bit with a large trout'
430 controlbox
.on('unknown_command', unknownCommand
);
432 controlbox
.on('command', allCommands
);
433 controlbox
.on('command:msg', msgCommand
);
435 controlbox
.on('command:action', actionCommand
);
437 controlbox
.on('command:join', joinCommand
);
439 controlbox
.on('command:part', partCommand
);
441 controlbox
.on('command:nick', function (ev
) {
442 _kiwi
.gateway
.changeNick(null, ev
.params
[0]);
445 controlbox
.on('command:query', queryCommand
);
447 controlbox
.on('command:topic', topicCommand
);
449 controlbox
.on('command:notice', noticeCommand
);
451 controlbox
.on('command:quote', quoteCommand
);
453 controlbox
.on('command:kick', kickCommand
);
455 controlbox
.on('command:clear', clearCommand
);
457 controlbox
.on('command:ctcp', ctcpCommand
);
459 controlbox
.on('command:server', serverCommand
);
461 controlbox
.on('command:whois', whoisCommand
);
463 controlbox
.on('command:whowas', whowasCommand
);
465 controlbox
.on('command:encoding', encodingCommand
);
467 controlbox
.on('command:css', function (ev
) {
468 var queryString
= '?reload=' + new Date().getTime();
469 $('link[rel="stylesheet"]').each(function () {
470 this.href
= this.href
.replace(/\?.*|$/, queryString
);
474 controlbox
.on('command:js', function (ev
) {
475 if (!ev
.params
[0]) return;
476 $script(ev
.params
[0] + '?' + (new Date().getTime()));
480 controlbox
.on('command:set', function (ev
) {
481 if (!ev
.params
[0]) return;
483 var setting
= ev
.params
[0],
486 // Do we have a second param to set a value?
490 value
= ev
.params
.join(' ');
492 // If we're setting a true boolean value..
493 if (value
=== 'true')
496 // If we're setting a false boolean value..
497 if (value
=== 'false')
500 // If we're setting a number..
501 if (parseInt(value
, 10).toString() === value
)
502 value
= parseInt(value
, 10);
504 _kiwi
.global
.settings
.set(setting
, value
);
507 // Read the value to the user
508 _kiwi
.app
.panels().active
.addMsg('', setting
+ ' = ' + _kiwi
.global
.settings
.get(setting
).toString());
512 controlbox
.on('command:save', function (ev
) {
513 _kiwi
.global
.settings
.save();
514 _kiwi
.app
.panels().active
.addMsg('', _kiwi
.global
.i18n
.translate('client_models_application_settings_saved').fetch());
518 controlbox
.on('command:alias', function (ev
) {
521 // No parameters passed so list them
523 $.each(controlbox
.preprocessor
.aliases
, function (name
, rule
) {
524 _kiwi
.app
.panels().server
.addMsg(' ', name
+ ' => ' + rule
);
529 // Deleting an alias?
530 if (ev
.params
[0] === 'del' || ev
.params
[0] === 'delete') {
532 if (name
[0] !== '/') name
= '/' + name
;
533 delete controlbox
.preprocessor
.aliases
[name
];
540 rule
= ev
.params
.join(' ');
542 // Make sure the name starts with a slash
543 if (name
[0] !== '/') name
= '/' + name
;
545 // Now actually add the alias
546 controlbox
.preprocessor
.aliases
[name
] = rule
;
550 controlbox
.on('command:ignore', function (ev
) {
551 var list
= _kiwi
.gateway
.get('ignore_list');
553 // No parameters passed so list them
555 if (list
.length
> 0) {
556 _kiwi
.app
.panels().active
.addMsg(' ', _kiwi
.global
.i18n
.translate('client_models_application_ignore_title').fetch() + ':');
557 $.each(list
, function (idx
, ignored_pattern
) {
558 _kiwi
.app
.panels().active
.addMsg(' ', ignored_pattern
);
561 _kiwi
.app
.panels().active
.addMsg(' ', _kiwi
.global
.i18n
.translate('client_models_application_ignore_none').fetch());
566 // We have a parameter, so add it
567 list
.push(ev
.params
[0]);
568 _kiwi
.gateway
.set('ignore_list', list
);
569 _kiwi
.app
.panels().active
.addMsg(' ', _kiwi
.global
.i18n
.translate('client_models_application_ignore_nick').fetch(ev
.params
[0]));
573 controlbox
.on('command:unignore', function (ev
) {
574 var list
= _kiwi
.gateway
.get('ignore_list');
577 _kiwi
.app
.panels().active
.addMsg(' ', _kiwi
.global
.i18n
.translate('client_models_application_ignore_stop_notice').fetch());
581 list
= _
.reject(list
, function(pattern
) {
582 return pattern
=== ev
.params
[0];
585 _kiwi
.gateway
.set('ignore_list', list
);
587 _kiwi
.app
.panels().active
.addMsg(' ', _kiwi
.global
.i18n
.translate('client_models_application_ignore_stopped').fetch(ev
.params
[0]));
591 controlbox
.on('command:applet', appletCommand
);
592 controlbox
.on('command:settings', settingsCommand
);
593 controlbox
.on('command:script', scriptCommand
);
596 // A fallback action. Send a raw command to the server
597 function unknownCommand (ev
) {
598 var raw_cmd
= ev
.command
+ ' ' + ev
.params
.join(' ');
599 console
.log('RAW: ' + raw_cmd
);
600 _kiwi
.gateway
.raw(null, raw_cmd
);
603 function allCommands (ev
) {}
605 function joinCommand (ev
) {
606 var panels
, channel_names
;
608 channel_names
= ev
.params
.join(' ').split(',');
609 panels
= that
.connections
.active_connection
.createAndJoinChannels(channel_names
);
611 // Show the last channel if we have one
613 panels
[panels
.length
- 1].view
.show();
616 function queryCommand (ev
) {
617 var destination
, panel
;
619 destination
= ev
.params
[0];
621 // Check if we have the panel already. If not, create it
622 panel
= that
.connections
.active_connection
.panels
.getByName(destination
);
624 panel
= new _kiwi
.model
.Query({name
: destination
});
625 that
.connections
.active_connection
.panels
.add(panel
);
628 if (panel
) panel
.view
.show();
632 function msgCommand (ev
) {
633 var destination
= ev
.params
[0],
634 panel
= that
.connections
.active_connection
.panels
.getByName(destination
) || that
.panels().server
;
638 panel
.addMsg(_kiwi
.app
.connections
.active_connection
.get('nick'), ev
.params
.join(' '));
639 _kiwi
.gateway
.privmsg(null, destination
, ev
.params
.join(' '));
642 function actionCommand (ev
) {
643 if (_kiwi
.app
.panels().active
.isServer()) {
647 var panel
= _kiwi
.app
.panels().active
;
648 panel
.addMsg('', '* ' + _kiwi
.app
.connections
.active_connection
.get('nick') + ' ' + ev
.params
.join(' '), 'action');
649 _kiwi
.gateway
.action(null, panel
.get('name'), ev
.params
.join(' '));
652 function partCommand (ev
) {
653 if (ev
.params
.length
=== 0) {
654 _kiwi
.gateway
.part(null, _kiwi
.app
.panels().active
.get('name'));
656 _
.each(ev
.params
, function (channel
) {
657 _kiwi
.gateway
.part(null, channel
);
662 function topicCommand (ev
) {
665 if (ev
.params
.length
=== 0) return;
667 if (that
.isChannelName(ev
.params
[0])) {
668 channel_name
= ev
.params
[0];
671 channel_name
= _kiwi
.app
.panels().active
.get('name');
674 _kiwi
.gateway
.topic(null, channel_name
, ev
.params
.join(' '));
677 function noticeCommand (ev
) {
680 // Make sure we have a destination and some sort of message
681 if (ev
.params
.length
<= 1) return;
683 destination
= ev
.params
[0];
686 _kiwi
.gateway
.notice(null, destination
, ev
.params
.join(' '));
689 function quoteCommand (ev
) {
690 var raw
= ev
.params
.join(' ');
691 _kiwi
.gateway
.raw(null, raw
);
694 function kickCommand (ev
) {
695 var nick
, panel
= _kiwi
.app
.panels().active
;
697 if (!panel
.isChannel()) return;
699 // Make sure we have a nick
700 if (ev
.params
.length
=== 0) return;
705 _kiwi
.gateway
.kick(null, panel
.get('name'), nick
, ev
.params
.join(' '));
708 function clearCommand (ev
) {
709 // Can't clear a server or applet panel
710 if (_kiwi
.app
.panels().active
.isServer() || _kiwi
.app
.panels().active
.isApplet()) {
714 if (_kiwi
.app
.panels().active
.clearMessages
) {
715 _kiwi
.app
.panels().active
.clearMessages();
719 function ctcpCommand(ev
) {
722 // Make sure we have a target and a ctcp type (eg. version, time)
723 if (ev
.params
.length
< 2) return;
725 target
= ev
.params
[0];
731 _kiwi
.gateway
.ctcp(null, true, type
, target
, ev
.params
.join(' '));
734 function settingsCommand (ev
) {
735 var settings
= _kiwi
.model
.Applet
.loadOnce('kiwi_settings');
736 settings
.view
.show();
739 function scriptCommand (ev
) {
740 var editor
= _kiwi
.model
.Applet
.loadOnce('kiwi_script_editor');
744 function appletCommand (ev
) {
745 if (!ev
.params
[0]) return;
747 var panel
= new _kiwi
.model
.Applet();
750 // Url and name given
751 panel
.load(ev
.params
[0], ev
.params
[1]);
753 // Load a pre-loaded applet
754 if (_kiwi
.applets
[ev
.params
[0]]) {
755 panel
.load(new _kiwi
.applets
[ev
.params
[0]]());
757 _kiwi
.app
.panels().server
.addMsg('', _kiwi
.global
.i18n
.translate('client_models_application_applet_notfound').fetch(ev
.params
[0]));
762 _kiwi
.app
.connections
.active_connection
.panels
.add(panel
);
767 function whoisCommand (ev
) {
772 } else if (_kiwi
.app
.panels().active
.isQuery()) {
773 nick
= _kiwi
.app
.panels().active
.get('name');
777 _kiwi
.app
.connections
.active_connection
.gateway
.raw('WHOIS ' + nick
+ ' ' + nick
);
781 function whowasCommand (ev
) {
786 } else if (_kiwi
.app
.panels().active
.isQuery()) {
787 nick
= _kiwi
.app
.panels().active
.get('name');
791 _kiwi
.app
.connections
.active_connection
.gateway
.raw('WHOWAS ' + nick
);
794 function encodingCommand (ev
) {
796 _kiwi
.gateway
.setEncoding(null, ev
.params
[0], function (success
) {
798 _kiwi
.app
.panels().active
.addMsg('', _kiwi
.global
.i18n
.translate('client_models_application_encoding_changed').fetch(ev
.params
[0]));
800 _kiwi
.app
.panels().active
.addMsg('', _kiwi
.global
.i18n
.translate('client_models_application_encoding_invalid').fetch(ev
.params
[0]));
804 _kiwi
.app
.panels().active
.addMsg('', _kiwi
.global
.i18n
.translate('client_models_application_encoding_notspecified').fetch());
805 _kiwi
.app
.panels().active
.addMsg('', _kiwi
.global
.i18n
.translate('client_models_application_encoding_usage').fetch());
809 function serverCommand (ev
) {
810 var server
, port
, ssl
, password
, nick
,
813 // If no server address given, show the new connection dialog
815 tmp
= new _kiwi
.view
.MenuBox(_kiwi
.global
.i18n
.translate('client_models_application_connection_create').fetch());
816 tmp
.addItem('new_connection', new _kiwi
.model
.NewConnection().view
.$el
);
819 // Center screen the dialog
821 top
: (that
.view
.$el
.height() / 2) - (tmp
.$el
.height() / 2),
822 left
: (that
.view
.$el
.width() / 2) - (tmp
.$el
.width() / 2)
828 // Port given in 'host:port' format and no specific port given after a space
829 if (ev
.params
[0].indexOf(':') > 0) {
830 tmp
= ev
.params
[0].split(':');
834 password
= ev
.params
[1] || undefined;
837 // Server + port given as 'host port'
838 server
= ev
.params
[0];
839 port
= ev
.params
[1] || 6667;
841 password
= ev
.params
[2] || undefined;
844 // + in the port means SSL
845 if (port
.toString()[0] === '+') {
847 port
= parseInt(port
.substring(1), 10);
852 // Default port if one wasn't found
855 // Use the same nick as we currently have
856 nick
= _kiwi
.app
.connections
.active_connection
.get('nick');
858 _kiwi
.app
.panels().active
.addMsg('', _kiwi
.global
.i18n
.translate('client_models_application_connection_connecting').fetch(server
, port
.toString()));
860 _kiwi
.gateway
.newConnection({
866 }, function(err
, new_connection
) {
868 _kiwi
.app
.panels().active
.addMsg('', _kiwi
.global
.i18n
.translate('client_models_application_connection_error').fetch(server
, port
.toString(), err
.toString()));
876 this.isChannelName = function (channel_name
) {
877 var channel_prefix
= _kiwi
.gateway
.get('channel_prefix');
879 if (!channel_name
|| !channel_name
.length
) return false;
880 return (channel_prefix
.indexOf(channel_name
[0]) > -1);
887 model
= Backbone
.Model
.extend(new model());
889 return new model(arguments
);