From 3f99a9a35cc4751c1e48292e45cbfd81501395f2 Mon Sep 17 00:00:00 2001 From: Evert Date: Wed, 21 Dec 2016 20:54:22 +0200 Subject: [PATCH] i hate this project --- client.config.example.toml | 2 ++ server/logger.js | 10 +++++----- src/document/index.html | 4 ++-- src/script/main.js | 30 ++++++++++++++++++++++-------- src/script/meta.js | 12 ------------ teemant.js | 10 ++++++++-- 6 files changed, 39 insertions(+), 29 deletions(-) delete mode 100644 src/script/meta.js diff --git a/client.config.example.toml b/client.config.example.toml index 52a27fa..6884557 100644 --- a/client.config.example.toml +++ b/client.config.example.toml @@ -12,6 +12,8 @@ realname="A Teemant User" default_quit_msg="Teemant IRC" default_part_msg="Bye!" + default_server="irc.icynet.ml" + default_port=6667 # Socket settings secure_by_default=false timeout=3000 diff --git a/server/logger.js b/server/logger.js index 4e3d020..5fdc4b2 100644 --- a/server/logger.js +++ b/server/logger.js @@ -42,9 +42,9 @@ module.exports.printRuntimeStats = function(runtime_stats, connections) { if(users != 0) // Don't divide by zero lmao serversPerUser = servers/users; - console.log(date+': Currently connected users: {0};' + - 'IRC server connections: {1};' + - 'Average servers per user: {2};' + - 'Total connections made: {3};' + - 'Uptime: {4}s;'.format(users, servers, serversPerUser, runtime_stats.connectionsMade, process.uptime())); + console.log(date+(': Currently connected users: {0}. ' + + 'IRC server connections: {1}. ' + + 'Average servers per user: {2}. ' + + 'Total connections made: {3}. ' + + 'Uptime: {4}s;').format(users, servers, serversPerUser, runtime_stats.connectionsMade, process.uptime())); }; diff --git a/src/document/index.html b/src/document/index.html index f476e8b..66a20f0 100644 --- a/src/document/index.html +++ b/src/document/index.html @@ -33,10 +33,10 @@ - +
- + diff --git a/src/script/main.js b/src/script/main.js index ab26a86..e52dee2 100644 --- a/src/script/main.js +++ b/src/script/main.js @@ -40,8 +40,6 @@ const colorizer = { stylize: require('./colorparser.js') }; -let urlParams = {}; - /*********************\ |** **| |** UTILITIES **| @@ -1312,6 +1310,7 @@ class IRCConnector { constructor() { this.formLocked = false; this.canClose = false; + this.defaults = {}; clientdom.connector.form.onsubmit = (e) => { if(this.formLocked) { @@ -1335,7 +1334,14 @@ class IRCConnector { }; } - fillFormFromURI() { + fillFormFromURI(urlParams) { + if(this.defaults.server) + clientdom.connector.server.value = this.defaults.server; + if(this.defaults.port) + clientdom.connector.port.value = this.defaults.port; + if(this.defaults.ssl) + clientdom.connector.secure.checked = this.defaults.ssl; + for(let param in urlParams) { let value = urlParams[param]; @@ -1376,6 +1382,7 @@ class IRCConnector { break; } } + if(window.location.hash) clientdom.connector.channel.value = window.location.hash; @@ -1395,6 +1402,10 @@ class IRCConnector { } } + defaultTo(data) { + this.defaults = data; + } + getDataFromForm() { let nickname = clientdom.connector.nickname.value; let password = clientdom.connector.password.value; @@ -2043,11 +2054,11 @@ function parseURL() { decode = function (s) { return decodeURIComponent(s.replace(pl, ' ')); }, query = window.location.search.substring(1); - urlParams = {}; + let urlParams = {}; while (match = search.exec(query)) urlParams[decode(match[1])] = decode(match[2]); - irc.auther.fillFormFromURI(); + irc.auther.fillFormFromURI(urlParams); } function stopWarnings() { @@ -2055,8 +2066,6 @@ function stopWarnings() { window.onbeforeunload = null; } -window.onpopstate = parseURL; - window.onresize = function() { if(irc.config.scrollOnResize) clientdom.letterbox.scrollTop = clientdom.letterbox.scrollHeight; @@ -2104,9 +2113,14 @@ window.onload = function() { irc.auther = new IRCConnector(); irc.chat = new IRCChatWindow(); - parseURL(); irc.settings.setInitialValues(); + irc.socket.on('defaults', function (data) { + irc.auther.defaultTo(data); + parseURL(); + window.onpopstate = parseURL; + }); + irc.socket.on('connect', function (data) { irc.socketUp = true; }); diff --git a/src/script/meta.js b/src/script/meta.js deleted file mode 100644 index 249bd78..0000000 --- a/src/script/meta.js +++ /dev/null @@ -1,12 +0,0 @@ -const metafunctions = { - hexcolor: {regex: /#([A-F0-9]{3}([A-F0-9]{3})?)\b/gi, replacer: (function (line, regxp) { - return line.replace(regxp, (color) => { - return '' + color + - '
 
'; - }); - })} -}; - -module.exports = { - -}; diff --git a/teemant.js b/teemant.js index 91a063b..0f6aad7 100755 --- a/teemant.js +++ b/teemant.js @@ -90,6 +90,12 @@ io.sockets.on('connection', function (socket) { logger.debugLog('clientID: {0} from: {1}'.format(socket.id, userip)); + socket.emit('defaults', { + server: config.client.default_server, + port: config.client.default_port, + ssl: config.client.secure_by_default + }); + // New object for connections connections[socket.id] = { host: { @@ -103,12 +109,12 @@ io.sockets.on('connection', function (socket) { hostQuery.then((arr) => { if(arr.length > 0) connections[socket.id].host.hostname = arr[0]; + + logger.debugLog('Hostname of {0} was determined to be {1}'.format(socket.id, connections[socket.id].host.hostname)); }).catch((err) => { logger.debugLog('Host resolve for {0} failed: {1}'.format(socket.id, err)); }); - logger.debugLog('Hostname of {0} was determined to be {1}'.format(socket.id, connections[socket.id].host.hostname)); - socket.on('disconnect', function() { for (let d in connections[socket.id]) { if(connections[socket.id][d].ipaddr) continue;