Merge pull request #126 from yuvipanda/code-cleanup-1

Minor code cleanup
This commit is contained in:
Mattias Erming 2014-09-13 23:25:19 +02:00
commit edc572b0f8
5 changed files with 15 additions and 17 deletions

View File

@ -143,7 +143,7 @@ $(function() {
}) })
); );
sidebar.find(".chan") sidebar.find(".chan")
.sort(function(a, b) { return $(a).data("id") - $(b).data("id") }) .sort(function(a, b) { return $(a).data("id") - $(b).data("id"); })
.last() .last()
.trigger("click"); .trigger("click");
}); });
@ -330,7 +330,7 @@ $(function() {
.data("count", "") .data("count", "")
.empty(); .empty();
if (sidebar.find(".highlight").length == 0) { if (sidebar.find(".highlight").length === 0) {
favico.badge(""); favico.badge("");
} }
@ -374,7 +374,7 @@ $(function() {
}); });
chan.css({ chan.css({
transition: "none", transition: "none",
opacity: .4 opacity: 0.4
}); });
return false; return false;
}); });
@ -464,7 +464,7 @@ $(function() {
self.focus(); self.focus();
return false; return false;
} }
}) });
}); });
windows.on("click", ".input", function() { windows.on("click", ".input", function() {
@ -472,7 +472,7 @@ $(function() {
}); });
forms.on("submit", "form", function(e) { forms.on("submit", "form", function(e) {
e.preventDefault() e.preventDefault();
var event = "auth"; var event = "auth";
var form = $(this); var form = $(this);
if (form.closest(".window").attr("id") == "connect") { if (form.closest(".window").attr("id") == "connect") {
@ -507,13 +507,11 @@ $(function() {
var direction = keys.split("+").pop(); var direction = keys.split("+").pop();
switch (direction) { switch (direction) {
case "up": case "up":
var i = Math.max(0, index - 1); channels.eq(Math.max(0, index - 1)).click();
channels.eq(i).click();
break; break;
case "down": case "down":
var i = Math.min(channels.length, index + 1); channels.eq(Math.min(channels.length, index + 1)).click();
channels.eq(i).click();
break; break;
} }
}); });
@ -542,7 +540,7 @@ $(function() {
document.addEventListener( document.addEventListener(
"visibilitychange", "visibilitychange",
function() { function() {
if (sidebar.find(".highlight").length == 0) { if (sidebar.find(".highlight").length === 0) {
favico.badge(""); favico.badge("");
} }
} }

View File

@ -196,7 +196,7 @@ Client.prototype.input = function(data) {
console.log(path + ": " + e); console.log(path + ": " + e);
} }
}); });
} };
Client.prototype.more = function(data) { Client.prototype.more = function(data) {
var client = this; var client = this;
@ -211,7 +211,7 @@ Client.prototype.more = function(data) {
chan: chan.id, chan: chan.id,
messages: messages messages: messages
}); });
} };
Client.prototype.quit = function() { Client.prototype.quit = function() {
this.networks.forEach(function(network) { this.networks.forEach(function(network) {

View File

@ -44,11 +44,11 @@ ClientManager.prototype.loadUser = function(name) {
"utf-8" "utf-8"
); );
json = JSON.parse(json); json = JSON.parse(json);
return json;
} catch(e) { } catch(e) {
console.log(e); console.log(e);
return; return;
} }
return json;
}; };
ClientManager.prototype.getUsers = function() { ClientManager.prototype.getUsers = function() {

View File

@ -3,14 +3,15 @@ var bcrypt = require("bcrypt");
var fs = require("fs"); var fs = require("fs");
var program = require("commander"); var program = require("commander");
var mkdirp = require("mkdirp"); var mkdirp = require("mkdirp");
var Helper = require("../helper");
const HOME = process.env.HOME + "/.shout";
program program
.command("add <name>") .command("add <name>")
.description("Add a new user") .description("Add a new user")
.action(function(name) { .action(function(name) {
try {
var path = Helper.resolveHomePath("users"); var path = Helper.resolveHomePath("users");
try {
mkdirp.sync(path); mkdirp.sync(path);
} catch (e) { } catch (e) {
console.log(""); console.log("");
@ -20,7 +21,6 @@ program
return; return;
} }
try { try {
var path = Helper.resolveHomePath("users");
var test = path + "/.test"; var test = path + "/.test";
fs.mkdirSync(test); fs.mkdirSync(test);
fs.rmdirSync(test); fs.rmdirSync(test);

View File

@ -13,7 +13,7 @@ program
if (!config.public && !users.length) { if (!config.public && !users.length) {
console.log(""); console.log("");
console.log("No users found!"); console.log("No users found!");
console.log("Create a new user with 'shout add <name>'.") console.log("Create a new user with 'shout add <name>'.");
console.log(""); console.log("");
} else { } else {
var host = program.host || process.env.IP || config.host; var host = program.host || process.env.IP || config.host;