diff --git a/client/js/shout.js b/client/js/shout.js index a23dc7de..c3560284 100644 --- a/client/js/shout.js +++ b/client/js/shout.js @@ -35,11 +35,12 @@ $(function() { $("html").addClass("web-app-mode"); } + var pop; try { - var pop = new Audio(); + pop = new Audio(); pop.src = "/audio/pop.ogg"; - } catch(e) { - var pop = { + } catch (e) { + pop = { play: $.noop }; } @@ -73,7 +74,7 @@ $(function() { }); }); - socket.on("auth", function(data) { + socket.on("auth", function(/* data */) { var body = $("body"); var login = $("#sign-in"); if (!login.length) { @@ -183,7 +184,7 @@ $(function() { socket.on("msg", function(data) { var target = "#chan-" + data.chan; - if (data.msg.type == "error") { + if (data.msg.type === "error") { target = "#chan-" + chat.find(".active").data("id"); } @@ -202,7 +203,7 @@ $(function() { } var type = data.msg.type; - if (type == "message" || type == "action") { + if (type === "message" || type === "action") { var nicks = chan.find(".users").data("nicks"); if (nicks) { var find = nicks.indexOf(from); @@ -220,7 +221,7 @@ $(function() { .find(".messages") .prepend(render("msg", {messages: data.messages})) .end(); - if (data.messages.length != 100) { + if (data.messages.length !== 100) { chan.find(".show-more").removeClass("show"); } }); @@ -274,7 +275,7 @@ $(function() { }); if (next !== null) { - var id = next.data("id"); + id = next.data("id"); sidebar.find("[data-id=" + id + "]").click(); } else { sidebar.find(".chan") @@ -374,7 +375,7 @@ $(function() { ].indexOf(name) !== -1) { chat.toggleClass("hide-" + name, !self.prop("checked")); } - if (name == "colors") { + if (name === "colors") { chat.toggleClass("no-colors", !self.prop("checked")); } }).find("input") @@ -383,7 +384,7 @@ $(function() { $("#badge").on("change", function() { var self = $(this); if (self.prop("checked")) { - if (Notification.permission != "granted") { + if (Notification.permission !== "granted") { Notification.requestPermission(); } } @@ -407,7 +408,6 @@ $(function() { .tab(complete, {hint: false}); var form = $("#form"); - var submit = $("#submit"); form.on("submit", function(e) { e.preventDefault(); @@ -428,7 +428,7 @@ $(function() { var text = ""; if (window.getSelection) { text = window.getSelection().toString(); - } else if (document.selection && document.selection.type != "Control") { + } else if (document.selection && document.selection.type !== "Control") { text = document.selection.createRange().text; } if (!text) { @@ -580,7 +580,7 @@ $(function() { pop.play(); } favico.badge("!"); - if (settings.badge && Notification.permission == "granted") { + if (settings.badge && Notification.permission === "granted") { var notify = new Notification(msg.from + " says:", { body: msg.text.trim(), icon: "/img/logo-64.png" @@ -640,7 +640,7 @@ $(function() { var content = self.parent().next(".toggle-content"); if (bottom && !content.hasClass("show")) { var img = content.find("img"); - if (img.length != 0 && !img.width()) { + if (img.length !== 0 && !img.width()) { img.on("load", function() { chat.scrollBottom(); }); @@ -678,7 +678,7 @@ $(function() { form.find(".btn") .attr("disabled", true) .end(); - if (form.closest(".window").attr("id") == "connect") { + if (form.closest(".window").attr("id") === "connect") { event = "conn"; } var values = {}; @@ -732,8 +732,8 @@ $(function() { Mousetrap.bind([ "command+k", "ctrl+shift+l" - ], function (e) { - if(e.target === input[0]) { + ], function(e) { + if (e.target === input[0]) { clear(); e.preventDefault(); } @@ -771,7 +771,7 @@ $(function() { words.push(nicks[i]); } - var channels = sidebar.find(".chan") + sidebar.find(".chan") .each(function() { var self = $(this); if (!self.hasClass("lobby")) { @@ -875,7 +875,7 @@ $(function() { } array.splice(new_index, 0, array.splice(old_index, 1)[0]); return array; - }; + } document.addEventListener( "visibilitychange", diff --git a/index.js b/index.js index 1fae1ba0..e5646d68 100755 --- a/index.js +++ b/index.js @@ -1,3 +1,3 @@ #!/usr/bin/env node process.chdir(__dirname); -var cli = require("./src/command-line"); +require("./src/command-line"); diff --git a/src/client.js b/src/client.js index 95a050b0..0a33ef95 100644 --- a/src/client.js +++ b/src/client.js @@ -80,11 +80,11 @@ Client.prototype.emit = function(event, data) { } var config = this.config || {}; if (config.log === true) { - if (event == "msg") { + if (event === "msg") { var target = this.find(data.chan); if (target) { var chan = target.chan.name; - if (target.chan.type == Chan.Type.LOBBY) { + if (target.chan.type === Chan.Type.LOBBY) { chan = target.network.host; } log.write( @@ -131,7 +131,7 @@ Client.prototype.connect = function(args) { if (config.bind) { server.localAddress = config.bind; - if(args.tls) { + if (args.tls) { var socket = net.connect(server); server.socket = socket; } @@ -152,7 +152,7 @@ Client.prototype.connect = function(args) { }); var nick = args.nick || "shout-user"; - var username = args.username || nick.replace(/[^a-zA-Z0-9]/g, ''); + var username = args.username || nick.replace(/[^a-zA-Z0-9]/g, ""); var realname = args.realname || "Shout User"; var irc = slate(stream); @@ -273,10 +273,10 @@ Client.prototype.sort = function(data) { var type = data.type; var order = data.order || []; + var sorted = []; switch (type) { case "networks": - var sorted = []; _.each(order, function(i) { var find = _.find(self.networks, {id: i}); if (find) { @@ -292,7 +292,6 @@ Client.prototype.sort = function(data) { if (!network) { return; } - var sorted = []; _.each(order, function(i) { var find = _.find(network.channels, {id: i}); if (find) { @@ -328,7 +327,7 @@ Client.prototype.save = function(force) { var client = this; var config = Helper.getConfig(); - if(config.public) { + if (config.public) { return; } @@ -360,7 +359,7 @@ Client.prototype.save = function(force) { try { json = JSON.parse(data); json.networks = networks; - } catch(e) { + } catch (e) { console.log(e); return; } diff --git a/src/clientManager.js b/src/clientManager.js index df4f08a9..624dd9d7 100644 --- a/src/clientManager.js +++ b/src/clientManager.js @@ -3,7 +3,6 @@ var fs = require("fs"); var Client = require("./client"); var mkdirp = require("mkdirp"); var Helper = require("./helper"); -var moment = require("moment"); module.exports = ClientManager; @@ -14,7 +13,7 @@ function ClientManager() { ClientManager.prototype.findClient = function(name) { for (var i in this.clients) { var client = this.clients[i]; - if (client.name == name) { + if (client.name === name) { return client; } } @@ -35,7 +34,7 @@ ClientManager.prototype.loadUser = function(name) { "utf-8" ); json = JSON.parse(json); - } catch(e) { + } catch (e) { console.log(e); return; } @@ -62,7 +61,7 @@ ClientManager.prototype.getUsers = function() { users.push(file.replace(".json", "")); } }); - } catch(e) { + } catch (e) { console.log(e); return; } @@ -88,7 +87,7 @@ ClientManager.prototype.addUser = function(name, password) { JSON.stringify(user, null, " "), {mode: "0777"} ); - } catch(e) { + } catch (e) { throw e; } return true; @@ -102,15 +101,14 @@ ClientManager.prototype.removeUser = function(name) { try { var path = Helper.HOME + "/users/" + name + ".json"; fs.unlinkSync(path); - } catch(e) { + } catch (e) { throw e; } return true; }; -ClientManager.prototype.autoload = function(sockets) { +ClientManager.prototype.autoload = function(/* sockets */) { var self = this; - var loaded = []; setInterval(function() { var loaded = _.pluck( self.clients, diff --git a/src/command-line/add.js b/src/command-line/add.js index 830b8022..153328e7 100644 --- a/src/command-line/add.js +++ b/src/command-line/add.js @@ -8,7 +8,7 @@ var Helper = require("../helper"); program .command("add ") .description("Add a new user") - .action(function(name, password) { + .action(function(name/* , password */) { var path = Helper.HOME + "/users"; try { mkdirp.sync(path); diff --git a/src/command-line/config.js b/src/command-line/config.js index 4080ff8f..e2658bdd 100644 --- a/src/command-line/config.js +++ b/src/command-line/config.js @@ -1,7 +1,4 @@ -var fs = require("fs"); -var path = require("path"); var program = require("commander"); -var mkdirp = require("mkdirp"); var child = require("child_process"); var Helper = require("../helper"); diff --git a/src/command-line/start.js b/src/command-line/start.js index 7637712d..676fccb1 100644 --- a/src/command-line/start.js +++ b/src/command-line/start.js @@ -1,4 +1,3 @@ -var _ = require("lodash"); var ClientManager = new require("../clientManager"); var program = require("commander"); var shout = require("../server"); diff --git a/src/helper.js b/src/helper.js index 565df801..b0006105 100644 --- a/src/helper.js +++ b/src/helper.js @@ -7,4 +7,4 @@ module.exports = { function getConfig() { return require(path.resolve(this.HOME) + "/config"); -}; +} diff --git a/src/identd.js b/src/identd.js index 7e32c422..76773568 100644 --- a/src/identd.js +++ b/src/identd.js @@ -4,7 +4,7 @@ var net = require("net"); var users = {}; module.exports.start = function(port) { - var server = net.createServer(init).listen(port || 113); + net.createServer(init).listen(port || 113); }; module.exports.hook = function(stream, user) { diff --git a/src/log.js b/src/log.js index 7da01d72..f07c6f45 100644 --- a/src/log.js +++ b/src/log.js @@ -7,7 +7,7 @@ module.exports.write = function(user, network, chan, msg) { try { var path = Helper.HOME + "/logs/" + user + "/" + network; mkdirp.sync(path); - } catch(e) { + } catch (e) { console.log(e); return; } @@ -20,7 +20,7 @@ module.exports.write = function(user, network, chan, msg) { var line = "[" + time + "] "; var type = msg.type.trim(); - if (type == "message" || type == "highlight") { + if (type === "message" || type === "highlight") { // Format: // [2014-01-01 00:00:00] Put that cookie down.. Now!! line += "<" + msg.from + "> " + msg.text; @@ -38,7 +38,7 @@ module.exports.write = function(user, network, chan, msg) { line + "\n", function(e) { if (e) { - console.log("Log#write():\n" + e) + console.log("Log#write():\n" + e); } } ); diff --git a/src/models/chan.js b/src/models/chan.js index 0121cc19..b493341b 100644 --- a/src/models/chan.js +++ b/src/models/chan.js @@ -37,7 +37,7 @@ Chan.prototype.sortUsers = function() { modes.forEach(function(mode) { this.users = _.remove( this.users, - function(u) { return u.mode == mode; } + function(u) { return u.mode === mode; } ).concat(this.users); }, this); }; diff --git a/src/plugins/inputs/action.js b/src/plugins/inputs/action.js index 8584a76e..b04b1463 100644 --- a/src/plugins/inputs/action.js +++ b/src/plugins/inputs/action.js @@ -1,13 +1,13 @@ var Msg = require("../../models/msg"); module.exports = function(network, chan, cmd, args) { - if (cmd != "slap" && cmd != "me") { + if (cmd !== "slap" && cmd !== "me") { return; } - + var client = this; var irc = network.irc; - + switch (cmd) { case "slap": var slap = "slaps " + args[0] + " around a bit with a large trout"; @@ -16,13 +16,13 @@ module.exports = function(network, chan, cmd, args) { if (args.length === 0) { break; } - + var text = slap || args.join(" "); irc.action( chan.name, text ); - + var msg = new Msg({ type: Msg.Type.ACTION, from: irc.me, diff --git a/src/plugins/inputs/connect.js b/src/plugins/inputs/connect.js index 86f02dc8..7bdcb0fe 100644 --- a/src/plugins/inputs/connect.js +++ b/src/plugins/inputs/connect.js @@ -1,5 +1,5 @@ module.exports = function(network, chan, cmd, args) { - if (cmd != "connect" && cmd != "server") { + if (cmd !== "connect" && cmd !== "server") { return; } if (args.length !== 0) { diff --git a/src/plugins/inputs/invite.js b/src/plugins/inputs/invite.js index 4042f25c..769edd0a 100644 --- a/src/plugins/inputs/invite.js +++ b/src/plugins/inputs/invite.js @@ -1,5 +1,5 @@ module.exports = function(network, chan, cmd, args) { - if (cmd != "invite") { + if (cmd !== "invite") { return; } var irc = network.irc; diff --git a/src/plugins/inputs/join.js b/src/plugins/inputs/join.js index 79c9553d..57c51455 100644 --- a/src/plugins/inputs/join.js +++ b/src/plugins/inputs/join.js @@ -1,5 +1,5 @@ module.exports = function(network, chan, cmd, args) { - if (cmd != "join") { + if (cmd !== "join") { return; } if (args.length !== 0) { diff --git a/src/plugins/inputs/kick.js b/src/plugins/inputs/kick.js index c994da2b..c1544576 100644 --- a/src/plugins/inputs/kick.js +++ b/src/plugins/inputs/kick.js @@ -1,5 +1,5 @@ module.exports = function(network, chan, cmd, args) { - if (cmd != "kick") { + if (cmd !== "kick") { return; } if (args.length !== 0) { diff --git a/src/plugins/inputs/mode.js b/src/plugins/inputs/mode.js index 45703098..2cd1b22c 100644 --- a/src/plugins/inputs/mode.js +++ b/src/plugins/inputs/mode.js @@ -1,19 +1,19 @@ module.exports = function(network, chan, cmd, args) { - if (cmd != "mode" && cmd != "op" && cmd != "voice" && cmd != "deop" && cmd != "devoice") { + if (cmd !== "mode" && cmd !== "op" && cmd !== "voice" && cmd !== "deop" && cmd !== "devoice") { return; } else if (args.length === 0) { return; } - + var mode; var user; - if (cmd != "mode") { + if (cmd !== "mode") { user = args[0]; mode = { - "op": "+o", - "voice": "+v", - "deop": "-o", - "devoice": "-v" + "op": "+o", + "voice": "+v", + "deop": "-o", + "devoice": "-v" }[cmd]; } else if (args.length === 1) { return; diff --git a/src/plugins/inputs/msg.js b/src/plugins/inputs/msg.js index 7757be9f..3a7c2476 100644 --- a/src/plugins/inputs/msg.js +++ b/src/plugins/inputs/msg.js @@ -1,16 +1,15 @@ var _ = require("lodash"); module.exports = function(network, chan, cmd, args) { - if (cmd != "say" && cmd != "msg") { + if (cmd !== "say" && cmd !== "msg") { return; } if (args.length === 0 || args[0] === "") { return; } - var client = this; var irc = network.irc; var target = ""; - if (cmd == "msg") { + if (cmd === "msg") { target = args.shift(); if (args.length === 0) { return; diff --git a/src/plugins/inputs/nick.js b/src/plugins/inputs/nick.js index 6ed6a77d..9f8bfee0 100644 --- a/src/plugins/inputs/nick.js +++ b/src/plugins/inputs/nick.js @@ -1,5 +1,5 @@ module.exports = function(network, chan, cmd, args) { - if (cmd != "nick") { + if (cmd !== "nick") { return; } if (args.length !== 0) { diff --git a/src/plugins/inputs/notice.js b/src/plugins/inputs/notice.js index 5a8e9fd3..b273ae4b 100644 --- a/src/plugins/inputs/notice.js +++ b/src/plugins/inputs/notice.js @@ -1,5 +1,5 @@ module.exports = function(network, chan, cmd, args) { - if (cmd != "notice" || !args[1]) { + if (cmd !== "notice" || !args[1]) { return; } var irc = network.irc; diff --git a/src/plugins/inputs/part.js b/src/plugins/inputs/part.js index 12a8a14d..b95083d4 100644 --- a/src/plugins/inputs/part.js +++ b/src/plugins/inputs/part.js @@ -1,11 +1,11 @@ var _ = require("lodash"); module.exports = function(network, chan, cmd, args) { - if (cmd != "part" && cmd != "leave" && cmd != "close") { + if (cmd !== "part" && cmd !== "leave" && cmd !== "close") { return; } var client = this; - if (chan.type == "query") { + if (chan.type === "query") { network.channels = _.without(network.channels, chan); client.emit("part", { chan: chan.id diff --git a/src/plugins/inputs/quit.js b/src/plugins/inputs/quit.js index 04e0e741..1bae1965 100644 --- a/src/plugins/inputs/quit.js +++ b/src/plugins/inputs/quit.js @@ -1,19 +1,19 @@ var _ = require("lodash"); module.exports = function(network, chan, cmd, args) { - if (cmd != "quit" && cmd != "disconnect") { + if (cmd !== "quit" && cmd !== "disconnect") { return; } - + var client = this; var irc = network.irc; var quitMessage = args[0] ? args.join(" ") : ""; - + client.networks = _.without(client.networks, network); client.save(); client.emit("quit", { network: network.id }); - + irc.quit(quitMessage); }; diff --git a/src/plugins/inputs/raw.js b/src/plugins/inputs/raw.js index 3594082f..6a5c1534 100644 --- a/src/plugins/inputs/raw.js +++ b/src/plugins/inputs/raw.js @@ -1,5 +1,5 @@ module.exports = function(network, chan, cmd, args) { - if (cmd != "raw" && cmd != "send" && cmd != "quote") { + if (cmd !== "raw" && cmd !== "send" && cmd !== "quote") { return; } if (args.length !== 0) { diff --git a/src/plugins/inputs/services.js b/src/plugins/inputs/services.js index 515fd3e9..6c0db36d 100644 --- a/src/plugins/inputs/services.js +++ b/src/plugins/inputs/services.js @@ -1,7 +1,7 @@ var _ = require("lodash"); module.exports = function(network, chan, cmd, args) { - if (cmd != "ns" && cmd != "cs" && cmd != "hs") { + if (cmd !== "ns" && cmd !== "cs" && cmd !== "hs") { return; } var target = ({ diff --git a/src/plugins/inputs/topic.js b/src/plugins/inputs/topic.js index 8f4c2bbf..01d373b7 100644 --- a/src/plugins/inputs/topic.js +++ b/src/plugins/inputs/topic.js @@ -1,12 +1,12 @@ module.exports = function(network, chan, cmd, args) { - if (cmd != "topic") { + if (cmd !== "topic") { return; } - + var msg = "TOPIC"; msg += " " + chan.name; msg += args[0] ? (" :" + args.join(" ")) : ""; - + var irc = network.irc; irc.write(msg); }; diff --git a/src/plugins/inputs/whois.js b/src/plugins/inputs/whois.js index fd24430f..4170338b 100644 --- a/src/plugins/inputs/whois.js +++ b/src/plugins/inputs/whois.js @@ -1,5 +1,5 @@ module.exports = function(network, chan, cmd, args) { - if (cmd != "whois" && cmd != "query") { + if (cmd !== "whois" && cmd !== "query") { return; } if (args.length !== 0) { diff --git a/src/plugins/irc-events/ctcp.js b/src/plugins/irc-events/ctcp.js index 7174cfba..42b7fed8 100644 --- a/src/plugins/irc-events/ctcp.js +++ b/src/plugins/irc-events/ctcp.js @@ -1,6 +1,6 @@ var pkg = require(process.cwd() + "/package.json"); -module.exports = function(irc, network) { +module.exports = function(irc/* , network */) { irc.on("message", function(data) { if (data.message.indexOf("\001") !== 0) { return; @@ -15,7 +15,7 @@ module.exports = function(irc, network) { ); break; case "PING": - if (split.length == 2) { + if (split.length === 2) { irc.ctcp(data.from, "PING " + split[1]); } break; diff --git a/src/plugins/irc-events/error.js b/src/plugins/irc-events/error.js index b6bd17d4..c56a36cc 100644 --- a/src/plugins/irc-events/error.js +++ b/src/plugins/irc-events/error.js @@ -13,7 +13,7 @@ module.exports = function(irc, network) { msg: msg }); if (!network.connected) { - if (data.cmd == "ERR_NICKNAMEINUSE") { + if (data.cmd === "ERR_NICKNAMEINUSE") { var random = irc.me + Math.floor(10 + (Math.random() * 89)); irc.nick(random); } diff --git a/src/plugins/irc-events/join.js b/src/plugins/irc-events/join.js index d4079900..edb7c245 100644 --- a/src/plugins/irc-events/join.js +++ b/src/plugins/irc-events/join.js @@ -26,7 +26,7 @@ module.exports = function(irc, network) { users: users }); var self = false; - if (data.nick.toLowerCase() == irc.me.toLowerCase()) { + if (data.nick.toLowerCase() === irc.me.toLowerCase()) { self = true; } var msg = new Msg({ diff --git a/src/plugins/irc-events/kick.js b/src/plugins/irc-events/kick.js index 88e37292..5daf252e 100644 --- a/src/plugins/irc-events/kick.js +++ b/src/plugins/irc-events/kick.js @@ -12,7 +12,7 @@ module.exports = function(irc, network) { return; } - if (data.client == irc.me) { + if (data.client === irc.me) { chan.users = []; } else { chan.users = _.without(chan.users, _.findWhere(chan.users, {name: data.client})); @@ -24,7 +24,7 @@ module.exports = function(irc, network) { }); var self = false; - if (data.nick.toLowerCase() == irc.me.toLowerCase()) { + if (data.nick.toLowerCase() === irc.me.toLowerCase()) { self = true; } diff --git a/src/plugins/irc-events/link.js b/src/plugins/irc-events/link.js index 908b7875..b0f3cca2 100644 --- a/src/plugins/irc-events/link.js +++ b/src/plugins/irc-events/link.js @@ -3,7 +3,7 @@ var cheerio = require("cheerio"); var Msg = require("../../models/msg"); var request = require("request"); var Helper = require("../../helper"); -var es = require('event-stream'); +var es = require("event-stream"); process.setMaxListeners(0); @@ -28,7 +28,7 @@ module.exports = function(irc, network) { return; } - var self = data.to.toLowerCase() == irc.me.toLowerCase(); + var self = data.to.toLowerCase() === irc.me.toLowerCase(); var chan = _.findWhere(network.channels, {name: self ? data.from : data.to}); if (typeof chan === "undefined") { return; @@ -67,12 +67,12 @@ function parse(msg, url, res, client) { toggle.type = "link"; toggle.head = $("title").text(); toggle.body = - $('meta[name=description]').attr('content') - || $('meta[property="og:description"]').attr('content') + $("meta[name=description]").attr("content") + || $("meta[property=\"og:description\"]").attr("content") || "No description found."; toggle.thumb = - $('meta[property="og:image"]').attr('content') - || $('meta[name="twitter:image:src"]').attr('content') + $("meta[property=\"og:image\"]").attr("content") + || $("meta[name=\"twitter:image:src\"]").attr("content") || ""; break; @@ -93,18 +93,18 @@ function parse(msg, url, res, client) { function fetch(url, cb) { try { var req = request.get(url); - } catch(e) { + } catch (e) { return; } var length = 0; var limit = 1024 * 10; req - .on('response', function(res) { - if (!(/(text\/html|application\/json)/.test(res.headers['content-type']))) { - res.req.abort(); + .on("response", function(res) { + if (!(/(text\/html|application\/json)/.test(res.headers["content-type"]))) { + res.req.abort(); } }) - .on('error', function() {}) + .on("error", function() {}) .pipe(es.map(function(data, next) { length += data.length; if (length > limit) { @@ -118,12 +118,12 @@ function fetch(url, cb) { var type; try { body = JSON.parse(data); - } catch(e) { + } catch (e) { body = {}; } try { - type = req.response.headers['content-type'].split(/ *; */).shift(); - } catch(e) { + type = req.response.headers["content-type"].split(/ *; */).shift(); + } catch (e) { type = {}; } data = { diff --git a/src/plugins/irc-events/message.js b/src/plugins/irc-events/message.js index aa990bb7..18b48e93 100644 --- a/src/plugins/irc-events/message.js +++ b/src/plugins/irc-events/message.js @@ -5,13 +5,13 @@ var Msg = require("../../models/msg"); module.exports = function(irc, network) { var client = this; irc.on("message", function(data) { - if (data.message.indexOf("\u0001") === 0 && data.message.substring(0, 7) != "\u0001ACTION") { + if (data.message.indexOf("\u0001") === 0 && data.message.substring(0, 7) !== "\u0001ACTION") { // Hide ctcp messages. return; } var target = data.to; - if (target.toLowerCase() == irc.me.toLowerCase()) { + if (target.toLowerCase() === irc.me.toLowerCase()) { target = data.from; } @@ -40,11 +40,11 @@ module.exports = function(irc, network) { }); var self = false; - if (data.from.toLowerCase() == irc.me.toLowerCase()) { + if (data.from.toLowerCase() === irc.me.toLowerCase()) { self = true; } - if (chan.id != client.activeChannel) { + if (chan.id !== client.activeChannel) { chan.unread++; } diff --git a/src/plugins/irc-events/mode.js b/src/plugins/irc-events/mode.js index 96648375..b4acc82a 100644 --- a/src/plugins/irc-events/mode.js +++ b/src/plugins/irc-events/mode.js @@ -14,7 +14,7 @@ module.exports = function(irc, network) { from = data.target; } var self = false; - if (from.toLowerCase() == irc.me.toLowerCase()) { + if (from.toLowerCase() === irc.me.toLowerCase()) { self = true; } var msg = new Msg({ diff --git a/src/plugins/irc-events/nick.js b/src/plugins/irc-events/nick.js index e884cded..fc65c4f2 100644 --- a/src/plugins/irc-events/nick.js +++ b/src/plugins/irc-events/nick.js @@ -6,7 +6,7 @@ module.exports = function(irc, network) { irc.on("nick", function(data) { var self = false; var nick = data["new"]; - if (nick == irc.me) { + if (nick === irc.me) { var lobby = network.channels[0]; var msg = new Msg({ text: "You're now known as " + nick, diff --git a/src/plugins/irc-events/notice.js b/src/plugins/irc-events/notice.js index 0f8c057f..a4b9d877 100644 --- a/src/plugins/irc-events/notice.js +++ b/src/plugins/irc-events/notice.js @@ -5,7 +5,7 @@ module.exports = function(irc, network) { var client = this; irc.on("notice", function(data) { var target = data.to; - if (target.toLowerCase() == irc.me.toLowerCase()) { + if (target.toLowerCase() === irc.me.toLowerCase()) { target = data.from; } @@ -15,7 +15,7 @@ module.exports = function(irc, network) { } var from = data.from || ""; - if (data.to == "*" || data.from.indexOf(".") !== -1) { + if (data.to === "*" || data.from.indexOf(".") !== -1) { from = ""; } var msg = new Msg({ diff --git a/src/plugins/irc-events/part.js b/src/plugins/irc-events/part.js index 42c0b355..a7ba317c 100644 --- a/src/plugins/irc-events/part.js +++ b/src/plugins/irc-events/part.js @@ -9,7 +9,7 @@ module.exports = function(irc, network) { return; } var from = data.nick; - if (from == irc.me) { + if (from === irc.me) { network.channels = _.without(network.channels, chan); client.save(); client.emit("part", { diff --git a/src/plugins/irc-events/whois.js b/src/plugins/irc-events/whois.js index 5a66540a..7e014368 100644 --- a/src/plugins/irc-events/whois.js +++ b/src/plugins/irc-events/whois.js @@ -26,7 +26,6 @@ module.exports = function(irc, network) { channels: "on", server: "using" }; - var i = 0; for (var k in data) { var key = prefix[k]; if (!key || data[k].toString() === "") { diff --git a/src/server.js b/src/server.js index 39a67106..5beb6707 100644 --- a/src/server.js +++ b/src/server.js @@ -26,7 +26,7 @@ module.exports = function(options) { var protocol = https.enable ? "https" : "http"; var port = config.port; var host = config.host; - var transports = config.transports || ['websocket', 'polling']; + var transports = config.transports || ["websocket", "polling"]; if (!https.enable){ server = require("http"); @@ -36,7 +36,7 @@ module.exports = function(options) { server = server.createServer({ key: fs.readFileSync(https.key), cert: fs.readFileSync(https.certificate) - }, app).listen(port, host) + }, app).listen(port, host); } if ((config.identd || {}).enable) { @@ -71,7 +71,7 @@ module.exports = function(options) { }; function index(req, res, next) { - if (req.url.split("?")[0] != "/") return next(); + if (req.url.split("?")[0] !== "/") return next(); return fs.readFile("client/index.html", "utf-8", function(err, file) { var data = _.merge( require("../package.json"), @@ -144,10 +144,10 @@ function auth(data) { var success = false; _.each(manager.clients, function(client) { if (data.token) { - if (data.token == client.token) { + if (data.token === client.token) { success = true; } - } else if (client.config.user == data.user) { + } else if (client.config.user === data.user) { if (bcrypt.compareSync(data.password || "", client.config.password)) { success = true; } diff --git a/test/plugins/link.js b/test/plugins/link.js index 6cef635d..278a2713 100644 --- a/test/plugins/link.js +++ b/test/plugins/link.js @@ -1,37 +1,37 @@ -var assert = require('assert'); +var assert = require("assert"); -var util = require('../util'); -var link = require('../../src/plugins/irc-events/link.js'); +var util = require("../util"); +var link = require("../../src/plugins/irc-events/link.js"); -describe('Link plugin', function() { - before(function(done) { - this.app = util.createWebserver(); - this.connection = this.app.listen(9002, done); - }); +describe("Link plugin", function() { + before(function(done) { + this.app = util.createWebserver(); + this.connection = this.app.listen(9002, done); + }); - after(function(done) { - this.connection.close(done); - }); + after(function(done) { + this.connection.close(done); + }); - beforeEach(function() { - this.irc = util.createClient(); - this.network = util.createNetwork(); - }); + beforeEach(function() { + this.irc = util.createClient(); + this.network = util.createNetwork(); + }); - it('should be able to fetch basic information about URLs', function(done) { - var plugin = link.call(this.irc, this.irc, this.network); + it("should be able to fetch basic information about URLs", function(done) { + link.call(this.irc, this.irc, this.network); - this.app.get('/basic', function(req, res) { - res.send('test'); - }); + this.app.get("/basic", function(req, res) { + res.send("test"); + }); - this.irc.createMessage({ - message: 'http://localhost:9002/basic' - }); + this.irc.createMessage({ + message: "http://localhost:9002/basic" + }); - this.irc.once('toggle', function(data) { - assert.equal(data.head, 'test'); - done(); - }) - }); + this.irc.once("toggle", function(data) { + assert.equal(data.head, "test"); + done(); + }); + }); }); diff --git a/test/util.js b/test/util.js index b7adeee4..cda4a419 100644 --- a/test/util.js +++ b/test/util.js @@ -1,43 +1,41 @@ -var EventEmitter = require('events').EventEmitter; -var util = require('util'); -var _ = require('lodash'); -var express = require('express'); +var EventEmitter = require("events").EventEmitter; +var util = require("util"); +var _ = require("lodash"); +var express = require("express"); function MockClient(opts) { - this.me = 'test-user'; + this.me = "test-user"; - for(k in opts) { - this[k] = opts[k]; - } + for (var k in opts) { + this[k] = opts[k]; + } } util.inherits(MockClient, EventEmitter); MockClient.prototype.createMessage = function(opts) { - var message = _.extend({ - message: 'dummy message', - from: 'test-user', - to: 'test-channel' - }, opts); + var message = _.extend({ + message: "dummy message", + from: "test-user", + to: "test-channel" + }, opts); - this.emit('message', message); -} + this.emit("message", message); +}; module.exports = { - createClient: function() { - return new MockClient(); - }, - createNetwork: function() { - return { - channels: [{ - name: 'test-channel', - messages: [] - }] - } - }, - createWebserver: function() { - return express(); - } -} - - + createClient: function() { + return new MockClient(); + }, + createNetwork: function() { + return { + channels: [{ + name: "test-channel", + messages: [] + }] + }; + }, + createWebserver: function() { + return express(); + } +};