summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.js29
1 files changed, 25 insertions, 4 deletions
diff --git a/index.js b/index.js
index 15a366a..3b3cbfa 100644
--- a/index.js
+++ b/index.js
@@ -70,10 +70,16 @@ $("#send-message").keypress(function(e) {
client.whois(message.substring(7, message.length));
} else if (message.indexOf("/list") == 0) {
client.list();
+ } else if (message.indexOf("/msg") == 0) {
+ nick = message.split(" ")[1];
+ message = message.substring(6+nick.length, message.length);
+ console.log(nick);
+ console.log(message);
+ sendPm(message, nick);
} else {
var tab = $(".tab.active").attr("data-tab");
if (tab.startsWith("chan-")) {
- sendMsg(message, channel.replace("#",""));
+ sendMsg(message, channel);
} else if(tab.startsWith("pm-")){
sendPm(message, tab.substring(3, tab.length));
@@ -92,18 +98,33 @@ function sendMsg(message, channel) {
}
function sendPm(message, nick) {
+
+ var chanTab = $("[data-tab=pm-"+nick+"].tab");
+ $(".active").removeClass("active");
+ if (chanTab.length == 0) {
+ $(".ui.menu").append("<a class='active item' data-id='"+numChans+"' data-tab='pm-"+nick+"'>"+nick+"</a>");
+ $("#chan-container").append("<div class='ui active tab' data-id='"+numChans+"' data-tab='pm-"+nick+"'></div>");
+ chanTab = $("[data-tab=pm-"+nick+"].tab");
+ chanTab.append("<div class='ui segment chat' data-id='"+numChans+"' data-tab='pm-"+nick+"'></div>");
+
+ $('.menu .item').tab({history:false});
+ numChans++;
+ }
+ $("[data-tab=pm-"+nick+"]").addClass("active");
+ var chatTab = $("[data-tab=pm-"+nick+"].chat");
console.log(nick + ': ' + message);
client.say(nick, message);
- var chanTab = $("[data-tab=pm-"+nick+"].chat");
- chanTab.append("<p class='chat-line'>&lt;" + "wclient" + "&gt; " + message +"</p>");
- chanTab.scrollTop(chanTab.prop("scrollHeight"));
+ chatTab.append("<p class='chat-line'>&lt;" + myNick + "&gt; " + message +"</p>");
+ chatTab.scrollTop(chanTab.prop("scrollHeight"));
}
function joinChannel(channel) {
client.join(channel);
channel = channel.replace("#","");
chanId = $(".active.chat").attr("data-id")
+
$(".active").removeClass("active");
+
$(".ui.menu").append("<a class='active item' data-id='"+numChans+"' data-tab='chan-"+channel+"'>#"+channel+"</a>");
$("#chan-container").append("<div class='ui active tab' data-id='"+numChans+"' data-tab='chan-"+channel+"'></div>");