Permalink
Browse files

update

  • Loading branch information...
justmiaotou committed May 10, 2012
1 parent 27fb9c1 commit 5f9f3c906bd395644266007c384ecdfd03590dcb
Showing with 64 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +49 −0 app/models/User.js
  3. +14 −0 common.js
View
@@ -1,2 +1,3 @@
node_modules/
*.swp
+structure.txt
View
@@ -0,0 +1,49 @@
+var helper = require('../../common.js');
+
+module.exports = function (details) {
+ var nickname = details.nickname,
+ id = details.id,
+ groups = details.groups,
+ rss = details.rss,
+ friends = details.friends,
+ socket = details.socket;
+
+ return {
+ getNickname: function() {
+ return nickname;
+ },
+ getId: function() {
+ return id;
+ },
+ getGroups: function() {
+ return groups;
+ },
+ getSocket: function() {
+ return socket;
+ },
+ setNickname: function(nn) {
+ nickname = nn;
+ },
+ setId: function(d) {
+ id = d;
+ },
+ addGroup: function(grp) {
+ var grpId = grp.getId();
+ if (groups[grpId]) {
+ return this.ALREADY_IN_GROUP;
+ } else {
+ groups[grpId] = grp;
+ }
+ },
+ leaveGroup: function(grpOrId) {
+ var grpId = helper.isString(grpOrId) ? grpOrId : grp.getId();
+ if (groups[grpId]) {
+ delete groups[grpId];
+ }
+ },
+ setSocket: function(soc) {
+ socket = soc;
+ },
+ ALREADY_IN_GROUP : 3
+ }
+};
View
@@ -0,0 +1,14 @@
+module.exports = {
+ toString: function(target) {
+ Object.prototype.toString.apply(target);
+ },
+ isString: function(obj) {
+ return this.toString(obj).toLowerCase() === '[object string]';
+ },
+ isFunction: function(obj) {
+ return this.toString(obj).toLowerCase() === '[object function]';
+ },
+ isArray: function(obj) {
+ return this.toString(obj).toLowerCase() === '[object array]';
+ }
+};

0 comments on commit 5f9f3c9

Please sign in to comment.