Permalink
Browse files

changed the handling of receiving events through nowjs on the client

  • Loading branch information...
1 parent b169a42 commit 9b6574e7a7e9beb01e2e54656df7ac1e793eadb5 @jettro committed Jul 8, 2011
Showing with 16 additions and 4 deletions.
  1. +16 −4 public/js/local.js
View
@@ -6,10 +6,22 @@ $(document).ready(function() {
now.receiveContact = function(data) {
var message = JSON.parse(data);
var toWrite;
- if (message.type == 'removed') {
- toWrite = "Contact " + message.type;
- } else {
- toWrite = message.content.name + " " + message.type;
+ switch(message.type) {
+ case 'contact-removed':
+ toWrite = "Contact removed";
+ break;
+ case 'contact-created':
+ toWrite = "Contact with name " + message.content.name + " created";
+ break;
+ case 'contact-changed':
+ toWrite = "Contact changed name to " + message.content.name;
+ break;
+ case 'address-created':
+ toWrite = "Added address of type " + message.content.addressType + " to contact " + message.content.name;
+ break;
+ case 'address-removed':
+ toWrite = "Removed address of type " + message.content.addressType + " to contact " + message.content.contact.name;
+ break;
}
$("#messages").prepend("<div>" + toWrite + " </div>");
};

0 comments on commit 9b6574e

Please sign in to comment.