var client var globals = require('./globals.js') module.exports.init = function(myClient) { client = myClient } module.exports.sendMsg = function(message, channel) { client.say(channel, message); var chanTab = $("[data-tab='"+ channel +"'].chat"); chanTab.append("

<" + globals.myNick + "> " + message +"

"); chanTab.scrollTop(chanTab.prop("scrollHeight")); } module.exports.sendPm = function(message, nick) { var chanTab = $("[data-tab="+nick+"].tab"); $(".active").removeClass("active"); numChans = globals.channels.length if (chanTab.length == 0) { $(".ui.menu").append(""+nick+""); $("#chan-container").append("
"); chanTab = $("[data-tab="+nick+"].tab"); chanTab.append("
"); $('.menu .item').tab({history:false}); globals.channels.push(nick) numChans++; } $("[data-tab="+nick+"]").addClass("active"); var chatTab = $("[data-tab="+nick+"].chat"); console.log(nick + ': ' + message); client.say(nick, message); chatTab.append("

<" + globals.myNick + "> " + message +"

"); chatTab.scrollTop(chanTab.prop("scrollHeight")); } module.exports.setTopic = function(channel, topic) { client.raw("TOPIC", channel, topic); } module.exports.joinChannel = function (channel, sendJoin) { numChans = globals.channels.length var channelObj = client.channel(channel); if (sendJoin) { channelObj.join(); channelObj.say("beep"); } chanId = $(".active.chat").attr("data-id") $(".active").removeClass("active"); $(".ui.menu").append(""+channel+""); $("#chan-container").append("
"); var chanTab = $("[data-tab='"+ channel +"'].tab"); chanTab.append("
"); chanTab.append("
"); chanTab.append("
"); $('.menu .item').tab({history:false}); globals.channels.push(channel) numChans++; } module.exports.removeChannel = function(channel, sendPart) { chanId = $("[data-tab='"+channel+"'].chat").attr("data-id"); $("[data-tab='"+channel+"']").remove(); if (sendPart) { var channelObj = client.channel(channel) channelObj.part(); } while ($("[data-id="+(chanId-1)+"]").length == 0 && chanId >=0) { chanId--; } $("[data-id="+(chanId-1)+"]").addClass("active"); } module.exports.whois = function(nick) { client.whois(nick); } module.exports.list = function() { client.raw("LIST") }