Skip to content

Commit

Permalink
update snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
Nexolight committed May 26, 2018
1 parent b02dc26 commit b2cdae3
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions snippets/statistics_wp.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
<div id="playersonline" style="min-height: 0px;">
<h3>Online:</h3>
<div id="playersonline_list"></div>
</div><br>

</div>
&nbsp;
<div id="playeroffline" style="min-height: 0px;">
<h3>Offline:</h3>
<div id="playersoffline_list" style="color: red;"></div>
</div><br>

</div>
&nbsp;
<div id="playersgone" style="min-height: 0px;">
<h3>Inactive (7 days):</h3>
<h3>Inactive (28 days):</h3>
<div id="playersgone_list" style="color: gray;"></div>
</div><br>

</div>
&nbsp;
<div id="playeronserver" style="min-height: 500px;"></div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
Expand Down Expand Up @@ -47,14 +47,23 @@ <h3>Inactive (7 days):</h3>
mkChart(jsondata);
}
})
var proto = "http";
var port = "6001";
if(location.protocol != 'https:'){
proto="http";
port="6001"
}else{
proto="https"
port="6002"
}
function startFlow(){
var container = $("#playercharts");
var err_cantparse = $("#err_cantparse")
var err_nocon = $("#err_nocon")
function updateme(){
$.ajax({
type: "GET",
url: "http://ark420-the.center:6001/serverstats?scope=all",
url: proto+"://tortuga.coldbyte.net:"+port+"/serverstats?scope=all",
async: true,
cache: false,
success: function(data){
Expand All @@ -78,7 +87,7 @@ <h3>Inactive (7 days):</h3>
}
setTimeout(function(){
updateme();
},1000)
},10000)
},
error: function(data){
if(!$(err_nocon).is(":visible")){
Expand Down Expand Up @@ -138,11 +147,22 @@ <h3>Inactive (7 days):</h3>
playername=this.name;
playerprofile=getSteamProfile(this.steamid);
playerid=this.steamid;
lastseen=this.lastseen;
now = new Date().getTime() / 1000;
if(now-lastseen < 126){
if(this.isonline){
putPlayerToList(playername,playerprofile,playerid,$(playersonline_list),"green");
}else if(now-lastseen < 604800){ putPlayerToList(playername,playerprofile,playerid,$(playersoffline_list),"#b2533e"); }else{ putPlayerToList(playername,playerprofile,playerid,$(playersgone_list),"#9b9b9b"); } }) } function putPlayerToList(name,profile,id,destList,color){ var strid = "#"+String(id); if($(destList).find(strid).length == 0){ var fonline = $(playersonline_list).find(strid); var foffline = $(playersoffline_list).find(strid); var fgone = $(playersgone_list).find(strid); if($(fonline).length > 0){
}else if(!this.isonline && now-2419200 <= this.lastseen){
putPlayerToList(playername,playerprofile,playerid,$(playersoffline_list),"#b2533e");
}else{
putPlayerToList(playername,playerprofile,playerid,$(playersgone_list),"#9b9b9b");
}
})
} function putPlayerToList(name,profile,id,destList,color){
var strid = "#"+String(id);
if($(destList).find(strid).length == 0){
var fonline = $(playersonline_list).find(strid);
var foffline = $(playersoffline_list).find(strid);
var fgone = $(playersgone_list).find(strid);
if($(fonline).length > 0){
$(fonline).remove();
}else if($(foffline).length > 0){
$(foffline).remove();
Expand All @@ -159,4 +179,4 @@ <h3>Inactive (7 days):</h3>
function getSteamProfile(steamid){
return "http://steamcommunity.com/profiles/"+String(steamid);
}
</script>
</script>

0 comments on commit b2cdae3

Please sign in to comment.