mirror of
https://github.com/glest/glest-source.git
synced 2025-09-26 23:49:03 +02:00
added aynch fetch for game stats
This commit is contained in:
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;
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user