Hi,
I'm currently working on a plugin which adds all current platoon members which are online to the comcenter. Of course sorted by groups.
It is based on the dicefriends plugin and although it is working, it only does so when I add an alert to it.
I can't get it to work without the alert. Maybe somebody has an idea ord figures it out.
The development link to the plugin is:
http://labs.web-wack.at/platoonFriends.js
Regards,
Horfic
BrainFooLong
Administrator
It's a simple "problem" but a bit harder to fix.
Your problem is that you use some iterations, and in it you call functions/methods.
And thats the point with the problem - Javascript is ASYNC, so it could happen that your iteration is finished but some method calls in it are still in queue in a undefined order.
Thats also the reason why most things in javascript apis like jQuery work with callbacks.
When you call "alert" on every iteration step, the script stops at this point but already queued method calls still be processed.
morre599
I was inspired by this script and made it work. It is a litle buggy but it works. var PlatoonFriends = {
updateInterval : 60*5,
init : function () {
var friendListSurface = $S("comcenter-surface-friends");
friendListSurface.oldUpdate = friendListSurface.update;
friendListSurface.update = function(itemState, opts) { var ret = this.oldUpdate(itemState, opts); PlatoonFriends.update(); return ret;}
friendListSurface.oldRefresh = friendListSurface.refresh;
friendListSurface.refresh = function() { var ret = this.oldRefresh(); PlatoonFriends.update(); return ret;}
update : function() {
var platoons = Surface.globalContext.userContext.platoons;
var platoonsObj = [];
var playerList = [];
for (var i = 0; i 0) {
// if yes, clear it
platoonContainer.empty();
} else {
// if no, create it
$('#comcenter-surface-friends #comcenterOnlineFriends').before(
$('').attr('id', 'comcenterPlatoonFriends-'+id)
);
for(var i in members) {
var member = members[i];
var user = member.user;
// if player is member of the platoon (not only invited) and in a PC game
//if(member.membershipLevel >= 4 && user.presence.isPlaying && user.presence.platform == 1 )
if(member.membershipLevel >= 4 && user.presence.isOnline && json.context.me.userId != user.userId) {
var player =
{
name : user.username,
userId : user.userId,
personaId : member.personaId,
userAvatar : user.gravatarMd5,
serverGuid : user.presence.serverGuid,
serverName : user.presence.serverName
}