From 6366fd38a256f48deb460fa6a31fd207cd6b2e9a Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Mon, 21 Apr 2014 00:12:07 +0200 Subject: [PATCH] Rename message property --- client/index.html | 2 +- lib/models.js | 8 ++++---- lib/server.js | 32 ++++++++++++++++++-------------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/client/index.html b/client/index.html index 5bb815d9..0e5ffc82 100644 --- a/client/index.html +++ b/client/index.html @@ -114,7 +114,7 @@
{{time}}
{{from}}
{{type}}
-
{{message}}
+
{{text}}
{{/each}} diff --git a/lib/models.js b/lib/models.js index d65841f6..5f6df75c 100644 --- a/lib/models.js +++ b/lib/models.js @@ -28,10 +28,10 @@ models.Users = Backbone.Collection.extend({ models.Message = Backbone.Model.extend({ defaults: { - type: "", - time: "", - from: "-!-", - message: "", + type: "", + time: "", + from: "-!-", + text: "", }, initialize: function() { this.set("time", require("moment")().format("HH:mm")); diff --git a/lib/server.js b/lib/server.js index ac993860..db759a25 100644 --- a/lib/server.js +++ b/lib/server.js @@ -121,7 +121,7 @@ function input(json) { } channel.get("messages").add({ from: user, - message: message, + text: message, }); break; @@ -244,7 +244,7 @@ function event(event, data) { chan.get("messages").add({ from: data[0].nick, - message: data[0].client, + text: data[0].client, type: "kick", }); break; @@ -254,7 +254,7 @@ function event(event, data) { if (typeof chan !== "undefined") { chan.get("messages").add({ from: data[0].nick, - message: data[0].mode + " " + data[0].client, + text: data[0].mode + " " + data[0].client, type: "mode", }); } @@ -263,7 +263,7 @@ function event(event, data) { case "motd": var messages = data[0].motd; messages.forEach(function(msg) { - channels.first().get("messages").add({message: msg}); + channels.first().get("messages").add({text: msg}); }); break; @@ -271,7 +271,7 @@ function event(event, data) { var chan = channels.findWhere({name: data[0].to}) || channels.add({type: "query", name: data[0].from}); chan.get("messages").add({ from: data[0].from, - message: data[0].message + text: data[0].message }); break; @@ -288,7 +288,7 @@ function event(event, data) { case "nick": if (data[0].new == this.get("client").me) { channels.first().get("messages").add({ - message: "You're now known as " + data[0]["new"], + text: "You're now known as " + data[0]["new"], }); } channels.each(function(chan) { @@ -303,17 +303,21 @@ function event(event, data) { chan.get("messages").add({ from: data[0].nick, - message: data[0]["new"], + text: data[0]["new"], type: "nick", }); }); break; - case "notice": + case "notice": if (data[0].to = "*") { data[0].from = "-!-"; } - channels.first().get("messages").add(data[0]); + channels.first().get("messages").add({ + type: "notice", + from: data[0].from, + text: data[0].message, + }); break; case "part": @@ -351,15 +355,15 @@ function event(event, data) { var from = data[0].nick || chan.get("name"); chan.get("messages").add({ from: from, - message: data[0].topic, + text: data[0].topic, type: "topic", }); break; case "welcome": channels.first().get("messages").add([ - {message: "You're now connected to " + this.get("host")}, - {message: "You're now known as " + data[0]} + {text: "You're now connected to " + this.get("host")}, + {text: "You're now known as " + data[0]} ]); break; @@ -367,7 +371,7 @@ function event(event, data) { if (data[1] == null) { channels.first().get("messages").add({ type: "error", - message: data[0] + text: data[0] }); break; } @@ -379,7 +383,7 @@ function event(event, data) { for (var k in data[1]) { if (i++ == 5) break; chan.get("messages").add({ - message: k + ": " + data[1][k] + text: k + ": " + data[1][k] }); } break;