mirror of
https://github.com/glest/glest-source.git
synced 2025-02-24 11:42:31 +01:00
added aynch fetch for game stats
This commit is contained in:
parent
53f0334d61
commit
a88d84fd6d
50
source/masterserver/scripts/utils.js
Normal file
50
source/masterserver/scripts/utils.js
Normal file
@ -0,0 +1,50 @@
|
||||
function asynchGet(url, target) {
|
||||
//debugger;
|
||||
//alert(target);
|
||||
//document.getElementById(target).style.display='visible';
|
||||
document.getElementById(target).innerHTML = ' Fetching data...';
|
||||
if (window.XMLHttpRequest) {
|
||||
req = new XMLHttpRequest();
|
||||
} else if (window.ActiveXObject) {
|
||||
req = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
if (req != undefined) {
|
||||
req.onreadystatechange = function() {asynchDone(url, target);};
|
||||
req.open("GET", url, true);
|
||||
req.send("");
|
||||
}
|
||||
}
|
||||
|
||||
function asynchDone(url, target) {
|
||||
//debugger;
|
||||
if (req.readyState == 4) { // only if req is "loaded"
|
||||
if (req.status == 200) { // only if "OK"
|
||||
document.getElementById(target).innerHTML = req.responseText;
|
||||
} else {
|
||||
document.getElementById(target).innerHTML=" MG Error:\n"+ req.status + "\n" +req.statusText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//debugger;
|
||||
for(var gameIndex = 1; gameIndex < 200; ++gameIndex) {
|
||||
if(document.getElementById('gameStats_' + gameIndex) ) {
|
||||
var link = document.getElementById('gameStats_' + gameIndex);
|
||||
link.onclick = function() {
|
||||
var row = document.getElementById('content_row_' + this.getAttribute('gameuuid'));
|
||||
if(row && row.className == 'fullyhide') {
|
||||
row.className = 'fullyshow';
|
||||
row.innerHTML = '<td width=\'100%\' colspan=\'100\'><a id=\'hide_stats_' + this.getAttribute('gameuuid') + '\' href=\'#\'>Hide Stats</a><div width=\'100%\' id=\'content_' + this.getAttribute('gameuuid') + '\'></div></td>';
|
||||
|
||||
var link2 = document.getElementById('hide_stats_' + this.getAttribute('gameuuid'));
|
||||
link2.onclick = function() {
|
||||
this.parentNode.parentNode.className = 'fullyhide';
|
||||
};
|
||||
|
||||
var div = document.getElementById('content_' + this.getAttribute('gameuuid'));
|
||||
asynchGet('showGameStats.php?gameUUID=' + this.getAttribute('gameuuid'),div.id);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@
|
||||
echo ' <link rel="shortcut icon" type="image/x-icon" href="images/' . htmlspecialchars( strtolower( PRODUCT_NAME ) ) . '.ico" />' . PHP_EOL;
|
||||
echo ' </head>' . PHP_EOL;
|
||||
echo ' <body>' . PHP_EOL;
|
||||
echo ' <h1><a href="' . htmlspecialchars( PRODUCT_URL ) . '">' . htmlspecialchars( PRODUCT_NAME ) . '</a> game stats</h1>' . PHP_EOL;
|
||||
// echo ' <h1>Game Stats</h1>' . PHP_EOL;
|
||||
echo ' <table>' . PHP_EOL;
|
||||
echo ' <tr>' . PHP_EOL;
|
||||
echo ' <th title="gameDuration">Game Duration</th>' . PHP_EOL;
|
||||
|
@ -80,6 +80,7 @@
|
||||
echo ' <th title="binaryCompileDate">Build date</th>' . PHP_EOL;
|
||||
echo ' </tr>' . PHP_EOL;
|
||||
|
||||
$games_with_stats = 0;
|
||||
foreach( $all_servers as $server )
|
||||
{
|
||||
# Filter by version if requested
|
||||
@ -125,7 +126,9 @@
|
||||
|
||||
if (($status_code == 2 || $status_code == 3) && $server['gameUUID'] != "")
|
||||
{
|
||||
printf( "\t\t\t\t<td title=\"%s\" class=\"%s\"><a href='showGameStats.php?gameUUID=%s'>%s</a></td>%s", $server['status'], $status_class, $server['gameUUID'], htmlspecialchars( $status_title, ENT_QUOTES ), PHP_EOL );
|
||||
$games_with_stats++;
|
||||
printf( "\t\t\t\t<td title=\"%s\" class=\"%s\"><a id=\"gameStats_%d\" href=\"#\" gameuuid=\"%s\">%s</a>", $server['status'], $status_class, $games_with_stats, $server['gameUUID'], htmlspecialchars( $status_title, ENT_QUOTES ) );
|
||||
printf( "</td>%s", PHP_EOL );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -179,6 +182,14 @@
|
||||
printf( "\t\t\t\t<td>%s</td>%s", htmlspecialchars( $server['binaryCompileDate'], ENT_QUOTES ), PHP_EOL );
|
||||
|
||||
echo "\t\t\t" . '</tr>' . PHP_EOL;
|
||||
|
||||
if (($status_code == 2 || $status_code == 3) && $server['gameUUID'] != "")
|
||||
{
|
||||
//echo "\t\t\t" . '<tr>' . PHP_EOL;
|
||||
printf( "\t\t\t\t<tr width='100%%' class='fullyhide' id='content_row_%s'>%s", $server['gameUUID'], PHP_EOL );
|
||||
printf( "<td width='100%%' colspan='100'></td>%s", PHP_EOL );
|
||||
echo "\t\t\t" . '</tr>' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,6 +199,8 @@
|
||||
echo ' <br />' . PHP_EOL;
|
||||
echo ' </p>' . PHP_EOL;
|
||||
|
||||
echo ' <script language="javascript" type="text/javascript" src="scripts/utils.js"></script>' . PHP_EOL;
|
||||
|
||||
if ( FILTER_VERSION != '' )
|
||||
{
|
||||
echo "\t\t<p>Filters active:</p>" . PHP_EOL;
|
||||
|
@ -62,3 +62,5 @@ th {
|
||||
background-color: Red;
|
||||
}
|
||||
|
||||
.fullyhide { display: none }
|
||||
.fullyshow { display: }
|
||||
|
Loading…
x
Reference in New Issue
Block a user