server: 'irc.kiwiirc.com',\r
port: 6667,\r
ssl: false,\r
- channel: window.location.hash || '#kiwiirc'\r
+ channel: window.location.hash || '#kiwiirc',\r
+ channel_key: ''\r
};\r
+ var uricheck;\r
\r
// Process the URL part by part, extracting as we go\r
parts = window.location.pathname.toString().replace(this.get('base_path'), '').split('/');\r
parts.shift();\r
\r
if (parts.length > 0 && parts[0]) {\r
- // Extract the port+ssl if we find one\r
- if (parts[0].search(/:/) > 0) {\r
- defaults.port = parts[0].substring(parts[0].search(/:/) + 1);\r
- defaults.server = parts[0].substring(0, parts[0].search(/:/));\r
- if (defaults.port[0] === '+') {\r
- defaults.port = parseInt(defaults.port.substring(1), 10);\r
- defaults.ssl = true;\r
+ uricheck = parts[0].substr(0, 7).toLowerCase();\r
+ if ((uricheck === 'ircs%3a') || (uricheck.substr(0,6) === 'irc%3a')) {\r
+ parts[0] = decodeURIComponent(parts[0]);\r
+ console.log(parts[0]);\r
+ // irc[s]://<host>[:<port>]/[<channel>[?<password>]]\r
+ uricheck = /^irc(s)?:(?:\/\/?)?([^:\/]+)(?::([0-9]+))?(?:(?:\/)([^\?]*)(?:(?:\?)(.*))?)?$/.exec(parts[0]);\r
+ console.log(uricheck);\r
+ if (uricheck) {\r
+ if (uricheck[1]) {\r
+ defaults.ssl = true;\r
+ if (defaults.port === 6667) {\r
+ defaults.port = 6697;\r
+ }\r
+ }\r
+ defaults.server = uricheck[2];\r
+ if (uricheck[3]) {\r
+ defaults.port = uricheck[3];\r
+ }\r
+ if (uricheck[4]) {\r
+ defaults.channel = '#' + uricheck[4];\r
+ if (uricheck[5]) {\r
+ defaults.channel_key = uricheck[5];\r
+ }\r
+ }\r
+ }\r
+ console.log(defaults);\r
+ parts = [];\r
+ } else {\r
+ // Extract the port+ssl if we find one\r
+ if (parts[0].search(/:/) > 0) {\r
+ defaults.port = parts[0].substring(parts[0].search(/:/) + 1);\r
+ defaults.server = parts[0].substring(0, parts[0].search(/:/));\r
+ if (defaults.port[0] === '+') {\r
+ defaults.port = parseInt(defaults.port.substring(1), 10);\r
+ defaults.ssl = true;\r
+ } else {\r
+ defaults.ssl = false;\r
+ }\r
+\r
} else {\r
- defaults.ssl = false;\r
+ defaults.server = parts[0];\r
}\r
\r
- } else {\r
- defaults.server = parts[0];\r
+ parts.shift();\r
}\r
-\r
- parts.shift();\r
}\r
\r
if (parts.length > 0 && parts[0]) {\r
that.view.barsShow();\r
\r
if (auto_connect_details.channel) {\r
- that.controlbox.processInput('/JOIN ' + auto_connect_details.channel);\r
+ that.controlbox.processInput('/JOIN ' + auto_connect_details.channel + ' ' + auto_connect_details.channel_key);\r
}\r
});\r
\r
port: $('.port', this.$el).val(),\r
ssl: $('.ssl', this.$el).prop('checked'),\r
password: $('.password', this.$el).val(),\r
- channel: $('.channel', this.$el).val()\r
+ channel: $('.channel', this.$el).val(),\r
+ channel_key: $('.channel_key', this.$el).val()\r
};\r
\r
this.trigger('server_connect', values);\r
},\r
\r
populateFields: function (defaults) {\r
- var nick, server, channel;\r
+ var nick, server, port, channel, channel_key, ssl, password;\r
\r
defaults = defaults || {};\r
\r
ssl = defaults.ssl || 0;\r
password = defaults.password || '';\r
channel = defaults.channel || '';\r
+ channel_key = defaults.channel_key || '';\r
\r
$('.nick', this.$el).val(nick);\r
$('.server', this.$el).val(server);\r
$('.ssl', this.$el).prop('checked', ssl);\r
$('.password', this.$el).val(password);\r
$('.channel', this.$el).val(channel);\r
+ $('.channel_key', this.$el).val(channel_key);\r
},\r
\r
hide: function () {\r