Show errors in current window

This commit is contained in:
Mattias Erming 2014-03-15 17:14:05 +01:00
parent be945fe4de
commit 5eefa31400
2 changed files with 23 additions and 16 deletions

View file

@ -59,8 +59,12 @@ $(function() {
break; break;
case "MESSAGES": case "MESSAGES":
var message = data.data;
if (message.type == "error") {
target = target.parent().find(".active");
}
target = target.find(".messages"); target = target.find(".messages");
target.append(Mustache.render(messages, {messages: data.data})); target.append(Mustache.render(messages, {messages: message}));
break; break;
} }
} }

View file

@ -231,10 +231,11 @@ function handleInput(input) {
default: default:
channel.get("messages").add( channel.get("messages").add(
new models.Message({ new models.Message({
text: "Unknown command: `/" + cmd + "`", text: cmd + " Unknown command",
type: "error" type: "error"
}) })
); );
break;
} }
} }
@ -353,20 +354,22 @@ function handleEvent(argv) {
var messages = channel.get("messages"); var messages = channel.get("messages");
var user = users.findWhere({name: argv.nick}); var user = users.findWhere({name: argv.nick});
if (typeof user !== "undefined") { if (typeof user === "undefined") {
user.set("name", argv.args[0]); return;
users.sort();
users.trigger(
"change", {}, users
);
messages.add(new models.Message({
user: argv.nick,
text: "changed name to " + argv.args[0],
type: "nick"
}));
} }
user.set("name", argv.args[0]);
users.sort();
users.trigger(
"change", {}, users
);
messages.add(new models.Message({
user: argv.nick,
text: "changed name to " + argv.args[0],
type: "nick"
}));
}); });
if (argv.nick == network.get("nick")) { if (argv.nick == network.get("nick")) {
@ -555,7 +558,7 @@ function handleEvent(argv) {
var args = argv.args; var args = argv.args;
channels.first().get("messages").add( channels.first().get("messages").add(
new models.Message({ new models.Message({
text: args[args.length - 1], text: args[args.length - 2].toUpperCase() + " " + args[args.length - 1],
type: "error" type: "error"
}) })
); );