summaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js51
1 files changed, 22 insertions, 29 deletions
diff --git a/index.js b/index.js
index 66c9b41..1142213 100644
--- a/index.js
+++ b/index.js
@@ -72,10 +72,6 @@ console.log($("#channel-input").val());
});
-
-
-
-
function imagify(url, channel) {
console.log(url);
$.ajax({
@@ -111,7 +107,7 @@ var numChans = 1;
$("#send-message").keypress(function(e) {
if(e.which == 13) {
var message = $("#send-message").val();
- var channel = $(".tab.active").attr("data-tab").replace("chan-", "#")
+ var channel = $(".tab.active").attr("data-tab")
if (message.indexOf("/join") == 0) {
joinChannel(message.substring(6, message.length), true);
} else if (message.indexOf("/part") == 0) {
@@ -130,7 +126,7 @@ $("#send-message").keypress(function(e) {
message = message.substring(6+nick.length, message.length);
sendPm(message, nick);
} else if (message.indexOf("/topic") == 0) {
- var channel = $(".tab.active").attr("data-tab").replace("chan-", "#")
+ var channel = $(".tab.active").attr("data-tab")
topic = message.substring(7, message.length);
setTopic(channel, topic);
} else if (message.indexOf("/") == 0) {
@@ -139,11 +135,11 @@ $("#send-message").keypress(function(e) {
client.send("kick", ["#wtest", "wjoe__", "test"]);
} else {
var tab = $(".tab.active").attr("data-tab");
- if (tab.startsWith("chan-")) {
+ if (tab.startsWith("#")) {
sendMsg(message, channel);
- } else if(tab.startsWith("pm-")){
- sendPm(message, tab.substring(3, tab.length));
+ } else {
+ sendPm(message, tab);
}
}
$("#send-message").val('');
@@ -152,26 +148,26 @@ $("#send-message").keypress(function(e) {
function sendMsg(message, channel) {
client.say(channel, message);
- var chanTab = $("[data-tab=chan-"+ channel.replace("#","") +"].chat");
+ var chanTab = $("[data-tab='"+ channel +"'].chat");
chanTab.append("<p class='chat-line'>&lt;" + myNick + "&gt; " + message +"</p>");
chanTab.scrollTop(chanTab.prop("scrollHeight"));
}
function sendPm(message, nick) {
- var chanTab = $("[data-tab=pm-"+nick+"].tab");
+ var chanTab = $("[data-tab="+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>");
+ $(".ui.menu").append("<a class='active item' data-id='"+numChans+"' data-tab='"+nick+"'>"+nick+"</a>");
+ $("#chan-container").append("<div class='ui active tab' data-id='"+numChans+"' data-tab='"+nick+"'></div>");
+ chanTab = $("[data-tab="+nick+"].tab");
+ chanTab.append("<div class='ui segment chat' data-id='"+numChans+"' data-tab='"+nick+"'></div>");
$('.menu .item').tab({history:false});
numChans++;
}
- $("[data-tab=pm-"+nick+"]").addClass("active");
- var chatTab = $("[data-tab=pm-"+nick+"].chat");
+ $("[data-tab="+nick+"]").addClass("active");
+ var chatTab = $("[data-tab="+nick+"].chat");
console.log(nick + ': ' + message);
client.say(nick, message);
chatTab.append("<p class='chat-line'>&lt;" + myNick + "&gt; " + message +"</p>");
@@ -183,34 +179,31 @@ function setTopic(channel, topic) {
}
function joinChannel(channel, sendJoin) {
- console.log("here");
if (sendJoin) {
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>");
+ $(".ui.menu").append("<a class='active item' data-id='"+numChans+"' data-tab='"+channel+"'>"+channel+"</a>");
+ $("#chan-container").append("<div class='ui active tab' data-id='"+numChans+"' data-tab='"+channel+"'></div>");
- var chanTab = $("[data-tab=chan-"+ channel +"].tab");
+ var chanTab = $("[data-tab="+ channel +"].tab");
- chanTab.append("<div class='ui selection list users' data-id='"+numChans+"' data-tab='chan-"+channel+"'></div>");
- chanTab.append("<div class='ui segment chat' data-id='"+numChans+"' data-tab='chan-"+channel+"'></div>");
- chanTab.append("<div class='ui topic' data-id='"+numChans+"' data-tab='chan-"+channel+"'></div>");
+ chanTab.append("<div class='ui selection list users' data-id='"+numChans+"' data-tab='"+channel+"'></div>");
+ chanTab.append("<div class='ui segment chat' data-id='"+numChans+"' data-tab='"+channel+"'></div>");
+ chanTab.append("<div class='ui topic' data-id='"+numChans+"' data-tab='"+channel+"'></div>");
$('.menu .item').tab({history:false});
}
function removeChannel(channel, sendPart) {
- channel = channel.replace("#","");
- chanId = $("[data-tab=chan-"+channel+"].chat").attr("data-id");
- $("[data-tab=chan-"+channel+"]").remove();
+ chanId = $("[data-tab="+channel+"].chat").attr("data-id");
+ $("[data-tab="+channel+"]").remove();
if (sendPart) {
- client.part("#"+channel);
+ client.part(channel);
}
while ($("[data-id="+(chanId-1)+"]").length == 0 && chanId >=0) {
chanId--;