Created
June 5, 2015 12:35
-
-
Save twist84/a5870b79404dea04223a to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/xexaxuraju
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="host1"> | |
<button onclick="checkServerStatus(this, 'http://94.10.224.155:11775/')">theTwister</button> | |
<p></p> | |
</div> | |
<div id="host2"> | |
<button onclick="checkServerStatus(this, 'http://82.33.96.129:11775/')">Personality</button> | |
<p></p> | |
</div> | |
<div id="host3"> | |
<button onclick="checkServerStatus(this, 'http://66.232.166.71:11775/')">gears</button> | |
<p></p> | |
</div> | |
<div id="host4"></div> | |
<div id="host5"></div> | |
<div id="host6"></div> | |
<div id="host7"></div> | |
<div id="host8"></div> | |
<div id="host9"></div> | |
<div id="host10"></div> | |
<div id="host11"></div> | |
<div id="host12"></div> | |
<div id="host13"></div> | |
<div id="host14"></div> | |
<div id="host15"></div> | |
<div id="host16"></div> | |
<script id="jsbin-javascript"> | |
function checkServerStatus( | |
btn, url | |
) { | |
function getValues( | |
obj, key | |
) { | |
var objects = []; | |
for ( | |
var i in obj | |
) { | |
if (!obj.hasOwnProperty(i)) continue; | |
if ( | |
typeof obj[i] == 'object' | |
) { | |
objects = objects.concat( | |
getValues(obj[i], key) | |
); | |
} else if ( | |
i == key | |
) { | |
objects.push( | |
obj[i] | |
); | |
} | |
} | |
return objects; | |
} | |
var script = document.body.appendChild( | |
document.createElement( | |
"script" | |
) | |
); | |
script.onload = function() { | |
if ( | |
window.XMLHttpRequest | |
) xmlhttp = new XMLHttpRequest(); | |
else xmlhttp = new ActiveXObject( | |
"Microsoft.XMLHTTP" | |
); | |
xmlhttp.open( | |
"GET", url, false | |
); | |
xmlhttp.send(); | |
var json = JSON.parse( | |
xmlhttp.responseText | |
); | |
var capitalized = json.variantType.charAt( | |
0 | |
).toUpperCase() + json.variantType.substring( | |
1 | |
); | |
var info = json.hostPlayer + " is hosting " + capitalized + "\n" + json.variant + " On " + json.map + | |
"\nThere is currently " + json.numPlayers + " of " + json.maxPlayers + " players in this game" + | |
"\n" + getValues(json.players, 'name') + "\n\nUse Server.Connect " + url.split('/')[2].split(':')[0] + | |
" to join" + "\nThis game is hosted at " + url + "\n\nYou need ElDewrito v" + json.eldewritoVersion + | |
" in order to play on this server\n"; | |
var output = info.split( | |
"\n" | |
).join( | |
"<br />" | |
); | |
var divID = btn.parentNode.id; | |
document.getElementById( | |
divID | |
).getElementsByTagName( | |
'p' | |
)[0].innerHTML = output; | |
console.clear(); | |
console.log( | |
"\n" + info | |
); | |
//alert(info); | |
}; | |
var divID = btn.parentNode.id; | |
script.onerror = function() { | |
console.log( | |
"There is no one hosting on " + url | |
); | |
document.getElementById( | |
divID | |
).getElementsByTagName( | |
'p' | |
)[0].innerHTML = | |
"There is no one hosting on " + url; | |
}; | |
script.src = url; | |
} | |
// | |
//checkServerStatus( '94.10.224.155' ); | |
//checkServerStatus( 'http://82.33.96.129:11775/' ); | |
//checkServerStatus( '2.71.247.62' ); | |
//checkServerStatus( 'http://66.232.166.71:11775/' ); | |
//IP = prompt("Enter An IP address or Host name", "94.10.224.155"); | |
//checkServerStatus(IP); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">function checkServerStatus( | |
btn, url | |
) { | |
function getValues( | |
obj, key | |
) { | |
var objects = []; | |
for ( | |
var i in obj | |
) { | |
if (!obj.hasOwnProperty(i)) continue; | |
if ( | |
typeof obj[i] == 'object' | |
) { | |
objects = objects.concat( | |
getValues(obj[i], key) | |
); | |
} else if ( | |
i == key | |
) { | |
objects.push( | |
obj[i] | |
); | |
} | |
} | |
return objects; | |
} | |
var script = document.body.appendChild( | |
document.createElement( | |
"script" | |
) | |
); | |
script.onload = function() { | |
if ( | |
window.XMLHttpRequest | |
) xmlhttp = new XMLHttpRequest(); | |
else xmlhttp = new ActiveXObject( | |
"Microsoft.XMLHTTP" | |
); | |
xmlhttp.open( | |
"GET", url, false | |
); | |
xmlhttp.send(); | |
var json = JSON.parse( | |
xmlhttp.responseText | |
); | |
var capitalized = json.variantType.charAt( | |
0 | |
).toUpperCase() + json.variantType.substring( | |
1 | |
); | |
var info = json.hostPlayer + " is hosting " + capitalized + "\n" + json.variant + " On " + json.map + | |
"\nThere is currently " + json.numPlayers + " of " + json.maxPlayers + " players in this game" + | |
"\n" + getValues(json.players, 'name') + "\n\nUse Server.Connect " + url.split('/')[2].split(':')[0] + | |
" to join" + "\nThis game is hosted at " + url + "\n\nYou need ElDewrito v" + json.eldewritoVersion + | |
" in order to play on this server\n"; | |
var output = info.split( | |
"\n" | |
).join( | |
"<br />" | |
); | |
var divID = btn.parentNode.id; | |
document.getElementById( | |
divID | |
).getElementsByTagName( | |
'p' | |
)[0].innerHTML = output; | |
console.clear(); | |
console.log( | |
"\n" + info | |
); | |
//alert(info); | |
}; | |
var divID = btn.parentNode.id; | |
script.onerror = function() { | |
console.log( | |
"There is no one hosting on " + url | |
); | |
document.getElementById( | |
divID | |
).getElementsByTagName( | |
'p' | |
)[0].innerHTML = | |
"There is no one hosting on " + url; | |
}; | |
script.src = url; | |
} | |
// | |
//checkServerStatus( '94.10.224.155' ); | |
//checkServerStatus( 'http://82.33.96.129:11775/' ); | |
//checkServerStatus( '2.71.247.62' ); | |
//checkServerStatus( 'http://66.232.166.71:11775/' ); | |
//IP = prompt("Enter An IP address or Host name", "94.10.224.155"); | |
//checkServerStatus(IP);</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkServerStatus( | |
btn, url | |
) { | |
function getValues( | |
obj, key | |
) { | |
var objects = []; | |
for ( | |
var i in obj | |
) { | |
if (!obj.hasOwnProperty(i)) continue; | |
if ( | |
typeof obj[i] == 'object' | |
) { | |
objects = objects.concat( | |
getValues(obj[i], key) | |
); | |
} else if ( | |
i == key | |
) { | |
objects.push( | |
obj[i] | |
); | |
} | |
} | |
return objects; | |
} | |
var script = document.body.appendChild( | |
document.createElement( | |
"script" | |
) | |
); | |
script.onload = function() { | |
if ( | |
window.XMLHttpRequest | |
) xmlhttp = new XMLHttpRequest(); | |
else xmlhttp = new ActiveXObject( | |
"Microsoft.XMLHTTP" | |
); | |
xmlhttp.open( | |
"GET", url, false | |
); | |
xmlhttp.send(); | |
var json = JSON.parse( | |
xmlhttp.responseText | |
); | |
var capitalized = json.variantType.charAt( | |
0 | |
).toUpperCase() + json.variantType.substring( | |
1 | |
); | |
var info = json.hostPlayer + " is hosting " + capitalized + "\n" + json.variant + " On " + json.map + | |
"\nThere is currently " + json.numPlayers + " of " + json.maxPlayers + " players in this game" + | |
"\n" + getValues(json.players, 'name') + "\n\nUse Server.Connect " + url.split('/')[2].split(':')[0] + | |
" to join" + "\nThis game is hosted at " + url + "\n\nYou need ElDewrito v" + json.eldewritoVersion + | |
" in order to play on this server\n"; | |
var output = info.split( | |
"\n" | |
).join( | |
"<br />" | |
); | |
var divID = btn.parentNode.id; | |
document.getElementById( | |
divID | |
).getElementsByTagName( | |
'p' | |
)[0].innerHTML = output; | |
console.clear(); | |
console.log( | |
"\n" + info | |
); | |
//alert(info); | |
}; | |
var divID = btn.parentNode.id; | |
script.onerror = function() { | |
console.log( | |
"There is no one hosting on " + url | |
); | |
document.getElementById( | |
divID | |
).getElementsByTagName( | |
'p' | |
)[0].innerHTML = | |
"There is no one hosting on " + url; | |
}; | |
script.src = url; | |
} | |
// | |
//checkServerStatus( '94.10.224.155' ); | |
//checkServerStatus( 'http://82.33.96.129:11775/' ); | |
//checkServerStatus( '2.71.247.62' ); | |
//checkServerStatus( 'http://66.232.166.71:11775/' ); | |
//IP = prompt("Enter An IP address or Host name", "94.10.224.155"); | |
//checkServerStatus(IP); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment