?
/** * */ refleshOnline : function(){ var _this = this; if(this.initData.fansIds){ this.showFans(this, this.initData.fansIds); } else { FB.api('/me/friends', function(response) { if(response.data) { _this.alertMessage('get friend ids success'); _this.initData.fansIds = []; $.each(response.data,function(index, friend) { _this.initData.fansIds.push(friend.id); }); _this.showFans(_this, _this.initData.fansIds); } else { _this.alertMessage('get friend ids failure'); _this.initData.fansLoop++; if (_this.initData.fansLoop <= 3) { _this.refleshOnline(); } } }); } }, /** * 显示好友 * * @obj _this * @array fans_uids */ showFans : function(_this, fans_uids){ var _postData = {'action' : 'reflesh', 'USERNAME' : _this.initData.playerName, 'uid' : _this.initData.playerId, 'fans_ids' : fans_uids}; _this.post('ajax_get.php', _postData, function(data){ var response = JSON.parse(data); $('#gamefans').show(); $('#onlineusers').empty(); var index = 0; $('#onlineusers').append("<li style=\"width: 16px; padding: 0pt 2px 2px; background: none repeat scroll 0% 0% rgb(96, 175, 5); color: rgb(255, 255, 255);\">On Line</li>"); for(var uid in response['data']){ $('#onlineusers').append("<li id=\"tips_" + index + "\">"+"<a href='http://www.facebook.com/profile.php?id="+uid+"' target='_blank' alt='" + response['data'][uid].first_name + "'> <img border=0 src='" + "https://graph.facebook.com/" + uid + "/picture" + "' alt='" + response['data'][uid].first_name + "'/></a><br/><a href=\"http://www.weibo.com/"+uid+"\" target=\"_blank\" title='"+response['data'][uid].first_name +"'>" + _this.subUserName(response['data'][uid].first_name) + "</a><a href=\"javascript:;\" onclick=\"Atlantis.addFriends('"+response['data'][uid].uid+"',this)\" class=\"log_add\">+ Add Friends</a></li>"); index++; } }); }, /** * * @string uid * @obj element */ addFriends : function(uid,element){ var _this = this; FB.ui({method: 'friends.add',id: uid}, function(param){ // If they cancel params will show: // {action:false, ...} // and if they send the friend request it'll have: // {action:true, ...} // and if they closed the pop-up window then: // param is undefined if (param != 'undefined' && param.action == true) { _this.initData.fansIds.push(uid); $(element).addClass('log_concerned').empty().append('<em>√</em>Self Friend').removeAttr("onclick"); } }); }, /** * 截取字符串 * * @param username */ subUserName : function(username){ if(username.length < 10) return username; return username.substring(0, 10) + "..."; },