_kiwi.model.Applet = _kiwi.model.Panel.extend({\r
- // Used to determine if this is an applet panel. Applet panel tabs are treated\r
- // differently than others\r
- applet: true,\r
-\r
-\r
initialize: function (attributes) {\r
// Temporary name\r
var name = "applet_"+(new Date().getTime().toString()) + Math.ceil(Math.random()*100).toString();\r
}\r
\r
this.closePanel();\r
+ },\r
+\r
+ isApplet: function () {\r
+ return true;\r
}\r
},\r
\r
\r
\r
fn_to_bind['command:ignore'] = function (ev) {\r
- var list = _kiwi.gateway.get('ignore_list');\r
+ var list = this.connections.active_connection.get('ignore_list');\r
\r
// No parameters passed so list them\r
if (!ev.params[0]) {\r
\r
// We have a parameter, so add it\r
list.push(ev.params[0]);\r
- _kiwi.gateway.set('ignore_list', list);\r
+ this.connections.active_connection.set('ignore_list', list);\r
_kiwi.app.panels().active.addMsg(' ', _kiwi.global.i18n.translate('client_models_application_ignore_nick').fetch(ev.params[0]));\r
};\r
\r
\r
fn_to_bind['command:unignore'] = function (ev) {\r
- var list = _kiwi.gateway.get('ignore_list');\r
+ var list = this.connections.active_connection.get('ignore_list');\r
\r
if (!ev.params[0]) {\r
_kiwi.app.panels().active.addMsg(' ', _kiwi.global.i18n.translate('client_models_application_ignore_stop_notice').fetch());\r
return pattern === ev.params[0];\r
});\r
\r
- _kiwi.gateway.set('ignore_list', list);\r
+ this.connections.active_connection.set('ignore_list', list);\r
\r
_kiwi.app.panels().active.addMsg(' ', _kiwi.global.i18n.translate('client_models_application_ignore_stopped').fetch(ev.params[0]));\r
};\r
function unknownCommand (ev) {\r
var raw_cmd = ev.command + ' ' + ev.params.join(' ');\r
console.log('RAW: ' + raw_cmd);\r
- _kiwi.gateway.raw(null, raw_cmd);\r
+ this.connections.active_connection.gateway.raw(raw_cmd);\r
}\r
\r
function allCommands (ev) {}\r
message = formatToIrcMsg(ev.params.join(' '));\r
\r
panel.addMsg(_kiwi.app.connections.active_connection.get('nick'), message);\r
- _kiwi.gateway.privmsg(null, destination, message);\r
+ this.connections.active_connection.gateway.privmsg(destination, message);\r
}\r
\r
function actionCommand (ev) {\r
\r
var panel = _kiwi.app.panels().active;\r
panel.addMsg('', '* ' + _kiwi.app.connections.active_connection.get('nick') + ' ' + ev.params.join(' '), 'action');\r
- _kiwi.gateway.action(null, panel.get('name'), ev.params.join(' '));\r
+ this.connections.active_connection.gateway.action(panel.get('name'), ev.params.join(' '));\r
}\r
\r
function partCommand (ev) {\r
if (ev.params.length === 0) {\r
- _kiwi.gateway.part(null, _kiwi.app.panels().active.get('name'));\r
+ this.connections.active_connection.gateway.part(_kiwi.app.panels().active.get('name'));\r
} else {\r
_.each(ev.params, function (channel) {\r
- _kiwi.gateway.part(null, channel);\r
+ this.connections.active_connection.gateway.part(channel);\r
});\r
}\r
}\r
\r
function nickCommand (ev) {\r
- _kiwi.gateway.changeNick(null, ev.params[0]);\r
+ this.connections.active_connection.gateway.changeNick(ev.params[0]);\r
}\r
\r
function topicCommand (ev) {\r
channel_name = _kiwi.app.panels().active.get('name');\r
}\r
\r
- _kiwi.gateway.topic(null, channel_name, ev.params.join(' '));\r
+ this.connections.active_connection.gateway.topic(channel_name, ev.params.join(' '));\r
}\r
\r
function noticeCommand (ev) {\r
destination = ev.params[0];\r
ev.params.shift();\r
\r
- _kiwi.gateway.notice(null, destination, ev.params.join(' '));\r
+ this.connections.active_connection.gateway.notice(destination, ev.params.join(' '));\r
}\r
\r
function quoteCommand (ev) {\r
var raw = ev.params.join(' ');\r
- _kiwi.gateway.raw(null, raw);\r
+ this.connections.active_connection.gateway.raw(raw);\r
}\r
\r
function kickCommand (ev) {\r
nick = ev.params[0];\r
ev.params.shift();\r
\r
- _kiwi.gateway.kick(null, panel.get('name'), nick, ev.params.join(' '));\r
+ this.connections.active_connection.gateway.kick(panel.get('name'), nick, ev.params.join(' '));\r
}\r
\r
function clearCommand (ev) {\r
type = ev.params[0];\r
ev.params.shift();\r
\r
- _kiwi.gateway.ctcp(null, true, type, target, ev.params.join(' '));\r
+ this.connections.active_connection.gateway.ctcp(true, type, target, ev.params.join(' '));\r
}\r
\r
function settingsCommand (ev) {\r
\r
setMode: function(mode_string) {\r
this.get('network').gateway.mode(this.get('name'), mode_string);\r
+ },\r
+\r
+ isChannel: function() {\r
+ return true;\r
}\r
});\r
// Set to a reference to this object within initialize()\r
var that = null;\r
\r
- this.defaults = {\r
- /**\r
- * The name of the network\r
- * @type String\r
- */\r
- name: 'Server',\r
-\r
- /**\r
- * The address (URL) of the network\r
- * @type String\r
- */\r
- address: '',\r
-\r
- /**\r
- * The current nickname\r
- * @type String\r
- */\r
- nick: '',\r
-\r
- /**\r
- * The channel prefix for this network\r
- * @type String\r
- */\r
- channel_prefix: '#',\r
-\r
- /**\r
- * The user prefixes for channel owner/admin/op/voice etc. on this network\r
- * @type Array\r
- */\r
- user_prefixes: ['~', '&', '@', '+'],\r
-\r
- /**\r
- * The URL to the Kiwi server\r
- * @type String\r
- */\r
- kiwi_server: '//kiwi',\r
-\r
- /**\r
- * List of nicks we are ignoring\r
- * @type Array\r
- */\r
- ignore_list: []\r
- };\r
-\r
-\r
this.initialize = function () {\r
that = this;\r
\r
this.sendData(data, callback);\r
};\r
\r
- // Check a nick alongside our ignore list\r
- this.isNickIgnored = function (nick) {\r
- var idx, list = this.get('ignore_list');\r
- var pattern, regex;\r
-\r
- for (idx = 0; idx < list.length; idx++) {\r
- pattern = list[idx].replace(/([.+^$[\]\\(){}|-])/g, "\\$1")\r
- .replace('*', '.*')\r
- .replace('?', '.');\r
-\r
- regex = new RegExp(pattern, 'i');\r
- if (regex.test(nick)) return true;\r
- }\r
-\r
- return false;\r
- };\r
-\r
\r
return new (Backbone.Model.extend(this))(arguments);\r
};\r
* The user prefixes for channel owner/admin/op/voice etc. on this network
* @type Array
*/
- user_prefixes: ['~', '&', '@', '+']
+ user_prefixes: ['~', '&', '@', '+'],
+
+ /**
+ * List of nicks we are ignoring
+ * @type Array
+ */
+ ignore_list: []
},
channel_name = channel_name.trim();
// If not a valid channel name, display a warning
- if (!_kiwi.app.isChannelName(channel_name)) {
+ if (!that.isChannelName(channel_name)) {
that.panels.server.addMsg('', _kiwi.global.i18n.translate('client_models_network_channel_invalid_name').fetch(channel_name));
_kiwi.app.message.text(_kiwi.global.i18n.translate('client_models_network_channel_invalid_name').fetch(channel_name), {timeout: 5000});
return;
that.gateway.join(panel.get('name'));
});
+ },
+
+ isChannelName: function (channel_name) {
+ var channel_prefix = this.get('channel_prefix');
+
+ if (!channel_name || !channel_name.length) return false;
+ return (channel_prefix.indexOf(channel_name[0]) > -1);
+ },
+
+ // Check a nick alongside our ignore list
+ isNickIgnored: function (nick) {
+ var idx, list = this.get('ignore_list');
+ var pattern, regex;
+
+ for (idx = 0; idx < list.length; idx++) {
+ pattern = list[idx].replace(/([.+^$[\]\\(){}|-])/g, "\\$1")
+ .replace('*', '.*')
+ .replace('?', '.');
+
+ regex = new RegExp(pattern, 'i');
+ if (regex.test(nick)) return true;
+ }
+
+ return false;
}
});
is_pm = (event.channel.toLowerCase() == this.get('nick').toLowerCase());
// An ignored user? don't do anything with it
- if (_kiwi.gateway.isNickIgnored(event.nick)) {
+ if (this.isNickIgnored(event.nick)) {
return;
}
function onCtcpRequest(event) {
// An ignored user? don't do anything with it
- if (_kiwi.gateway.isNickIgnored(event.nick)) {
+ if (this.isNickIgnored(event.nick)) {
return;
}
function onCtcpResponse(event) {
// An ignored user? don't do anything with it
- if (_kiwi.gateway.isNickIgnored(event.nick)) {
+ if (this.isNickIgnored(event.nick)) {
return;
}
var panel, channel_name;
// An ignored user? don't do anything with it
- if (!event.from_server && event.nick && _kiwi.gateway.isNickIgnored(event.nick)) {
+ if (!event.from_server && event.nick && this.isNickIgnored(event.nick)) {
return;
}
is_pm = (event.channel.toLowerCase() == this.get('nick').toLowerCase());
// An ignored user? don't do anything with it
- if (_kiwi.gateway.isNickIgnored(event.nick)) {
+ if (this.isNickIgnored(event.nick)) {
return;
}
},\r
\r
isChannel: function () {\r
- var channel_prefix = _kiwi.gateway.get('channel_prefix'),\r
- this_name = this.get('name');\r
-\r
- if (this.isApplet() || !this_name) return false;\r
- return (channel_prefix.indexOf(this_name[0]) > -1);\r
+ return false;\r
},\r
\r
isQuery: function () {\r
- if (!this.isChannel() && !this.isApplet() && !this.isServer()) {\r
- return true;\r
- }\r
-\r
return false;\r
},\r
\r
isApplet: function () {\r
- return this.applet ? true : false;\r
+ return false;\r
},\r
\r
isServer: function () {\r
- return this.server ? true : false;\r
+ return false;\r
},\r
\r
isActive: function () {\r
"name": name,\r
"scrollback": []\r
}, {"silent": true});\r
+ },\r
+\r
+ isChannel: function () {\r
+ return false;\r
+ },\r
+\r
+ isQuery: function () {\r
+ return true;\r
}\r
});
\ No newline at end of file
_kiwi.model.Server = _kiwi.model.Channel.extend({\r
- // Used to determine if this is a server panel\r
- server: true,\r
-\r
initialize: function (attributes) {\r
var name = "Server";\r
this.view = new _kiwi.view.Channel({"model": this, "name": name});\r
}, {"silent": true});\r
\r
//this.addMsg(' ', '--> Kiwi IRC: Such an awesome IRC client', '', {style: 'color:#009900;'});\r
+ },\r
+\r
+ isServer: function () {\r
+ return true;\r
+ },\r
+\r
+ isChannel: function () {\r
+ return false;\r
}\r
});
\ No newline at end of file
nick_colour_hex, nick_hex, is_highlight, msg_css_classes = '',
time_difference,
sb = this.model.get('scrollback'),
- prev_msg = sb[sb.length-2];
+ prev_msg = sb[sb.length-2],
+ network;
// Nick highlight detecting
if ((new RegExp('(^|\\W)(' + escapeRegex(_kiwi.app.connections.active_connection.get('nick')) + ')(\\W|$)', 'i')).test(msg.msg)) {
msg.msg = $('<div />').text(msg.msg).html();
// Make the channels clickable
- re = new RegExp('(?:^|\\s)([' + escapeRegex(_kiwi.gateway.get('channel_prefix')) + '][^ ,\\007]+)', 'g');
- msg.msg = msg.msg.replace(re, function (match) {
- return '<a class="chan" data-channel="' + match.trim() + '">' + match + '</a>';
- });
+ 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="' + match.trim() + '">' + match + '</a>';
+ });
+ }
// Parse any links found
chanClick: function (event) {
- if (event.target) {
- _kiwi.gateway.join(null, $(event.target).data('channel'));
- } else {
- // IE...
- _kiwi.gateway.join(null, $(event.srcElement).data('channel'));
- }
+ var target = (event.target) ? $(event.target).data('channel') : $(event.srcElement).data('channel');
+
+ _kiwi.app.connections.active_connection.gateway.join(target);
},
},
partClick: function (event) {
- _kiwi.gateway.part(null, _kiwi.app.panels().active.get('name'));
+ _kiwi.app.connections.active_connection.gateway.part(_kiwi.app.panels().active.get('name'));
}
});
\ No newline at end of file
// If hit return key, update the current topic
if (ev.keyCode === 13) {
- _kiwi.gateway.topic(null, _kiwi.app.panels().active.get('name'), inp_val);
+ _kiwi.app.connections.active_connection.gateway.topic(_kiwi.app.panels().active.get('name'), inp_val);
return false;
}
},