$(document).ready(function () { checkStatus(); var intervalid = setInterval(function () { checkStatus(); }, 10 * 1000); }) function checkStatus() { $.ajax({ url: apiurl, success: function (json) { json = json.tsstatus; var result = ""; if (json.success) { var clientsonline = json.clientsonline; var maxclients = json.maxclients; var clientsprecent = Math.round(json.clientsonline * 100 / json.maxclients); var version = json.version; var platform = json.platform; var uptime = json.uptime; var averagePacketloss = Math.round(json.averagePacketloss * 100) / 100; var averagePing = Math.round(json.averagePing * 100) / 100; result = '
' + statusOnline + ': ' + clientsonline + ' / ' + maxclients + ' (' + clientsprecent + '%)
' + '' + statusUptime + ': ' + uptime + '
' + '' + statusVersion + ': ' + version + ' @ ' + platform + '
' + '' + statusAvgping + ': ' + averagePing + ' ms
' + '' + statusAvgpl + ': ' + averagePacketloss + '%
'; } else { result = 'Online: ' + statusOffline + '
'; } $("#serverstatus").html(result); }, error: function (result) { $("#serverstatus").html('' + statusOnline + ': ERROR
'); } }) }