summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Robinson <joe@grabyo.com>2016-04-01 17:06:56 +0100
committerJoe Robinson <joe@grabyo.com>2016-04-01 17:06:56 +0100
commitb73957a20677a857a1e3d5f6678cbd8a64c4192b (patch)
tree3a2873d60835d90562972f0b849355178309997d
parent61a590751e1407cdecf0503433e8c01824a14805 (diff)
WIP Connection UI
-rw-r--r--config.json1
-rw-r--r--index.html32
-rw-r--r--index.js59
3 files changed, 66 insertions, 26 deletions
diff --git a/config.json b/config.json
index 9d01223..7f4fb11 100644
--- a/config.json
+++ b/config.json
@@ -1,6 +1,7 @@
{
"nick": "wclient",
"server": "irc.blatech.net",
+ "port": 6667,
"channels": [
"#wtest",
"#wtest2"
diff --git a/index.html b/index.html
index 1d39298..e9e881b 100644
--- a/index.html
+++ b/index.html
@@ -4,7 +4,33 @@
</head>
<body class="container">
- <div id="chan-container">
+ <div id="connect-container">
+ <div class="ui segment" id="connect-settings">
+ <div class="ui input" id="server-container">
+ <input placeholder="Server" id="server-input" type="text" autofocus="true">
+ </div>
+ <div class="ui divider"></div>
+ <div class="ui input" id="port-container">
+ <input placeholder="Port" id="port-input" type="text">
+ </div>
+ <div class="ui divider"></div>
+ <div class="ui input" id="nick-container">
+ <input placeholder="Nick" id="nick-input" type="text">
+ </div>
+ <div class="ui divider"></div>
+ <div class="ui input" id="channel-container">
+ <input placeholder="Channels" id="channel-input" type="text">
+ </div>
+ <div class="ui divider"></div>
+ <div class="ui input" id="password-container">
+ <input placeholder="Password" id="password-input" type="text">
+ </div>
+ <div class="ui divider"></div>
+ <button class="ui button" id="connect">Connect</button>
+
+ </div>
+ </div>
+ <div id="chan-container" style="display:none">
<div class="ui pointing secondary menu">
<a class='active item' data-id='0' data-tab='status'>status</a>
</div>
@@ -13,14 +39,14 @@
</div>
</div>
</div>
- <div id="message">
+ <div id="message" style="display:none">
<div class="ui input" id="message-container">
<input placeholder="Message" id="send-message" type="text" autofocus="true">
</div>
</div>
<script>
window.$ = window.jQuery = require('./lib/jquery-2.2.2.js');
- var blachat = require("./index.js");
+ blachat = require("./index.js");
function scrollToTop(channel) {
var chatTab = $("[data-tab=chan-"+ channel +"].chat");
chatTab.scrollTop(chatTab.prop('scrollHeight'));
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>");
-// });