\r
controlbox.on('command:ctcp', ctcpCommand);\r
\r
+ controlbox.on('command:server', serverCommand);\r
+\r
\r
controlbox.on('command:css', function (ev) {\r
var queryString = '?reload=' + new Date().getTime();\r
}\r
\r
\r
+ function serverCommand (ev) {\r
+ var server, port, ssl, password, nick,\r
+ tmp;\r
+\r
+ if (!ev.params[0]) return;\r
+\r
+ // Port given in 'host:port' format and no specific port given after a space\r
+ if (ev.params[0].indexOf(':') > 0) {\r
+ tmp = ev.params[0].split(':');\r
+ server = tmp[0];\r
+ port = tmp[1];\r
+\r
+ password = ev.params[1] || undefined;\r
+\r
+ } else {\r
+ // Server + port given as 'host port'\r
+ server = ev.params[0];\r
+ port = ev.params[1] || 6667;\r
+\r
+ password = ev.params[2] || undefined;\r
+ }\r
+\r
+ // + in the port means SSL\r
+ if (port.toString()[0] === '+') {\r
+ ssl = true;\r
+ port = parseInt(port.substring(1), 10);\r
+ } else {\r
+ ssl = false;\r
+ }\r
+\r
+ // Default port if one wasn't found\r
+ port = port || 6667;\r
+\r
+ // Use the same nick as we currently have\r
+ nick = _kiwi.app.connections.active_connection.get('nick');\r
+\r
+ _kiwi.app.panels().active.addMsg('', 'Connecting to ' + server + ':' + port.toString() + '..');\r
+\r
+ _kiwi.gateway.newConnection({\r
+ nick: nick,\r
+ host: server,\r
+ port: port,\r
+ ssl: ssl,\r
+ password: password\r
+ }, function(err, new_connection) {\r
+ if (err)\r
+ _kiwi.app.panels().active.addMsg('', 'Error connecting to ' + server + ':' + port.toString() + ' (' + err.toString() + ')');\r
+ });\r
+ }\r
+\r
+\r
\r
\r
\r