var User = Class.create(); User.prototype = { msid : null, name : null, picTiny : null, isAppUser : null, friends : null, friendsWithApp : null, friendsWithoutApp : null, osPersonObj : null, // Constructor. Takes a myspace person object initialize : function(_personObj, _isAppUser) { this.osPersonObj = _personObj; this.msid = _personObj.getId().replace('myspace.com:', ''); this.name = _personObj.getDisplayName(); if (this.name == null || this.name.length == 0) this.name = 'Somebody'; this.picTiny = _personObj.getField(opensocial.Person.Field.THUMBNAIL_URL); this.isAppUser = _isAppUser; }, // Add friends to the object. Parameters are from opensocial addFriends : function(_friends, _friendsWithApp) { var tmpFriends = {}; var tmpFriendsWithApp = {}; var tmpFriendsWithoutApp = {}; for (var i = 0; i < _friends.length; ++i) { var user = new User(_friends[i], false); tmpFriends[user.msid] = user; } for (var i = 0; i < _friendsWithApp.length; ++i) { var id = _friendsWithApp[i].getId(); if (tmpFriends[id] != undefined) { tmpFriends[id].isAppUser = true; tmpFriendsWithApp[id] = tmpFriends[id]; } else { var user = new User(_friendsWithApp[i], false); tmpFriendsWithApp[user.msid] = user; } } for (var i = 0; i < _friends.length; ++i) { var id = _friends[i].getId().sub('myspace.com:', ''); if (tmpFriends[id].isAppUser == false) tmpFriendsWithoutApp[id] = tmpFriends[id]; } this.friends = $H(tmpFriends); this.friendsWithApp = $H(tmpFriendsWithApp); this.friendsWithoutApp = $H(tmpFriendsWithoutApp); } };