summaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js59
1 files changed, 36 insertions, 23 deletions
diff --git a/index.js b/index.js
index 3b3cbfa..a6e8ebf 100644
--- a/index.js
+++ b/index.js
@@ -2,6 +2,9 @@ var linkify = require("linkifyjs");
var linkifyHtml = require('linkifyjs/html');
var shell = require('electron').shell;
var config = require('./config.json')
+var pjson = require('./package.json');
+const progName = pjson.name;
+const version = pjson.version;
const myNick = config.nick;
$(document).ready(function() {
@@ -15,11 +18,36 @@ $(document).on('click', 'a[href^="http"]', function(event) {
const irc = require('irc');
+$("#server-input").val(config.server);
+$("#port-input").val(config.port);
+$("#nick-input").val(config.nick);
var channels = config.channels
-const client = new irc.Client(config.server, myNick, {
- channels: channels,
- userName: [myNick]
+var txtChannels = "";
+
+config.channels.forEach(function(channel) {
+ txtChannels += channel + ", "
});
+txtChannels = txtChannels.substring(0, txtChannels.length-2)
+
+$("#channel-input").val(txtChannels);
+const client = new irc.Client();
+
+$('#connect').on('click', function() {
+ client.server = $("#server-input").val();
+ client.nick = $("#nick-input").val(config.nick);
+ $("#chan-container").show();
+ $("#message").show();
+ $("#connect-container").hide();
+ client.connect();
+
+});
+
+// const client = new irc.Client(config.server, myNick, {
+// channels: config.channels,
+// userName: [myNick]
+// });
+
+
function imagify(url, channel) {
console.log(url);
@@ -73,9 +101,11 @@ $("#send-message").keypress(function(e) {
} 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 if (message.indexOf("/" == 0)) {
+ command = message.split(" ")[0].replace("/","");
+ commandArgs = message.replace(command + " ", "");
+ client.send("kick", ["#wtest", "wjoe__", "test"]);
} else {
var tab = $(".tab.active").attr("data-tab");
if (tab.startsWith("chan-")) {
@@ -90,7 +120,6 @@ $("#send-message").keypress(function(e) {
});
function sendMsg(message, channel) {
- console.log(channel + ': ' + message);
client.say(channel, message);
var chanTab = $("[data-tab=chan-"+ channel.replace("#","") +"].chat");
chanTab.append("<p class='chat-line'>&lt;" + "wclient" + "&gt; " + message +"</p>");
@@ -216,7 +245,7 @@ client.addListener('raw', function(message) {
});
client.addListener('ctcp-version', function(from, to, text, message) {
- client.ctcp(from, "VERSION", "VERSION blachat v0.1.0")
+ client.ctcp(from, "VERSION", "VERSION "+progName + " v"+ version)
});
@@ -390,19 +419,3 @@ client.addListener('channellist', function(channelList) {
statusTab.scrollTop(statusTab.prop("scrollHeight"));
}
});
-// client.addListener('message#wtest', function (from, message) {
-// console.log(from + ' => #wtest: ' + message);
-// var chanTab = $("[data-tab=chan-wtest].chat");
-// chanTab.append("<p class='chat-line'>&lt;" + from + "&gt; " + message +"</p>");
-// chanTab.scrollTop(chanTab.prop("scrollHeight"));
-// });
-//
-// client.addListener('message#jerseyesports', function (from, message) {
-// console.log(from + ' => #jerseyesports: ' + message);
-// $("[data-tab=chan-jerseyesports].chat").append("<p class='chat-line'>&lt;" + from + "&gt; " + message +"</p>");
-// });
-
-// client.addListener('message#theblueroom', function (from, message) {
-// console.log(from + ' => #jerseyesports: ' + message);
-// $("[data-tab=chan-theblueroom].chat").append("<p class='chat-line'>&lt;" + from + "&gt; " + message +"</p>");
-// });