From eb4e80ef26060be4a47e83471bed1ab21ef19650 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Tue, 5 Apr 2016 15:09:46 +0100 Subject: Fix connection UI, add SSL toggle, join channels on receiving names or topic to support bouncers --- CHANGELOG | 19 +++++++++++++++++++ config.json | 1 + index.html | 7 ++++++- index.js | 61 ++++++++++++++++++++++++++++++++++++++++++------------------ package.json | 2 +- 5 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 CHANGELOG 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" diff --git a/index.html b/index.html index e9e881b..35254dc 100644 --- a/index.html +++ b/index.html @@ -23,7 +23,12 @@
- + +
+
+
+ +
diff --git a/index.js b/index.js index a6e8ebf..7effc5b 100644 --- a/index.js +++ b/index.js @@ -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("

<" + "wclient" + "> " + message +"

"); + chanTab.append("

<" + myNick + "> " + message +"

"); 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("

"+message.args+"

") + if (statusCmds.indexOf(message.command) > -1 || message.command.startsWith("rpl_")) { + statusTab.append("

"+message.command + ": " +message.args+"

") 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("
"+mode+nick+"
") } @@ -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("

Topic for #"+channel+" is "+topic+" - set by "+nick+" at "+message.args[3]+"

") var topicTab = $("[data-tab=chan-"+ channel +"].topic"); topicTab.html("

"+topic+"

") @@ -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", -- cgit v1.2.3