Created
October 11, 2012 20:40
-
-
Save calebrob6/3875327 to your computer and use it in GitHub Desktop.
Start of tictactoe gui
This file contains hidden or 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
<html> | |
<head> | |
<title>GUI for Interacting with HTTP Server</title> | |
<script type="text/javascript"> | |
var userId = -1; | |
var userAuth = -1; | |
var gameStarted = false; | |
function getXMLHttpRequestObject() { | |
var ref = null; | |
if (window.XMLHttpRequest) { | |
ref = new XMLHttpRequest(); | |
} else if (window.ActiveXObject) { // Older IE. | |
ref = new ActiveXObject("MSXML2.XMLHTTP.3.0"); | |
} | |
return ref; | |
} | |
function doConnect(){ | |
http = getXMLHttpRequestObject(); | |
params = ""; | |
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | |
http.setRequestHeader("Content-length", params.length); | |
http.setRequestHeader("Connection", "close"); | |
http.onreadystatechange = function() { | |
alert(http.readyState); | |
if(xmlhttp.readyState == 4){ | |
alert(http.responseText); | |
} | |
}; | |
http.open("POST","http://localhost:8000/connect",false); | |
http.send(params); | |
http.close(); | |
} | |
function doCommand(path,params,callback){ | |
http = getXMLHttpRequestObject(); | |
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | |
http.setRequestHeader("Content-length", params.length); | |
http.setRequestHeader("Connection", "close"); | |
http.onreadystatechange = function() { | |
if(xmlhttp.readyState == 4){ | |
callback(http.responseText); | |
} | |
}; | |
http.open("POST","http://localhost:8000"+path,true); | |
http.send(params); | |
} | |
function getStatus(){ | |
doCommand("/game/status","",processStatus); | |
} | |
function processStatus(sText){ | |
eval("board="+sText) | |
for(){ | |
for(){ | |
document.getElementById(x+";"+y).value= | |
} | |
} | |
} | |
function doMove(x,y){ | |
} | |
</script> | |
</head> | |
<body> | |
<table borders="0"> | |
<tr> | |
<td><input type='button' id='0;0' value='_' size='3' onclick="doMove(this.id)"></td> | |
<td><input type='button' id='0;0' value='_' size='3' onclick="doMove(this.id)"></td> | |
<td><input type='button' id='0;0' value='_' size='3' onclick="doMove(this.id)"></td> | |
</tr> | |
<tr> | |
<td><input type='button' id='0;0' value='_' size='3' onclick="doMove(this.id)"></td> | |
<td><input type='button' id='0;0' value='_' size='3' onclick="doMove(this.id)"></td> | |
<td><input type='button' id='0;0' value='_' size='3' onclick="doMove(this.id)"></td> | |
</tr> | |
<tr> | |
<td><input type='button' id='0;0' value='_' size='3' onclick="doMove(this.id)"></td> | |
<td><input type='button' id='0;0' value='_' size='3' onclick="doMove(this.id)"></td> | |
<td><input type='button' id='0;0' value='_' size='3' onclick="doMove(this.id)"></td> | |
</tr> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment