diff options
author | Joe Robinson <joe@grabyo.com> | 2016-04-05 15:09:46 +0100 |
---|---|---|
committer | Joe Robinson <joe@grabyo.com> | 2016-04-05 15:09:46 +0100 |
commit | eb4e80ef26060be4a47e83471bed1ab21ef19650 (patch) | |
tree | f1e239144ec1568458c710c5b8f3c67dfadd2807 | |
parent | b73957a20677a857a1e3d5f6678cbd8a64c4192b (diff) |
Fix connection UI, add SSL toggle, join channels on receiving names or topic to support bouncers
-rw-r--r-- | CHANGELOG | 19 | ||||
-rw-r--r-- | config.json | 1 | ||||
-rw-r--r-- | index.html | 7 | ||||
-rw-r--r-- | index.js | 61 | ||||
-rw-r--r-- | package.json | 2 |
5 files changed, 70 insertions, 20 deletions
diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..66cacb3 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,19 @@ +0.1.0 +----- + - Initial alpha release with basic IRC functionality and commands + - Support /join and /part of channels + - Can send and receive messages in channels + - PMs will be shown and can be replied to in their tab, but no way to initiate PMs + - Can send /whois and channel /list commands + - Interpret join, part, quit, kill, kick, and mode messages + - Display topics and user lists in channels +0.1.1 +----- + - Added ability to send PMs with /msg +0.2.0 +----- + - Added basic connection UI at startup (automatically populated from config.json) +0.2.1 +----- + - Create channel tab when names list is received, to support bouncers + - Added SSL connection option diff --git a/config.json b/config.json index 7f4fb11..0d09a15 100644 --- a/config.json +++ b/config.json @@ -2,6 +2,7 @@ "nick": "wclient", "server": "irc.blatech.net", "port": 6667, + "password": "", "channels": [ "#wtest", "#wtest2" @@ -23,7 +23,12 @@ </div> <div class="ui divider"></div> <div class="ui input" id="password-container"> - <input placeholder="Password" id="password-input" type="text"> + <input placeholder="Password" id="password-input" type="password"> + </div> + <div class="ui divider"></div> + <div class="ui toggle checkbox"> + <input id="ssl-input" type="checkbox"> + <label>Enable SSL</label> </div> <div class="ui divider"></div> <button class="ui button" id="connect">Connect</button> @@ -5,7 +5,7 @@ var config = require('./config.json') var pjson = require('./package.json'); const progName = pjson.name; const version = pjson.version; -const myNick = config.nick; +var myNick = config.nick; $(document).ready(function() { $("#send-message").focus(); @@ -21,31 +21,43 @@ const irc = require('irc'); $("#server-input").val(config.server); $("#port-input").val(config.port); $("#nick-input").val(config.nick); +$("#password-input").val(config.password); var channels = config.channels var txtChannels = ""; config.channels.forEach(function(channel) { - txtChannels += channel + ", " + txtChannels += channel + " " }); -txtChannels = txtChannels.substring(0, txtChannels.length-2) +txtChannels = txtChannels.substring(0, txtChannels.length-1) $("#channel-input").val(txtChannels); -const client = new irc.Client(); +var client; $('#connect').on('click', function() { - client.server = $("#server-input").val(); - client.nick = $("#nick-input").val(config.nick); +console.log($("#channel-input").val()); + channels = $("#channel-input").val().split(" "); + myNick = $("#nick-input").val() + ssl = ($("#ssl-input:checked").val() == "on"); + console.log(ssl); + client = new irc.Client($("#server-input").val(), myNick, { + channels: channels, + userName: myNick, + password: $("#password-input").val(), + port: $("#port-input").val(), + secure: ssl, + selfSigned: true, + certExpired: true +}); + createListeners(client); + + $("#chan-container").show(); $("#message").show(); $("#connect-container").hide(); - client.connect(); }); -// const client = new irc.Client(config.server, myNick, { -// channels: config.channels, -// userName: [myNick] -// }); + @@ -102,7 +114,7 @@ $("#send-message").keypress(function(e) { nick = message.split(" ")[1]; message = message.substring(6+nick.length, message.length); sendPm(message, nick); - } else if (message.indexOf("/" == 0)) { + } else if (message.indexOf("/") == 0) { command = message.split(" ")[0].replace("/",""); commandArgs = message.replace(command + " ", ""); client.send("kick", ["#wtest", "wjoe__", "test"]); @@ -122,7 +134,7 @@ $("#send-message").keypress(function(e) { function sendMsg(message, channel) { client.say(channel, message); var chanTab = $("[data-tab=chan-"+ channel.replace("#","") +"].chat"); - chanTab.append("<p class='chat-line'><" + "wclient" + "> " + message +"</p>"); + chanTab.append("<p class='chat-line'><" + myNick + "> " + message +"</p>"); chanTab.scrollTop(chanTab.prop("scrollHeight")); } @@ -147,8 +159,10 @@ function sendPm(message, nick) { chatTab.scrollTop(chanTab.prop("scrollHeight")); } -function joinChannel(channel) { - client.join(channel); +function joinChannel(channel, sendJoin) { + if (sendJoin) { + client.join(channel); + } channel = channel.replace("#",""); chanId = $(".active.chat").attr("data-id") @@ -219,6 +233,9 @@ function removeChannel(channel, sendPart) { $("[data-id="+(chanId-1)+"]").addClass("active"); } +function createListeners(client) { + + client.addListener('error', function(message) { console.log('error: ', message); }); @@ -238,8 +255,8 @@ client.addListener('motd', function(motd) { client.addListener('raw', function(message) { var statusTab = $("[data-tab=status].chat"); statusCmds = ["NOTICEAUTH", "rpl_welcome, rpl_yourhoust", "rpl_created", "rpl_myinfo", "rpl_isupport", "rpl_luserclient", "rpl_luserop", "rpl_luserme", "rpl_luserchannels", "rpl_localusers", "rpl_globalusers"]; - if (statusCmds.indexOf(message.command) > -1) { - statusTab.append("<p class='chat-line'>"+message.args+"</p>") + if (statusCmds.indexOf(message.command) > -1 || message.command.startsWith("rpl_")) { + statusTab.append("<p class='chat-line'>"+message.command + ": " +message.args+"</p>") statusTab.scrollTop(statusTab.prop("scrollHeight")); } }); @@ -250,9 +267,12 @@ client.addListener('ctcp-version', function(from, to, text, message) { client.addListener('names', function(channel, nicks) { + channel = channel.replace("#","") + if($(".ui.tab[data-tab=chan-"+channel+"]").length == 0) { + joinChannel(channel, false) + } for(nick in nicks) { var mode = nicks[nick]; - channel = channel.replace("#","") if($(".ui.users[data-tab=chan-"+channel+"] [data-nick="+nick+"]").length == 0) { $(".ui.users[data-tab=chan-"+channel+"]").append("<div class=item data-nick="+nick+">"+mode+nick+"</div>") } @@ -335,6 +355,9 @@ client.addListener('kill', function(nick, reason, channels, message) { client.addListener('topic', function(channel, topic, nick, message) { channel = channel.replace("#",""); var chatTab = $("[data-tab=chan-"+ channel +"].chat"); + if($(".ui.tab[data-tab=chan-"+channel+"]").length == 0) { + joinChannel(channel, false) + } chatTab.append("<p class='chat-line'>Topic for #"+channel+" is "+topic+" - set by "+nick+" at "+message.args[3]+"</p>") var topicTab = $("[data-tab=chan-"+ channel +"].topic"); topicTab.html("<p class='topic-line'>"+topic+"</p>") @@ -419,3 +442,5 @@ client.addListener('channellist', function(channelList) { statusTab.scrollTop(statusTab.prop("scrollHeight")); } }); + +} diff --git a/package.json b/package.json index 60e1d96..d635fce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blachat", - "version": "0.1.0", + "version": "0.2.1", "description": "A modern IRC client", "license": "GPL-3.0", "repository": "http://www.blatech.co.uk/wjoe/blachat", |