// Populate the server select box with defaults\r
this.panels.server.server_login.populateFields({\r
'nick': getQueryVariable('nick') || 'kiwi_' + Math.ceil(Math.random() * 10000).toString(),\r
- 'server': getQueryVariable('server') || 'irc.kiwiirc.net',\r
+ 'server': getQueryVariable('server') || 'irc.kiwiirc.com',\r
'channel': window.location.hash || '#test'\r
});\r
};\r
gw.on('onnotice', function (event) {\r
var panel;\r
\r
- // If a panel isn't found for this channel, reroute to the\r
- // server panel\r
- panel = that.panels.getByName(event.target);\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
kiwi.gateway.changeNick(ev.params[0]);\r
});\r
\r
+ controlbox.on('command_query', this.queryCommand);\r
+ controlbox.on('command_q', this.queryCommand);\r
+\r
controlbox.on('command_topic', this.topicCommand);\r
\r
controlbox.on('command_notice', this.noticeCommand);\r
});\r
};\r
\r
+ // A fallback action. Send a raw command to the server\r
this.unknownCommand = function (ev) {\r
- kiwi.gateway.raw(ev.command + ' ' + ev.params.join(' '));\r
+ var raw_cmd = ev.command + ' ' + ev.params.join(' ');\r
+ console.log('RAW: ' + raw_cmd);\r
+ kiwi.gateway.raw(raw_cmd);\r
};\r
\r
this.allCommands = function (ev) {\r
\r
};\r
\r
+ this.queryCommand = function (ev) {\r
+ var destination, panel;\r
+\r
+ destination = ev.params[0];\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
+ }\r
+\r
+ if (panel) panel.view.show();\r
+ \r
+ };\r
+\r
this.msgCommand = function (ev) {\r
- kiwi.current_panel.addMsg(kiwi.gateway.get('nick'), ev.params.join(' '));\r
- kiwi.gateway.privmsg(kiwi.current_panel.get('name'), ev.params.join(' '));\r
+ var destination = ev.params[0],\r
+ panel = that.panels.getByName(destination) || that.panels.server;\r
+\r
+ ev.params.shift();\r
+\r
+ panel.addMsg(kiwi.gateway.get('nick'), ev.params.join(' '));\r
+ kiwi.gateway.privmsg(destination, ev.params.join(' '));\r
};\r
\r
this.partCommand = function (ev) {\r
command = params[0].substr(1).toLowerCase();\r
params = params.splice(1);\r
} else {\r
+ // Default command\r
command = 'msg';\r
+ params.unshift(kiwi.current_panel.get('name'));\r
}\r
\r
// Trigger the command events\r
\r
// If we didn't have any listeners for this event, fire a special case\r
// TODO: This feels dirty. Should this really be done..?\r
- if (!this._callbacks['command' + command]) {\r
+ if (!this._callbacks['command_' + command]) {\r
this.trigger('unknown_command', {command: command, params: params});\r
}\r
}\r