Permalink
Browse files

Mock session

  • Loading branch information...
1 parent 22826f4 commit b7443c00dc6155c73b3e377321665d76df0a2f95 @jaseemabid committed Apr 9, 2012
Showing with 18 additions and 8 deletions.
  1. +13 −6 static/js/routers.js
  2. +5 −2 static/js/views.js
View
@@ -12,22 +12,29 @@ fooChat.Routers = {
},
initialize: function () {},
home: function () {
- fooChat.activeUser = new fooChat.Models.ActiveUser();
- if(fooChat.activeUser.get('uid') === 0 ) {
+
+ fooChat.activeUser = fooChat.activeUser || new fooChat.Models.ActiveUser();
+ if (fooChat.activeUser.get('uid') === 0) {
fooChat.appRouter.navigate('/login', true);
return;
}
- //fooChat.activeUser.set({'uid':'3d123352c8c4c8866f5158acc6000366'}); // jaseemabid's
- //fooChat.activeUser.set({'uid': '3d123352c8c4c8866f5158acc60010d7'}); // swvist's
+
fooChat.contacts = new fooChat.Collections.ContactList([], fooChat.activeUser);
fooChat.messages = new fooChat.Collections.MessageList([], fooChat.activeUser);
fooChat.topBar = new fooChat.Views.TopBarView(fooChat.activeUser);
fooChat.app = new fooChat.Views.AppView();
},
login: function () {
- console.log("login");
- fooChat.activeUser = new fooChat.Models.ActiveUser();
fooChat.loginView = new fooChat.Views.LoginView();
+ fooChat.activeUser = fooChat.activeUser || new fooChat.Models.ActiveUser();
+
+ fooChat.activeUser.fetch({
+ "success": function (model, response) {
+ fooChat.appRouter.navigate('/', true);
+ },"error" : function (model, response) {
+ console.error("fooChat.activeUser.fetch error");
+ }
+ });
},
blank: function () {
console.log("blank");
View
@@ -52,7 +52,9 @@ fooChat.Views = {
},
render: function () {
- $("div#messageBox").append($(this.el).html(this.template.supplant({})));
+ $('ul#dashBoard').remove();
+ $('div#sideBar').html('');
+ $("div#messageBox").html('').append($(this.el).html(this.template.supplant({})));
return this;
}
}),
@@ -113,7 +115,7 @@ fooChat.Views = {
this.$el.val('');
},
render: function () {
- $("div#messageBox").append($(this.el));
+ $("div#messageBox").html('').append($(this.el));
return this;
}
}),
@@ -140,6 +142,7 @@ fooChat.Views = {
$('ul#contactsList').append(view.render().el);
},
addAllContact: function () {
+ $('div#sideBar').prepend($('<ul>').attr({id:'contactsList'}).addClass('nav nav-tabs nav-stacked') );
fooChat.contacts.each(this.addOneContact);
},
addOneMessage: function (message) {

0 comments on commit b7443c0

Please sign in to comment.