in-line display of online outfit members - PlanetSide Universe
PSU Social Facebook Twitter Twitter YouTube Steam TwitchTV
PlanetSide Universe
PSU: Friendly fire - isn't.
Home Forum Chat Wiki Social AGN PS2 Stats
Notices
Go Back   PlanetSide Universe > PlanetSide Discussions > PlanetSide 2 API Discussion

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 2013-05-28, 08:57 PM   [Ignore Me] #1
Athan
Private
 
Post in-line display of online outfit members


I put this together for use on an enjin.com-hosted site, but it should work on anything you can place the HTML in, so long as you have a jQuery version loaded already.

Note the YOUR_OUTFIT_ID_HERE that you need to edit in the query.

Also the CSS will need tweaking for your own use, as I borrow various bits of the enjin theme we use.

It auto-refreshes every 5 minutes, or there's a Refresh button you can use.

Code:
<div id="ps2-ingame">
 <div class="element_smalltitle">
  <div class="left"><!-- --></div>
  <div class="right"><!-- --></div>
  <div id="in-game-members-header" class="title">In-Game Currently:</div>
 </div>
 <div id="in-game-members" class="m_shoutbox" style="height: 150px; overflow-y: scroll;"></div>
 <div id="ps2-ingame-as-of" style="text-align: center"></div>
 <div style="text-align: center;">
  <div class="element_smallbutton">
   <div class="l"><!-- --></div>
   <div class="r"><!-- --></div>
   <input id="ps2-ingame-refresh" type="button" value="Refresh">
  </div>
 </div>
</div>

<script type="text/javascript">
  var refreshTimer = null;
  window.jQuery(document).ready(function($) {

    $('#ps2-ingame-refresh').click(refreshIngameStatus);
    doIngameStatus();
  });

  function doIngameStatus() {
    $.ajax({
      url: 'http://census.soe.com/s:miggyorg/get/ps2-beta/outfit/YOUR_OUTFIT_ID_HERE/?c:resolve=member,member_online_status,member_character%28name%29',
      type: 'GET',
      timeout: 20000,
      dataType: 'jsonp',
      success: onMembersReceived,
      complete: onMembersComplete
    });
  }

  function onMembersReceived(json) {
    var now = new Date();

    var ingame_members = countOnlineMembers(json.outfit_list[0]);
    $('#in-game-members-header').html('In-Game Currently (' + ingame_members.length + '):');
    $('#in-game-members').html('');
    for (var x = 0 ; x < ingame_members.length ; x++) {
      $('#in-game-members').append('<div class="shout">' + ingame_members[x] + '</div>');
    }
    $('#ps2-ingame-as-of').html('<div class="shout">As of: ' + now.toTimeString() + '</div>');

  }

  function countOnlineMembers(outfit_list) {
    var ingame = new Array();
    for (var m = 0 ; m < outfit_list.members.length ; m++) {
      if (outfit_list.members[m].online_status > 0) {
        ingame.push(outfit_list.members[m].name.first);
      }
    }
    ingame.sort(caseiCompare);
    return ingame;
  }

        function caseiCompare(a, b) {
                var ai = a.toLowerCase();
                var bi = b.toLowerCase();

                if (ai > bi) {
                        return 1;
                } else if (ai < bi) {
                        return -1;
                } else {
                        return 0;
                }
        }

  function refreshIngameStatus() {
    refreshTimer = null;
    doIngameStatus();
  }

  function onMembersComplete(jqQuery, jqStatus) {
    refreshTimer = setTimeout(refreshIngameStatus, 5 * 60 * 1000);
  }
</script>
Athan is offline  
 
  PlanetSide Universe > PlanetSide Discussions > PlanetSide 2 API Discussion

Bookmarks

Tags
enjin, ingame, jquery

Discord


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 10:51 AM.

Content © 2002-2013, PlanetSide-Universe.com, All rights reserved.
PlanetSide and the SOE logo are registered trademarks of Sony Online Entertainment Inc. © 2004 Sony Online Entertainment Inc. All rights reserved.
All other trademarks or tradenames are properties of their respective owners.
Powered by vBulletin
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.