-kiwi.model.Application = Backbone.Model.extend(new (function () {\r
-\r
+kiwi.model.Application = function () {\r
// Set to a reference to this object within initialize()\r
var that = null;\r
\r
// The auto connect details entered into the server select box\r
var auto_connect_details = {};\r
\r
- /** Instance of kiwi.model.PanelList */\r
- this.panels = null;\r
\r
- /** kiwi.view.Application */\r
- this.view = null;\r
+ var model = function () {\r
+ /** Instance of kiwi.model.PanelList */\r
+ this.panels = null;\r
\r
- /** kiwi.view.StatusMessage */\r
- this.message = null;\r
+ /** kiwi.view.Application */\r
+ this.view = null;\r
\r
- /* Address for the kiwi server */\r
- this.kiwi_server = null;\r
+ /** kiwi.view.StatusMessage */\r
+ this.message = null;\r
\r
- this.initialize = function () {\r
- that = this;\r
+ /* Address for the kiwi server */\r
+ this.kiwi_server = null;\r
\r
- // Best guess at where the kiwi server is\r
- this.detectKiwiServer();\r
- };\r
+ this.initialize = function () {\r
+ that = this;\r
\r
- this.start = function () {\r
- // Only debug if set in the querystring\r
- if (!getQueryVariable('debug')) {\r
- manageDebug(false);\r
- } else {\r
- //manageDebug(true);\r
- }\r
- \r
- // Set the gateway up\r
- kiwi.gateway = new kiwi.model.Gateway();\r
- this.bindGatewayCommands(kiwi.gateway);\r
+ // Best guess at where the kiwi server is\r
+ this.detectKiwiServer();\r
+ };\r
\r
- this.initializeClient();\r
- this.initializeGlobals();\r
+ this.start = function () {\r
+ // Only debug if set in the querystring\r
+ if (!getQueryVariable('debug')) {\r
+ manageDebug(false);\r
+ } else {\r
+ //manageDebug(true);\r
+ }\r
+ \r
+ // Set the gateway up\r
+ kiwi.gateway = new kiwi.model.Gateway();\r
+ this.bindGatewayCommands(kiwi.gateway);\r
\r
- this.view.barsHide(true);\r
+ this.initializeClient();\r
+ this.initializeGlobals();\r
\r
- this.panels.server.server_login.bind('server_connect', function (event) {\r
- var server_login = this;\r
- auto_connect_details = event;\r
+ this.view.barsHide(true);\r
\r
- server_login.networkConnecting();\r
- \r
- $script(that.kiwi_server + '/socket.io/socket.io.js?ts='+(new Date().getTime()), function () {\r
- if (!window.io) {\r
- kiwiServerNotFound();\r
- return;\r
- }\r
- kiwi.gateway.set('kiwi_server', that.kiwi_server + '/kiwi');\r
- kiwi.gateway.set('nick', event.nick);\r
+ this.panels.server.server_login.bind('server_connect', function (event) {\r
+ var server_login = this;\r
+ auto_connect_details = event;\r
+\r
+ server_login.networkConnecting();\r
\r
- kiwi.gateway.connect(event.server, event.port, event.ssl, event.password, function () {});\r
+ $script(that.kiwi_server + '/socket.io/socket.io.js?ts='+(new Date().getTime()), function () {\r
+ if (!window.io) {\r
+ kiwiServerNotFound();\r
+ return;\r
+ }\r
+ kiwi.gateway.set('kiwi_server', that.kiwi_server + '/kiwi');\r
+ kiwi.gateway.set('nick', event.nick);\r
+ \r
+ kiwi.gateway.connect(event.server, event.port, event.ssl, event.password, function () {});\r
+ });\r
});\r
- });\r
-\r
- // TODO: Shouldn't really be here but it's not working in the view.. :/\r
- // Hack for firefox browers: Focus is not given on this event loop iteration\r
- setTimeout(function(){\r
- kiwi.app.panels.server.server_login.$el.find('.nick').select();\r
- }, 0);\r
- };\r
\r
-\r
- function kiwiServerNotFound (e) {\r
- that.panels.server.server_login.showError();\r
- }\r
+ // TODO: Shouldn't really be here but it's not working in the view.. :/\r
+ // Hack for firefox browers: Focus is not given on this event loop iteration\r
+ setTimeout(function(){\r
+ kiwi.app.panels.server.server_login.$el.find('.nick').select();\r
+ }, 0);\r
+ };\r
\r
\r
- this.detectKiwiServer = function () {\r
- // If running from file, default to localhost:7777 by default\r
- if (window.location.protocol === 'file:') {\r
- this.kiwi_server = 'http://localhost:7778';\r
- } else {\r
- // Assume the kiwi server is on the same server\r
- this.kiwi_server = window.location.protocol + '//' + window.location.host;\r
+ function kiwiServerNotFound (e) {\r
+ that.panels.server.server_login.showError();\r
}\r
- };\r
\r
\r
- this.initializeClient = function () {\r
- this.view = new kiwi.view.Application({model: this, el: this.get('container')});\r
- \r
- /**\r
- * Set the UI components up\r
- */\r
- this.panels = new kiwi.model.PanelList();\r
+ this.detectKiwiServer = function () {\r
+ // If running from file, default to localhost:7777 by default\r
+ if (window.location.protocol === 'file:') {\r
+ this.kiwi_server = 'http://localhost:7778';\r
+ } else {\r
+ // Assume the kiwi server is on the same server\r
+ this.kiwi_server = window.location.protocol + '//' + window.location.host;\r
+ }\r
+ };\r
\r
- this.controlbox = new kiwi.view.ControlBox({el: $('#controlbox')[0]});\r
- this.bindControllboxCommands(this.controlbox);\r
\r
- this.topicbar = new kiwi.view.TopicBar({el: $('#topic')[0]});\r
+ this.initializeClient = function () {\r
+ this.view = new kiwi.view.Application({model: this, el: this.get('container')});\r
+ \r
+ /**\r
+ * Set the UI components up\r
+ */\r
+ this.panels = new kiwi.model.PanelList();\r
\r
- this.message = new kiwi.view.StatusMessage({el: $('#status_message')[0]});\r
+ this.controlbox = new kiwi.view.ControlBox({el: $('#controlbox')[0]});\r
+ this.bindControllboxCommands(this.controlbox);\r
\r
- this.resize_handle = new kiwi.view.ResizeHandler({el: $('#memberlists_resize_handle')[0]});\r
- \r
- this.panels.server.view.show();\r
+ this.topicbar = new kiwi.view.TopicBar({el: $('#topic')[0]});\r
\r
- // Rejigg the UI sizes\r
- this.view.doLayout();\r
+ this.message = new kiwi.view.StatusMessage({el: $('#status_message')[0]});\r
\r
- this.populateDefaultServerSettings();\r
- };\r
+ this.resize_handle = new kiwi.view.ResizeHandler({el: $('#memberlists_resize_handle')[0]});\r
+ \r
+ this.panels.server.view.show();\r
\r
+ // Rejigg the UI sizes\r
+ this.view.doLayout();\r
\r
- this.initializeGlobals = function () {\r
- kiwi.global.control = this.controlbox;\r
- };\r
+ this.populateDefaultServerSettings();\r
+ };\r
\r
\r
- this.populateDefaultServerSettings = function () {\r
- var parts;\r
- var defaults = {\r
- nick: getQueryVariable('nick') || 'kiwi_' + Math.ceil(Math.random() * 10000).toString(),\r
- server: 'irc.kiwiirc.com',\r
- port: 6667,\r
- ssl: false,\r
- channel: window.location.hash || '#kiwiirc'\r
+ this.initializeGlobals = function () {\r
+ kiwi.global.control = this.controlbox;\r
};\r
\r
- // Process the URL part by part, extracting as we go\r
- parts = window.location.pathname.toString().split('/');\r
- parts.shift();\r
\r
- if (parts.length > 0 && parts[0].toLowerCase() === 'client') {\r
+ this.populateDefaultServerSettings = function () {\r
+ var parts;\r
+ var defaults = {\r
+ nick: getQueryVariable('nick') || 'kiwi_' + Math.ceil(Math.random() * 10000).toString(),\r
+ server: 'irc.kiwiirc.com',\r
+ port: 6667,\r
+ ssl: false,\r
+ channel: window.location.hash || '#kiwiirc'\r
+ };\r
+\r
+ // Process the URL part by part, extracting as we go\r
+ parts = window.location.pathname.toString().split('/');\r
parts.shift();\r
\r
- if (parts.length > 0 && parts[0]) {\r
- // TODO: Extract the port from this hostname\r
- defaults.server = parts[0];\r
+ if (parts.length > 0 && parts[0].toLowerCase() === 'client') {\r
parts.shift();\r
- }\r
\r
- if (parts.length > 0 && parts[0]) {\r
- defaults.channel = '#' + parts[0];\r
- parts.shift();\r
+ if (parts.length > 0 && parts[0]) {\r
+ // TODO: Extract the port from this hostname\r
+ defaults.server = parts[0];\r
+ parts.shift();\r
+ }\r
+\r
+ if (parts.length > 0 && parts[0]) {\r
+ defaults.channel = '#' + parts[0];\r
+ parts.shift();\r
+ }\r
}\r
- }\r
\r
- // Set any random numbers if needed\r
- defaults.nick = defaults.nick.replace('?', Math.floor(Math.random() * 100000).toString());\r
+ // Set any random numbers if needed\r
+ defaults.nick = defaults.nick.replace('?', Math.floor(Math.random() * 100000).toString());\r
\r
- // Populate the server select box with defaults\r
- this.panels.server.server_login.populateFields(defaults);\r
- };\r
+ // Populate the server select box with defaults\r
+ this.panels.server.server_login.populateFields(defaults);\r
+ };\r
\r
\r
- this.bindGatewayCommands = function (gw) {\r
- gw.on('onmotd', function (event) {\r
- that.panels.server.addMsg(kiwi.gateway.get('name'), event.msg, 'motd');\r
- });\r
+ this.bindGatewayCommands = function (gw) {\r
+ gw.on('onmotd', function (event) {\r
+ that.panels.server.addMsg(kiwi.gateway.get('name'), event.msg, 'motd');\r
+ });\r
\r
\r
- gw.on('onconnect', function (event) {\r
- that.view.barsShow();\r
- \r
- if (auto_connect_details.channel) {\r
- that.controlbox.processInput('/JOIN ' + auto_connect_details.channel);\r
- }\r
- });\r
+ gw.on('onconnect', function (event) {\r
+ that.view.barsShow();\r
+ \r
+ if (auto_connect_details.channel) {\r
+ that.controlbox.processInput('/JOIN ' + auto_connect_details.channel);\r
+ }\r
+ });\r
\r
\r
- (function () {\r
- var gw_stat = 0;\r
+ (function () {\r
+ var gw_stat = 0;\r
\r
- gw.on('disconnect', function (event) {\r
- var msg = 'You have been disconnected. Attempting to reconnect for you..';\r
- that.message.text(msg, {timeout: 10000});\r
+ gw.on('disconnect', function (event) {\r
+ var msg = 'You have been disconnected. Attempting to reconnect for you..';\r
+ that.message.text(msg, {timeout: 10000});\r
\r
- // Mention the disconnection on every channel\r
- $.each(kiwi.app.panels.models, function (idx, panel) {\r
- if (!panel || !panel.isChannel()) return;\r
- panel.addMsg('', msg, 'action quit');\r
+ // Mention the disconnection on every channel\r
+ $.each(kiwi.app.panels.models, function (idx, panel) {\r
+ if (!panel || !panel.isChannel()) return;\r
+ panel.addMsg('', msg, 'action quit');\r
+ });\r
+ kiwi.app.panels.server.addMsg('', msg, 'action quit');\r
+\r
+ gw_stat = 1;\r
+ });\r
+ gw.on('reconnecting', function (event) {\r
+ msg = 'You have been disconnected. Attempting to reconnect again in ' + (event.delay/1000) + ' seconds..';\r
+ kiwi.app.panels.server.addMsg('', msg, 'action quit');\r
});\r
- kiwi.app.panels.server.addMsg('', msg, 'action quit');\r
+ gw.on('connect', function (event) {\r
+ if (gw_stat !== 1) return;\r
\r
- gw_stat = 1;\r
- });\r
- gw.on('reconnecting', function (event) {\r
- msg = 'You have been disconnected. Attempting to reconnect again in ' + (event.delay/1000) + ' seconds..';\r
- kiwi.app.panels.server.addMsg('', msg, 'action quit');\r
- });\r
- gw.on('connect', function (event) {\r
- if (gw_stat !== 1) return;\r
+ var msg = 'It\'s OK, you\'re connected again :)';\r
+ that.message.text(msg, {timeout: 5000});\r
\r
- var msg = 'It\'s OK, you\'re connected again :)';\r
- that.message.text(msg, {timeout: 5000});\r
+ // Mention the disconnection on every channel\r
+ $.each(kiwi.app.panels.models, function (idx, panel) {\r
+ if (!panel || !panel.isChannel()) return;\r
+ panel.addMsg('', msg, 'action join');\r
+ });\r
+ kiwi.app.panels.server.addMsg('', msg, 'action join');\r
\r
- // Mention the disconnection on every channel\r
- $.each(kiwi.app.panels.models, function (idx, panel) {\r
- if (!panel || !panel.isChannel()) return;\r
- panel.addMsg('', msg, 'action join');\r
+ gw_stat = 0;\r
});\r
- kiwi.app.panels.server.addMsg('', msg, 'action join');\r
-\r
- gw_stat = 0;\r
- });\r
- })();\r
+ })();\r
\r
\r
- gw.on('onjoin', function (event) {\r
- var c, members, user;\r
- c = that.panels.getByName(event.channel);\r
- if (!c) {\r
- c = new kiwi.model.Channel({name: event.channel});\r
- that.panels.add(c);\r
- }\r
+ gw.on('onjoin', function (event) {\r
+ var c, members, user;\r
+ c = that.panels.getByName(event.channel);\r
+ if (!c) {\r
+ c = new kiwi.model.Channel({name: event.channel});\r
+ that.panels.add(c);\r
+ }\r
\r
- members = c.get('members');\r
- if (!members) return;\r
+ members = c.get('members');\r
+ if (!members) return;\r
\r
- user = new kiwi.model.Member({nick: event.nick, ident: event.ident, hostname: event.hostname});\r
- members.add(user);\r
- // TODO: highlight the new channel in some way\r
- });\r
+ user = new kiwi.model.Member({nick: event.nick, ident: event.ident, hostname: event.hostname});\r
+ members.add(user);\r
+ // TODO: highlight the new channel in some way\r
+ });\r
\r
\r
- gw.on('onpart', function (event) {\r
- var channel, members, user,\r
- part_options = {};\r
+ gw.on('onpart', function (event) {\r
+ var channel, members, user,\r
+ part_options = {};\r
\r
- part_options.type = 'part';\r
- part_options.message = event.message || '';\r
+ part_options.type = 'part';\r
+ part_options.message = event.message || '';\r
\r
- channel = that.panels.getByName(event.channel);\r
- if (!channel) return;\r
+ channel = that.panels.getByName(event.channel);\r
+ if (!channel) return;\r
\r
- // If this is us, close the panel\r
- if (event.nick === kiwi.gateway.get('nick')) {\r
- channel.close();\r
- return;\r
- }\r
+ // If this is us, close the panel\r
+ if (event.nick === kiwi.gateway.get('nick')) {\r
+ channel.close();\r
+ return;\r
+ }\r
\r
- members = channel.get('members');\r
- if (!members) return;\r
+ members = channel.get('members');\r
+ if (!members) return;\r
\r
- user = members.getByNick(event.nick);\r
- if (!user) return;\r
+ user = members.getByNick(event.nick);\r
+ if (!user) return;\r
\r
- members.remove(user, part_options);\r
- });\r
+ members.remove(user, part_options);\r
+ });\r
\r
\r
- gw.on('onquit', function (event) {\r
- var member, members,\r
- quit_options = {};\r
+ gw.on('onquit', function (event) {\r
+ var member, members,\r
+ quit_options = {};\r
\r
- quit_options.type = 'quit';\r
- quit_options.message = event.message || '';\r
+ quit_options.type = 'quit';\r
+ quit_options.message = event.message || '';\r
\r
- $.each(that.panels.models, function (index, panel) {\r
- if (!panel.isChannel()) return;\r
+ $.each(that.panels.models, function (index, panel) {\r
+ if (!panel.isChannel()) return;\r
\r
- member = panel.get('members').getByNick(event.nick);\r
- if (member) {\r
- panel.get('members').remove(member, quit_options);\r
- }\r
+ member = panel.get('members').getByNick(event.nick);\r
+ if (member) {\r
+ panel.get('members').remove(member, quit_options);\r
+ }\r
+ });\r
});\r
- });\r
\r
\r
- gw.on('onkick', function (event) {\r
- var channel, members, user,\r
- part_options = {};\r
+ gw.on('onkick', function (event) {\r
+ var channel, members, user,\r
+ part_options = {};\r
\r
- part_options.type = 'kick';\r
- part_options.by = event.nick;\r
- part_options.message = event.message || '';\r
+ part_options.type = 'kick';\r
+ part_options.by = event.nick;\r
+ part_options.message = event.message || '';\r
\r
- channel = that.panels.getByName(event.channel);\r
- if (!channel) return;\r
+ channel = that.panels.getByName(event.channel);\r
+ if (!channel) return;\r
\r
- members = channel.get('members');\r
- if (!members) return;\r
+ members = channel.get('members');\r
+ if (!members) return;\r
\r
- user = members.getByNick(event.kicked);\r
- if (!user) return;\r
+ user = members.getByNick(event.kicked);\r
+ if (!user) return;\r
\r
- members.remove(user, part_options);\r
+ members.remove(user, part_options);\r
\r
- if (event.kicked === kiwi.gateway.get('nick')) {\r
- members.reset([]);\r
- }\r
- \r
- });\r
+ if (event.kicked === kiwi.gateway.get('nick')) {\r
+ members.reset([]);\r
+ }\r
+ \r
+ });\r
\r
\r
- gw.on('onmsg', function (event) {\r
- var panel,\r
- is_pm = (event.channel == kiwi.gateway.get('nick'));\r
+ gw.on('onmsg', function (event) {\r
+ var panel,\r
+ is_pm = (event.channel == kiwi.gateway.get('nick'));\r
\r
- if (is_pm) {\r
- // If a panel isn't found for this PM, create one\r
- panel = that.panels.getByName(event.nick);\r
- if (!panel) {\r
- panel = new kiwi.model.Channel({name: event.nick});\r
- that.panels.add(panel);\r
- }\r
+ if (is_pm) {\r
+ // If a panel isn't found for this PM, create one\r
+ panel = that.panels.getByName(event.nick);\r
+ if (!panel) {\r
+ panel = new kiwi.model.Channel({name: event.nick});\r
+ that.panels.add(panel);\r
+ }\r
\r
- } else {\r
- // If a panel isn't found for this channel, reroute to the\r
- // server panel\r
- panel = that.panels.getByName(event.channel);\r
- if (!panel) {\r
- panel = that.panels.server;\r
+ } else {\r
+ // If a panel isn't found for this channel, reroute to the\r
+ // server panel\r
+ panel = that.panels.getByName(event.channel);\r
+ if (!panel) {\r
+ panel = that.panels.server;\r
+ }\r
}\r
- }\r
- \r
- panel.addMsg(event.nick, event.msg);\r
- });\r
+ \r
+ panel.addMsg(event.nick, event.msg);\r
+ });\r
\r
\r
- gw.on('onnotice', function (event) {\r
- var panel;\r
+ gw.on('onnotice', function (event) {\r
+ var panel;\r
\r
- // Find a panel for the destination(channel) or who its from\r
- panel = that.panels.getByName(event.target) || that.panels.getByName(event.nick);\r
- if (!panel) {\r
- panel = that.panels.server;\r
- }\r
+ // Find a panel for the destination(channel) or who its from\r
+ panel = that.panels.getByName(event.target) || that.panels.getByName(event.nick);\r
+ if (!panel) {\r
+ panel = that.panels.server;\r
+ }\r
\r
- panel.addMsg('[' + (event.nick||'') + ']', event.msg);\r
- });\r
+ panel.addMsg('[' + (event.nick||'') + ']', event.msg);\r
+ });\r
\r
\r
- gw.on('onaction', function (event) {\r
- var panel,\r
- is_pm = (event.channel == kiwi.gateway.get('nick'));\r
+ gw.on('onaction', function (event) {\r
+ var panel,\r
+ is_pm = (event.channel == kiwi.gateway.get('nick'));\r
\r
- if (is_pm) {\r
- // If a panel isn't found for this PM, create one\r
- panel = that.panels.getByName(event.nick);\r
- if (!panel) {\r
- panel = new kiwi.model.Channel({name: event.nick});\r
- that.panels.add(panel);\r
- }\r
+ if (is_pm) {\r
+ // If a panel isn't found for this PM, create one\r
+ panel = that.panels.getByName(event.nick);\r
+ if (!panel) {\r
+ panel = new kiwi.model.Channel({name: event.nick});\r
+ that.panels.add(panel);\r
+ }\r
\r
- } else {\r
- // If a panel isn't found for this channel, reroute to the\r
- // server panel\r
- panel = that.panels.getByName(event.channel);\r
- if (!panel) {\r
- panel = that.panels.server;\r
+ } else {\r
+ // If a panel isn't found for this channel, reroute to the\r
+ // server panel\r
+ panel = that.panels.getByName(event.channel);\r
+ if (!panel) {\r
+ panel = that.panels.server;\r
+ }\r
}\r
- }\r
\r
- panel.addMsg('', '* ' + event.nick + ' ' + event.msg, 'action');\r
- });\r
+ panel.addMsg('', '* ' + event.nick + ' ' + event.msg, 'action');\r
+ });\r
\r
\r
- gw.on('ontopic', function (event) {\r
- var c;\r
- c = that.panels.getByName(event.channel);\r
- if (!c) return;\r
+ gw.on('ontopic', function (event) {\r
+ var c;\r
+ c = that.panels.getByName(event.channel);\r
+ if (!c) return;\r
\r
- // Set the channels topic\r
- c.set('topic', event.topic);\r
+ // Set the channels topic\r
+ c.set('topic', event.topic);\r
\r
- // If this is the active channel, update the topic bar too\r
- if (c.get('name') === kiwi.app.panels.active.get('name')) {\r
- that.topicbar.setCurrentTopic(event.topic);\r
- }\r
- });\r
+ // If this is the active channel, update the topic bar too\r
+ if (c.get('name') === kiwi.app.panels.active.get('name')) {\r
+ that.topicbar.setCurrentTopic(event.topic);\r
+ }\r
+ });\r
\r
\r
- gw.on('ontopicsetby', function (event) {\r
- var c, when;\r
- c = that.panels.getByName(event.channel);\r
- if (!c) return;\r
+ gw.on('ontopicsetby', function (event) {\r
+ var c, when;\r
+ c = that.panels.getByName(event.channel);\r
+ if (!c) return;\r
\r
- when = formatDate(new Date(event.when * 1000));\r
- c.addMsg('', 'Topic set by ' + event.nick + ' at ' + when, 'topic');\r
- });\r
+ when = formatDate(new Date(event.when * 1000));\r
+ c.addMsg('', 'Topic set by ' + event.nick + ' at ' + when, 'topic');\r
+ });\r
\r
\r
- gw.on('onuserlist', function (event) {\r
- var channel;\r
- channel = that.panels.getByName(event.channel);\r
+ gw.on('onuserlist', function (event) {\r
+ var channel;\r
+ channel = that.panels.getByName(event.channel);\r
\r
- // If we didn't find a channel for this, may aswell leave\r
- if (!channel) return;\r
+ // If we didn't find a channel for this, may aswell leave\r
+ if (!channel) return;\r
\r
- channel.temp_userlist = channel.temp_userlist || [];\r
- _.each(event.users, function (item) {\r
- var user = new kiwi.model.Member({nick: item.nick, modes: item.modes});\r
- channel.temp_userlist.push(user);\r
+ channel.temp_userlist = channel.temp_userlist || [];\r
+ _.each(event.users, function (item) {\r
+ var user = new kiwi.model.Member({nick: item.nick, modes: item.modes});\r
+ channel.temp_userlist.push(user);\r
+ });\r
});\r
- });\r
\r
\r
- gw.on('onuserlist_end', function (event) {\r
- var channel;\r
- channel = that.panels.getByName(event.channel);\r
+ gw.on('onuserlist_end', function (event) {\r
+ var channel;\r
+ channel = that.panels.getByName(event.channel);\r
\r
- // If we didn't find a channel for this, may aswell leave\r
- if (!channel) return;\r
+ // If we didn't find a channel for this, may aswell leave\r
+ if (!channel) return;\r
\r
- // Update the members list with the new list\r
- channel.get('members').reset(channel.temp_userlist || []);\r
+ // Update the members list with the new list\r
+ channel.get('members').reset(channel.temp_userlist || []);\r
\r
- // Clear the temporary userlist\r
- delete channel.temp_userlist;\r
- });\r
+ // Clear the temporary userlist\r
+ delete channel.temp_userlist;\r
+ });\r
\r
\r
- gw.on('onmode', function (event) {\r
- var channel, i, prefixes, members, member, find_prefix;\r
- \r
- // Build a nicely formatted string to be displayed to a regular human\r
- function friendlyModeString (event_modes, alt_target) {\r
- var modes = {}, return_string;\r
-\r
- // If no default given, use the main event info\r
- if (!event_modes) {\r
- event_modes = event.modes;\r
- alt_target = event.target;\r
- }\r
+ gw.on('onmode', function (event) {\r
+ var channel, i, prefixes, members, member, find_prefix;\r
+ \r
+ // Build a nicely formatted string to be displayed to a regular human\r
+ function friendlyModeString (event_modes, alt_target) {\r
+ var modes = {}, return_string;\r
+\r
+ // If no default given, use the main event info\r
+ if (!event_modes) {\r
+ event_modes = event.modes;\r
+ alt_target = event.target;\r
+ }\r
\r
- // Reformat the mode object to make it easier to work with\r
- _.each(event_modes, function (mode){\r
- var param = mode.param || alt_target || '';\r
+ // Reformat the mode object to make it easier to work with\r
+ _.each(event_modes, function (mode){\r
+ var param = mode.param || alt_target || '';\r
\r
- // Make sure we have some modes for this param\r
- if (!modes[param]) {\r
- modes[param] = {'+':'', '-':''};\r
- }\r
+ // Make sure we have some modes for this param\r
+ if (!modes[param]) {\r
+ modes[param] = {'+':'', '-':''};\r
+ }\r
\r
- modes[param][mode.mode[0]] += mode.mode.substr(1);\r
- });\r
+ modes[param][mode.mode[0]] += mode.mode.substr(1);\r
+ });\r
\r
- // Put the string together from each mode\r
- return_string = [];\r
- _.each(modes, function (modeset, param) {\r
- var str = '';\r
- if (modeset['+']) str += '+' + modeset['+'];\r
- if (modeset['-']) str += '-' + modeset['-'];\r
- return_string.push(str + ' ' + param);\r
- });\r
- return_string = return_string.join(', ');\r
+ // Put the string together from each mode\r
+ return_string = [];\r
+ _.each(modes, function (modeset, param) {\r
+ var str = '';\r
+ if (modeset['+']) str += '+' + modeset['+'];\r
+ if (modeset['-']) str += '-' + modeset['-'];\r
+ return_string.push(str + ' ' + param);\r
+ });\r
+ return_string = return_string.join(', ');\r
\r
- return return_string;\r
- }\r
+ return return_string;\r
+ }\r
\r
\r
- channel = that.panels.getByName(event.target);\r
- if (channel) {\r
- prefixes = kiwi.gateway.get('user_prefixes');\r
- find_prefix = function (p) {\r
- return event.modes[i].mode[1] === p.mode;\r
- };\r
- for (i = 0; i < event.modes.length; i++) {\r
- if (_.any(prefixes, find_prefix)) {\r
- if (!members) {\r
- members = channel.get('members');\r
- }\r
- member = members.getByNick(event.modes[i].param);\r
- if (!member) {\r
- console.log('MODE command recieved for unknown member %s on channel %s', event.modes[i].param, event.target);\r
- return;\r
- } else {\r
- if (event.modes[i].mode[0] === '+') {\r
- member.addMode(event.modes[i].mode[1]);\r
- } else if (event.modes[i].mode[0] === '-') {\r
- member.removeMode(event.modes[i].mode[1]);\r
+ channel = that.panels.getByName(event.target);\r
+ if (channel) {\r
+ prefixes = kiwi.gateway.get('user_prefixes');\r
+ find_prefix = function (p) {\r
+ return event.modes[i].mode[1] === p.mode;\r
+ };\r
+ for (i = 0; i < event.modes.length; i++) {\r
+ if (_.any(prefixes, find_prefix)) {\r
+ if (!members) {\r
+ members = channel.get('members');\r
}\r
- members.sort();\r
- //channel.addMsg('', '=== ' + event.nick + ' set mode ' + event.modes[i].mode + ' ' + event.modes[i].param, 'action mode');\r
+ member = members.getByNick(event.modes[i].param);\r
+ if (!member) {\r
+ console.log('MODE command recieved for unknown member %s on channel %s', event.modes[i].param, event.target);\r
+ return;\r
+ } else {\r
+ if (event.modes[i].mode[0] === '+') {\r
+ member.addMode(event.modes[i].mode[1]);\r
+ } else if (event.modes[i].mode[0] === '-') {\r
+ member.removeMode(event.modes[i].mode[1]);\r
+ }\r
+ members.sort();\r
+ //channel.addMsg('', '=== ' + event.nick + ' set mode ' + event.modes[i].mode + ' ' + event.modes[i].param, 'action mode');\r
+ }\r
+ } else {\r
+ // Channel mode being set\r
+ // TODO: Store this somewhere?\r
+ //channel.addMsg('', 'CHANNEL === ' + event.nick + ' set mode ' + event.modes[i].mode + ' on ' + event.target, 'action mode');\r
}\r
- } else {\r
- // Channel mode being set\r
- // TODO: Store this somewhere?\r
- //channel.addMsg('', 'CHANNEL === ' + event.nick + ' set mode ' + event.modes[i].mode + ' on ' + event.target, 'action mode');\r
}\r
- }\r
\r
- channel.addMsg('', '=== ' + event.nick + ' sets mode ' + friendlyModeString(), 'action mode');\r
- } else {\r
- // This is probably a mode being set on us.\r
- if (event.target.toLowerCase() === kiwi.gateway.get("nick").toLowerCase()) {\r
- that.panels.server.addMsg('', '=== ' + event.nick + ' set mode ' + friendlyModeString(), 'action mode');\r
+ channel.addMsg('', '=== ' + event.nick + ' sets mode ' + friendlyModeString(), 'action mode');\r
} else {\r
- console.log('MODE command recieved for unknown target %s: ', event.target, event);\r
+ // This is probably a mode being set on us.\r
+ if (event.target.toLowerCase() === kiwi.gateway.get("nick").toLowerCase()) {\r
+ that.panels.server.addMsg('', '=== ' + event.nick + ' set mode ' + friendlyModeString(), 'action mode');\r
+ } else {\r
+ console.log('MODE command recieved for unknown target %s: ', event.target, event);\r
+ }\r
}\r
- }\r
- });\r
+ });\r
\r
\r
- gw.on('onnick', function (event) {\r
- var member;\r
+ gw.on('onnick', function (event) {\r
+ var member;\r
\r
- $.each(that.panels.models, function (index, panel) {\r
- if (!panel.isChannel()) return;\r
+ $.each(that.panels.models, function (index, panel) {\r
+ if (!panel.isChannel()) return;\r
\r
- member = panel.get('members').getByNick(event.nick);\r
- if (member) {\r
- member.set('nick', event.newnick);\r
- panel.addMsg('', '== ' + event.nick + ' is now known as ' + event.newnick, 'action nick');\r
- }\r
+ member = panel.get('members').getByNick(event.nick);\r
+ if (member) {\r
+ member.set('nick', event.newnick);\r
+ panel.addMsg('', '== ' + event.nick + ' is now known as ' + event.newnick, 'action nick');\r
+ }\r
+ });\r
});\r
- });\r
-\r
\r
- gw.on('onwhois', function (event) {\r
- /*globals secondsToTime */\r
- var logon_date, idle_time = '', panel;\r
\r
- if (event.end) {\r
- return;\r
- }\r
+ gw.on('onwhois', function (event) {\r
+ /*globals secondsToTime */\r
+ var logon_date, idle_time = '', panel;\r
\r
- if (typeof event.idle !== 'undefined') {\r
- idle_time = secondsToTime(parseInt(event.idle, 10));\r
- idle_time = idle_time.h.toString().lpad(2, "0") + ':' + idle_time.m.toString().lpad(2, "0") + ':' + idle_time.s.toString().lpad(2, "0");\r
- }\r
+ if (event.end) {\r
+ return;\r
+ }\r
\r
- panel = kiwi.app.panels.active;\r
- if (event.ident) {\r
- panel.addMsg(event.nick, 'is ' + event.nick + '!' + event.ident + '@' + event.host + ' * ' + event.msg, 'whois');\r
- } else if (event.chans) {\r
- panel.addMsg(event.nick, 'on ' + event.chans, 'whois');\r
- } else if (event.server) {\r
- panel.addMsg(event.nick, 'using ' + event.server, 'whois');\r
- } else if (event.msg) {\r
- panel.addMsg(event.nick, event.msg, 'whois');\r
- } else if (event.logon) {\r
- logon_date = new Date();\r
- logon_date.setTime(event.logon * 1000);\r
- logon_date = formatDate(logon_date);\r
-\r
- panel.addMsg(event.nick, 'idle for ' + idle_time + ', signed on ' + logon_date, 'whois');\r
- } else {\r
- panel.addMsg(event.nick, 'idle for ' + idle_time, 'whois');\r
- }\r
- });\r
+ if (typeof event.idle !== 'undefined') {\r
+ idle_time = secondsToTime(parseInt(event.idle, 10));\r
+ idle_time = idle_time.h.toString().lpad(2, "0") + ':' + idle_time.m.toString().lpad(2, "0") + ':' + idle_time.s.toString().lpad(2, "0");\r
+ }\r
\r
+ panel = kiwi.app.panels.active;\r
+ if (event.ident) {\r
+ panel.addMsg(event.nick, 'is ' + event.nick + '!' + event.ident + '@' + event.host + ' * ' + event.msg, 'whois');\r
+ } else if (event.chans) {\r
+ panel.addMsg(event.nick, 'on ' + event.chans, 'whois');\r
+ } else if (event.server) {\r
+ panel.addMsg(event.nick, 'using ' + event.server, 'whois');\r
+ } else if (event.msg) {\r
+ panel.addMsg(event.nick, event.msg, 'whois');\r
+ } else if (event.logon) {\r
+ logon_date = new Date();\r
+ logon_date.setTime(event.logon * 1000);\r
+ logon_date = formatDate(logon_date);\r
+\r
+ panel.addMsg(event.nick, 'idle for ' + idle_time + ', signed on ' + logon_date, 'whois');\r
+ } else {\r
+ panel.addMsg(event.nick, 'idle for ' + idle_time, 'whois');\r
+ }\r
+ });\r
\r
- gw.on('onlist_start', function (data) {\r
- if (kiwi.app.channel_list) {\r
- kiwi.app.channel_list.close();\r
- delete kiwi.app.channel_list;\r
- }\r
\r
- var panel = new kiwi.model.Applet(),\r
- applet = new kiwi.applets.Chanlist();\r
+ gw.on('onlist_start', function (data) {\r
+ if (kiwi.app.channel_list) {\r
+ kiwi.app.channel_list.close();\r
+ delete kiwi.app.channel_list;\r
+ }\r
\r
- panel.load(applet);\r
- \r
- kiwi.app.panels.add(panel);\r
- panel.view.show();\r
- \r
- kiwi.app.channel_list = applet;\r
- });\r
+ var panel = new kiwi.model.Applet(),\r
+ applet = new kiwi.applets.Chanlist();\r
\r
+ panel.load(applet);\r
+ \r
+ kiwi.app.panels.add(panel);\r
+ panel.view.show();\r
+ \r
+ kiwi.app.channel_list = applet;\r
+ });\r
\r
- gw.on('onlist_channel', function (data) {\r
- // TODO: Put this listener within the applet itself\r
- kiwi.app.channel_list.addChannel(data.chans);\r
- });\r
\r
+ gw.on('onlist_channel', function (data) {\r
+ // TODO: Put this listener within the applet itself\r
+ kiwi.app.channel_list.addChannel(data.chans);\r
+ });\r
\r
- gw.on('onlist_end', function (data) {\r
- // TODO: Put this listener within the applet itself\r
- delete kiwi.app.channel_list;\r
- });\r
\r
+ gw.on('onlist_end', function (data) {\r
+ // TODO: Put this listener within the applet itself\r
+ delete kiwi.app.channel_list;\r
+ });\r
\r
- gw.on('onirc_error', function (data) {\r
- var panel, tmp;\r
\r
- if (data.channel !== undefined && !(panel = kiwi.app.panels.getByName(data.channel))) {\r
- panel = kiwi.app.panels.server;\r
- }\r
+ gw.on('onirc_error', function (data) {\r
+ var panel, tmp;\r
\r
- switch (data.error) {\r
- case 'banned_from_channel':\r
- panel.addMsg(' ', '=== You are banned from ' + data.channel + '. ' + data.reason, 'status');\r
- kiwi.app.message.text('You are banned from ' + data.channel + '. ' + data.reason);\r
- break;\r
- case 'bad_channel_key':\r
- panel.addMsg(' ', '=== Bad channel key for ' + data.channel, 'status');\r
- kiwi.app.message.text('Bad channel key or password for ' + data.channel);\r
- break;\r
- case 'invite_only_channel':\r
- panel.addMsg(' ', '=== ' + data.channel + ' is invite only.', 'status');\r
- kiwi.app.message.text(data.channel + ' is invite only');\r
- break;\r
- case 'channel_is_full':\r
- panel.addMsg(' ', '=== ' + data.channel + ' is full.', 'status');\r
- kiwi.app.message.text(data.channel + ' is full');\r
- break;\r
- case 'chanop_privs_needed':\r
- panel.addMsg(' ', '=== ' + data.reason, 'status');\r
- kiwi.app.message.text(data.reason + ' (' + data.channel + ')');\r
- break;\r
- case 'no_such_nick':\r
- tmp = kiwi.app.panels.getByName(data.nick);\r
- if (tmp) {\r
- tmp.addMsg(' ', '=== ' + data.nick + ': ' + data.reason, 'status');\r
- } else {\r
- kiwi.app.panels.server.addMsg(' ', '=== ' + data.nick + ': ' + data.reason, 'status');\r
- }\r
- break;\r
- case 'nickname_in_use':\r
- kiwi.app.panels.server.addMsg(' ', '=== The nickname ' + data.nick + ' is already in use. Please select a new nickname', 'status');\r
- if (kiwi.app.panels.server !== kiwi.app.panels.active) {\r
- kiwi.app.message.text('The nickname "' + data.nick + '" is already in use. Please select a new nickname');\r
+ if (data.channel !== undefined && !(panel = kiwi.app.panels.getByName(data.channel))) {\r
+ panel = kiwi.app.panels.server;\r
}\r
\r
- // Only show the nickchange component if the controlbox is open\r
- if (that.controlbox.$el.css('display') !== 'none') {\r
- (new kiwi.view.NickChangeBox()).render();\r
+ switch (data.error) {\r
+ case 'banned_from_channel':\r
+ panel.addMsg(' ', '=== You are banned from ' + data.channel + '. ' + data.reason, 'status');\r
+ kiwi.app.message.text('You are banned from ' + data.channel + '. ' + data.reason);\r
+ break;\r
+ case 'bad_channel_key':\r
+ panel.addMsg(' ', '=== Bad channel key for ' + data.channel, 'status');\r
+ kiwi.app.message.text('Bad channel key or password for ' + data.channel);\r
+ break;\r
+ case 'invite_only_channel':\r
+ panel.addMsg(' ', '=== ' + data.channel + ' is invite only.', 'status');\r
+ kiwi.app.message.text(data.channel + ' is invite only');\r
+ break;\r
+ case 'channel_is_full':\r
+ panel.addMsg(' ', '=== ' + data.channel + ' is full.', 'status');\r
+ kiwi.app.message.text(data.channel + ' is full');\r
+ break;\r
+ case 'chanop_privs_needed':\r
+ panel.addMsg(' ', '=== ' + data.reason, 'status');\r
+ kiwi.app.message.text(data.reason + ' (' + data.channel + ')');\r
+ break;\r
+ case 'no_such_nick':\r
+ tmp = kiwi.app.panels.getByName(data.nick);\r
+ if (tmp) {\r
+ tmp.addMsg(' ', '=== ' + data.nick + ': ' + data.reason, 'status');\r
+ } else {\r
+ kiwi.app.panels.server.addMsg(' ', '=== ' + data.nick + ': ' + data.reason, 'status');\r
+ }\r
+ break;\r
+ case 'nickname_in_use':\r
+ kiwi.app.panels.server.addMsg(' ', '=== The nickname ' + data.nick + ' is already in use. Please select a new nickname', 'status');\r
+ if (kiwi.app.panels.server !== kiwi.app.panels.active) {\r
+ kiwi.app.message.text('The nickname "' + data.nick + '" is already in use. Please select a new nickname');\r
+ }\r
+\r
+ // Only show the nickchange component if the controlbox is open\r
+ if (that.controlbox.$el.css('display') !== 'none') {\r
+ (new kiwi.view.NickChangeBox()).render();\r
+ }\r
+\r
+ break;\r
+ default:\r
+ // We don't know what data contains, so don't do anything with it.\r
+ //kiwi.front.tabviews.server.addMsg(null, ' ', '=== ' + data, 'status');\r
}\r
+ });\r
+ };\r
\r
- break;\r
- default:\r
- // We don't know what data contains, so don't do anything with it.\r
- //kiwi.front.tabviews.server.addMsg(null, ' ', '=== ' + data, 'status');\r
- }\r
- });\r
- };\r
\r
\r
+ /**\r
+ * Bind to certain commands that may be typed into the control box\r
+ */\r
+ this.bindControllboxCommands = function (controlbox) {\r
+ // Default aliases\r
+ $.extend(controlbox.preprocessor.aliases, {\r
+ '/p': '/part $1+',\r
+ '/me': '/action $1+',\r
+ '/j': '/join $1+',\r
+ '/q': '/query $1+',\r
+ '/k': '/kick $1+'\r
+ });\r
\r
- /**\r
- * Bind to certain commands that may be typed into the control box\r
- */\r
- this.bindControllboxCommands = function (controlbox) {\r
- // Default aliases\r
- $.extend(controlbox.preprocessor.aliases, {\r
- '/p': '/part $1+',\r
- '/me': '/action $1+',\r
- '/j': '/join $1+',\r
- '/q': '/query $1+',\r
- '/k': '/kick $1+'\r
- });\r
+ controlbox.on('unknown_command', unknownCommand);\r
\r
- controlbox.on('unknown_command', unknownCommand);\r
+ controlbox.on('command', allCommands);\r
+ controlbox.on('command_msg', msgCommand);\r
\r
- controlbox.on('command', allCommands);\r
- controlbox.on('command_msg', msgCommand);\r
+ controlbox.on('command_action', actionCommand);\r
\r
- controlbox.on('command_action', actionCommand);\r
+ controlbox.on('command_join', joinCommand);\r
\r
- controlbox.on('command_join', joinCommand);\r
+ controlbox.on('command_part', partCommand);\r
\r
- controlbox.on('command_part', partCommand);\r
+ controlbox.on('command_nick', function (ev) {\r
+ kiwi.gateway.changeNick(ev.params[0]);\r
+ });\r
\r
- controlbox.on('command_nick', function (ev) {\r
- kiwi.gateway.changeNick(ev.params[0]);\r
- });\r
+ controlbox.on('command_query', queryCommand);\r
\r
- controlbox.on('command_query', queryCommand);\r
+ controlbox.on('command_topic', topicCommand);\r
\r
- controlbox.on('command_topic', topicCommand);\r
+ controlbox.on('command_notice', noticeCommand);\r
\r
- controlbox.on('command_notice', noticeCommand);\r
+ controlbox.on('command_quote', quoteCommand);\r
\r
- controlbox.on('command_quote', quoteCommand);\r
+ controlbox.on('command_kick', kickCommand);\r
\r
- controlbox.on('command_kick', kickCommand);\r
\r
+ controlbox.on('command_css', function (ev) {\r
+ var queryString = '?reload=' + new Date().getTime();\r
+ $('link[rel="stylesheet"]').each(function () {\r
+ this.href = this.href.replace(/\?.*|$/, queryString);\r
+ });\r
+ });\r
\r
- controlbox.on('command_css', function (ev) {\r
- var queryString = '?reload=' + new Date().getTime();\r
- $('link[rel="stylesheet"]').each(function () {\r
- this.href = this.href.replace(/\?.*|$/, queryString);\r
+ controlbox.on('command_js', function (ev) {\r
+ if (!ev.params[0]) return;\r
+ $script(ev.params[0] + '?' + (new Date().getTime()));\r
});\r
- });\r
\r
- controlbox.on('command_js', function (ev) {\r
- if (!ev.params[0]) return;\r
- $script(ev.params[0] + '?' + (new Date().getTime()));\r
- });\r
+ controlbox.on('command_alias', function (ev) {\r
+ var name, rule;\r
\r
- controlbox.on('command_alias', function (ev) {\r
- var name, rule;\r
+ // No parameters passed so list them\r
+ if (!ev.params[1]) {\r
+ $.each(controlbox.preprocessor.aliases, function (name, rule) {\r
+ kiwi.app.panels.server.addMsg(' ', name + ' => ' + rule);\r
+ });\r
+ return;\r
+ }\r
\r
- // No parameters passed so list them\r
- if (!ev.params[1]) {\r
- $.each(controlbox.preprocessor.aliases, function (name, rule) {\r
- kiwi.app.panels.server.addMsg(' ', name + ' => ' + rule);\r
- });\r
- return;\r
- }\r
+ // Deleting an alias?\r
+ if (ev.params[0] === 'del' || ev.params[0] === 'delete') {\r
+ name = ev.params[1];\r
+ if (name[0] !== '/') name = '/' + name;\r
+ delete controlbox.preprocessor.aliases[name];\r
+ return;\r
+ }\r
\r
- // Deleting an alias?\r
- if (ev.params[0] === 'del' || ev.params[0] === 'delete') {\r
- name = ev.params[1];\r
- if (name[0] !== '/') name = '/' + name;\r
- delete controlbox.preprocessor.aliases[name];\r
- return;\r
- }\r
+ // Add the alias\r
+ name = ev.params[0];\r
+ ev.params.shift();\r
+ rule = ev.params.join(' ');\r
\r
- // Add the alias\r
- name = ev.params[0];\r
- ev.params.shift();\r
- rule = ev.params.join(' ');\r
+ // Make sure the name starts with a slash\r
+ if (name[0] !== '/') name = '/' + name;\r
\r
- // Make sure the name starts with a slash\r
- if (name[0] !== '/') name = '/' + name;\r
+ // Now actually add the alias\r
+ controlbox.preprocessor.aliases[name] = rule;\r
+ });\r
\r
- // Now actually add the alias\r
- controlbox.preprocessor.aliases[name] = rule;\r
- });\r
+ controlbox.on('command_applet', appletCommand);\r
+ controlbox.on('command_settings', settingsCommand);\r
+ };\r
\r
- controlbox.on('command_applet', appletCommand);\r
- controlbox.on('command_settings', settingsCommand);\r
- };\r
+ // A fallback action. Send a raw command to the server\r
+ function unknownCommand (ev) {\r
+ var raw_cmd = ev.command + ' ' + ev.params.join(' ');\r
+ console.log('RAW: ' + raw_cmd);\r
+ kiwi.gateway.raw(raw_cmd);\r
+ }\r
\r
- // A fallback action. Send a raw command to the server\r
- function unknownCommand (ev) {\r
- var raw_cmd = ev.command + ' ' + ev.params.join(' ');\r
- console.log('RAW: ' + raw_cmd);\r
- kiwi.gateway.raw(raw_cmd);\r
- }\r
+ function allCommands (ev) {}\r
\r
- function allCommands (ev) {}\r
+ function joinCommand (ev) {\r
+ var channel, channel_names;\r
\r
- function joinCommand (ev) {\r
- var channel, channel_names;\r
+ channel_names = ev.params.join(' ').split(',');\r
\r
- channel_names = ev.params.join(' ').split(',');\r
+ $.each(channel_names, function (index, channel_name) {\r
+ // Trim any whitespace off the name\r
+ channel_name = channel_name.trim();\r
\r
- $.each(channel_names, function (index, channel_name) {\r
- // Trim any whitespace off the name\r
- channel_name = channel_name.trim();\r
+ // Check if we have the panel already. If not, create it\r
+ channel = that.panels.getByName(channel_name);\r
+ if (!channel) {\r
+ channel = new kiwi.model.Channel({name: channel_name});\r
+ kiwi.app.panels.add(channel);\r
+ }\r
\r
- // Check if we have the panel already. If not, create it\r
- channel = that.panels.getByName(channel_name);\r
- if (!channel) {\r
- channel = new kiwi.model.Channel({name: channel_name});\r
- kiwi.app.panels.add(channel);\r
- }\r
+ kiwi.gateway.join(channel_name);\r
+ });\r
\r
- kiwi.gateway.join(channel_name);\r
- });\r
+ if (channel) channel.view.show();\r
+ \r
+ }\r
\r
- if (channel) channel.view.show();\r
- \r
- }\r
+ function queryCommand (ev) {\r
+ var destination, panel;\r
\r
- function queryCommand (ev) {\r
- var destination, panel;\r
+ destination = ev.params[0];\r
\r
- destination = ev.params[0];\r
+ // Check if we have the panel already. If not, create it\r
+ panel = that.panels.getByName(destination);\r
+ if (!panel) {\r
+ panel = new kiwi.model.Channel({name: destination});\r
+ kiwi.app.panels.add(panel);\r
+ }\r
\r
- // Check if we have the panel already. If not, create it\r
- panel = that.panels.getByName(destination);\r
- if (!panel) {\r
- panel = new kiwi.model.Channel({name: destination});\r
- kiwi.app.panels.add(panel);\r
+ if (panel) panel.view.show();\r
+ \r
}\r
\r
- if (panel) panel.view.show();\r
- \r
- }\r
+ function msgCommand (ev) {\r
+ var destination = ev.params[0],\r
+ panel = that.panels.getByName(destination) || that.panels.server;\r
\r
- function msgCommand (ev) {\r
- var destination = ev.params[0],\r
- panel = that.panels.getByName(destination) || that.panels.server;\r
+ ev.params.shift();\r
\r
- ev.params.shift();\r
+ panel.addMsg(kiwi.gateway.get('nick'), ev.params.join(' '));\r
+ kiwi.gateway.privmsg(destination, ev.params.join(' '));\r
+ }\r
\r
- panel.addMsg(kiwi.gateway.get('nick'), ev.params.join(' '));\r
- kiwi.gateway.privmsg(destination, ev.params.join(' '));\r
- }\r
+ function actionCommand (ev) {\r
+ if (kiwi.app.panels.active === kiwi.app.panels.server) {\r
+ return;\r
+ }\r
\r
- function actionCommand (ev) {\r
- if (kiwi.app.panels.active === kiwi.app.panels.server) {\r
- return;\r
+ var panel = kiwi.app.panels.active;\r
+ panel.addMsg('', '* ' + kiwi.gateway.get('nick') + ' ' + ev.params.join(' '), 'action');\r
+ kiwi.gateway.action(panel.get('name'), ev.params.join(' '));\r
}\r
\r
- var panel = kiwi.app.panels.active;\r
- panel.addMsg('', '* ' + kiwi.gateway.get('nick') + ' ' + ev.params.join(' '), 'action');\r
- kiwi.gateway.action(panel.get('name'), ev.params.join(' '));\r
- }\r
-\r
- function partCommand (ev) {\r
- if (ev.params.length === 0) {\r
- kiwi.gateway.part(kiwi.app.panels.active.get('name'));\r
- } else {\r
- _.each(ev.params, function (channel) {\r
- kiwi.gateway.part(channel);\r
- });\r
+ function partCommand (ev) {\r
+ if (ev.params.length === 0) {\r
+ kiwi.gateway.part(kiwi.app.panels.active.get('name'));\r
+ } else {\r
+ _.each(ev.params, function (channel) {\r
+ kiwi.gateway.part(channel);\r
+ });\r
+ }\r
+ // TODO: More responsive = close tab now, more accurate = leave until part event\r
+ //kiwi.app.panels.remove(kiwi.app.panels.active);\r
}\r
- // TODO: More responsive = close tab now, more accurate = leave until part event\r
- //kiwi.app.panels.remove(kiwi.app.panels.active);\r
- }\r
\r
- function topicCommand (ev) {\r
- var channel_name;\r
+ function topicCommand (ev) {\r
+ var channel_name;\r
\r
- if (ev.params.length === 0) return;\r
+ if (ev.params.length === 0) return;\r
\r
- if (that.isChannelName(ev.params[0])) {\r
- channel_name = ev.params[0];\r
- ev.params.shift();\r
- } else {\r
- channel_name = kiwi.app.panels.active.get('name');\r
- }\r
+ if (that.isChannelName(ev.params[0])) {\r
+ channel_name = ev.params[0];\r
+ ev.params.shift();\r
+ } else {\r
+ channel_name = kiwi.app.panels.active.get('name');\r
+ }\r
\r
- kiwi.gateway.topic(channel_name, ev.params.join(' '));\r
- }\r
+ kiwi.gateway.topic(channel_name, ev.params.join(' '));\r
+ }\r
\r
- function noticeCommand (ev) {\r
- var destination;\r
+ function noticeCommand (ev) {\r
+ var destination;\r
\r
- // Make sure we have a destination and some sort of message\r
- if (ev.params.length <= 1) return;\r
+ // Make sure we have a destination and some sort of message\r
+ if (ev.params.length <= 1) return;\r
\r
- destination = ev.params[0];\r
- ev.params.shift();\r
+ destination = ev.params[0];\r
+ ev.params.shift();\r
\r
- kiwi.gateway.notice(destination, ev.params.join(' '));\r
- }\r
+ kiwi.gateway.notice(destination, ev.params.join(' '));\r
+ }\r
\r
- function quoteCommand (ev) {\r
- var raw = ev.params.join(' ');\r
- kiwi.gateway.raw(raw);\r
- }\r
+ function quoteCommand (ev) {\r
+ var raw = ev.params.join(' ');\r
+ kiwi.gateway.raw(raw);\r
+ }\r
\r
- function kickCommand (ev) {\r
- var nick, panel = kiwi.app.panels.active;\r
+ function kickCommand (ev) {\r
+ var nick, panel = kiwi.app.panels.active;\r
\r
- if (!panel.isChannel()) return;\r
+ if (!panel.isChannel()) return;\r
\r
- // Make sure we have a nick\r
- if (ev.params.length === 0) return;\r
+ // Make sure we have a nick\r
+ if (ev.params.length === 0) return;\r
\r
- nick = ev.params[0];\r
- ev.params.shift();\r
+ nick = ev.params[0];\r
+ ev.params.shift();\r
\r
- kiwi.gateway.kick(panel.get('name'), nick, ev.params.join(' '));\r
- }\r
+ kiwi.gateway.kick(panel.get('name'), nick, ev.params.join(' '));\r
+ }\r
\r
- function settingsCommand (ev) {\r
- var panel = new kiwi.model.Applet();\r
- panel.load(new kiwi.applets.Settings());\r
- \r
- kiwi.app.panels.add(panel);\r
- panel.view.show();\r
- }\r
+ function settingsCommand (ev) {\r
+ var panel = new kiwi.model.Applet();\r
+ panel.load(new kiwi.applets.Settings());\r
+ \r
+ kiwi.app.panels.add(panel);\r
+ panel.view.show();\r
+ }\r
\r
- function appletCommand (ev) {\r
- if (!ev.params[0]) return;\r
+ function appletCommand (ev) {\r
+ if (!ev.params[0]) return;\r
\r
- var panel = new kiwi.model.Applet();\r
+ var panel = new kiwi.model.Applet();\r
\r
- if (ev.params[1]) {\r
- // Url and name given\r
- panel.load(ev.params[0], ev.params[1]);\r
- } else {\r
- // Load a pre-loaded applet\r
- if (kiwi.applets[ev.params[0]]) {\r
- panel.load(new kiwi.applets[ev.params[0]]());\r
+ if (ev.params[1]) {\r
+ // Url and name given\r
+ panel.load(ev.params[0], ev.params[1]);\r
} else {\r
- kiwi.app.panels.server.addMsg('', 'Applet "' + ev.params[0] + '" does not exist');\r
- return;\r
+ // Load a pre-loaded applet\r
+ if (kiwi.applets[ev.params[0]]) {\r
+ panel.load(new kiwi.applets[ev.params[0]]());\r
+ } else {\r
+ kiwi.app.panels.server.addMsg('', 'Applet "' + ev.params[0] + '" does not exist');\r
+ return;\r
+ }\r
}\r
+ \r
+ kiwi.app.panels.add(panel);\r
+ panel.view.show();\r
}\r
- \r
- kiwi.app.panels.add(panel);\r
- panel.view.show();\r
- }\r
\r
\r
\r
\r
\r
- this.isChannelName = function (channel_name) {\r
- var channel_prefix = kiwi.gateway.get('channel_prefix');\r
+ this.isChannelName = function (channel_name) {\r
+ var channel_prefix = kiwi.gateway.get('channel_prefix');\r
+\r
+ if (!channel_name || !channel_name.length) return false;\r
+ return (channel_prefix.indexOf(channel_name[0]) > -1);\r
+ };\r
\r
- if (!channel_name || !channel_name.length) return false;\r
- return (channel_prefix.indexOf(channel_name[0]) > -1);\r
};\r
\r
\r
-})());\r
+ model = Backbone.Model.extend(new model());\r
+\r
+ return new model(arguments);\r
+};\r