password box

This commit is contained in:
Evert Prants 2016-09-27 18:59:09 +03:00
parent 11a25c1444
commit 8a9fb95c06
6 changed files with 57 additions and 18 deletions

View File

@ -64,8 +64,15 @@ body {
margin-top: 5px;
color: #2196f3;
}
.ircclient .coverwindow .wrapper label.autosize {
width: auto;
display: inline-block !important;
font-size: 90% !important;
margin-bottom: 10px;
}
.ircclient .coverwindow .wrapper input[type=text],
.ircclient .coverwindow .wrapper input[type=number] {
.ircclient .coverwindow .wrapper input[type=number],
.ircclient .coverwindow .wrapper input[type=password] {
padding: 8px;
width: 300px;
border-radius: 5px;

View File

@ -25,14 +25,22 @@
<form action="" id="IRCConnector">
<label for="nickname">Nickname</label>
<input type="text" name="nickname" id="nickname" value="">
<label class="autosize" for="password_trig">I have a password</label>&nbsp;
<input type="checkbox" name="password_trig" id="password_trig">
<div class="password_box" style="display: none;">
<label for="password">Password</label>
<input type="password" name="password" id="password">
</div>
<label for="channel">Channel</label>
<input type="text" name="channel" id="channel" value="#diamond">
<label for="server">Server</label>
<input type="text" name="server" id="server" value="irc.icynet.ml">
<label for="port">Port</label>
<input type="number" name="port" id="port" value="6667">
<label for="secure">Secure connection</label>
Use SSL <input type="checkbox" name="secure" id="secure">
<div class="server_data">
<label for="server">Server</label>
<input type="text" name="server" id="server" value="irc.icynet.ml">
<label for="port">Port</label>
<input type="number" name="port" id="port" value="6667">
<label for="secure">Secure connection</label>
Use SSL <input type="checkbox" name="secure" id="secure">
</div>
<input type="submit" value="Connect">
</form>
</div>

View File

@ -415,6 +415,10 @@ let commands = {
irc.socket.emit("userinput", {command: "quit", server: buffer.server, message: listargs.slice(1).join(" "), arguments: []});
}, description: "[<message>] - Quit the current server with message.", aliases: ['exit']},
mode: {execute: function(buffer, handler, command, message, listargs) {
irc.socket.emit("userinput", {command: "mode", server: buffer.server, message: listargs.slice(1).join(" "), arguments: []});
}, description: "[target] [mode] - Set/remove mode of target."},
msg: {execute: function(buffer, handler, command, message, listargs) {
if(!listargs[1] || !listargs[2])
return handler.commandError(buffer, listargs[0].toUpperCase()+': Missing parameters!');
@ -1060,6 +1064,10 @@ class IRCConnector {
if(key === 27 && this.canClose)
this.authComplete();
}
clientdom.connector.pwtrigger.onclick = (e) => {
this.togglePassword();
}
}
fillFormFromURI() {
@ -1113,6 +1121,7 @@ class IRCConnector {
event.preventDefault();
let nickname = clientdom.connector.nickname.value;
let password = clientdom.connector.password.value;
let channel = clientdom.connector.channel.value;
let server = clientdom.connector.server.value;
let port = clientdom.connector.port.value;
@ -1161,11 +1170,14 @@ class IRCConnector {
return false;
}
if(!clientdom.connector.pwtrigger.checked)
password = "";
irc.socket.emit('irc_create', {nickname: nickname,
autojoin: channel,
server: server,
port: port,
password: null,
password: password,
secure: clientdom.connector.secure.checked });
return true;
}
@ -1176,6 +1188,13 @@ class IRCConnector {
this.formLocked = false;
}
togglePassword() {
if(clientdom.connector.pwtrigger.checked)
clientdom.connector.pwbox.style.display = "block";
else
clientdom.connector.pwbox.style.display = "none";
}
authComplete() {
clientdom.connector.frame.style.display = "none";
this.formLocked = false;
@ -1217,7 +1236,7 @@ class InputHandler {
}
keyUpHandle(e, key) {
if(key == 38 || key == 40 || key == 8 || key == 9) return;
if(key == 38 || key == 40 || key == 9) return;
let input = clientdom.input.value;
let word = input.split(/ |\n/).pop();
@ -1296,11 +1315,6 @@ class InputHandler {
// Remember the word until next time.
this.lastWord = word;
return;
} else if(key == 8) {
this.index = -1;
this.lastWord = "";
return;
}
}
@ -1753,6 +1767,9 @@ window.onload = function() {
clientdom.connector['messenger'] = clientdom.connector.frame.querySelector('#connmsg');
clientdom.connector['form'] = clientdom.connector.frame.querySelector('#IRCConnector');
clientdom.connector['nickname'] = clientdom.connector.form.querySelector('#nickname');
clientdom.connector['password'] = clientdom.connector.form.querySelector('#password');
clientdom.connector['pwtrigger'] = clientdom.connector.form.querySelector('#password_trig');
clientdom.connector['pwbox'] = clientdom.connector.form.querySelector('.password_box');
clientdom.connector['channel'] = clientdom.connector.form.querySelector('#channel');
clientdom.connector['server'] = clientdom.connector.form.querySelector('#server');
clientdom.connector['port'] = clientdom.connector.form.querySelector('#port');

View File

@ -75,7 +75,12 @@ body
font-size: 80%
margin-top: 5px
color: #2196F3
input[type=text], input[type=number]
&.autosize
width: auto
display: inline-block !important
font-size: 90% !important
margin-bottom: 10px
input[type=text], input[type=number], input[type=password]
padding: 8px;
width: 300px;
border-radius: 5px;

View File

@ -220,6 +220,7 @@ class IRCConnectionHandler {
case "042":
this.conn.emit('pass_to_client', {type: "server_message", messageType: "regular", message: line.arguments[1] +" "+ line.trailing, server: serverName, from: realServerName});
break;
case "501":
case "401":
case "402":
case "421":

View File

@ -54,7 +54,7 @@ io.sockets.on('connection', function (socket) {
connections[socket.id] = {
host: {
ipaddr: userip,
hostname: "localhost"
hostname: userip
}
}
@ -63,10 +63,11 @@ io.sockets.on('connection', function (socket) {
hostQuery.then((arr) => {
if(arr.length > 0)
connections[socket.id].host.hostname = arr[0];
if(config.server.debug)
console.log("Hostname of "+socket.id+" was determined to be "+connections[socket.id].host.hostname);
}).catch((err) => { console.log("Host resolve for "+socket.id+" failed: ", err); });
if(config.server.debug)
console.log("Hostname of "+socket.id+" was determined to be "+connections[socket.id].host.hostname);
socket.on('disconnect', function() {
for (let d in connections[socket.id]) {
if(connections[socket.id][d].ipaddr) continue;