big consolidation
This commit is contained in:
101
fnf2014/hackordrink/test1.html
Normal file
101
fnf2014/hackordrink/test1.html
Normal file
@@ -0,0 +1,101 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
function generateBallotKey()
|
||||
{
|
||||
document.write(createUUID());
|
||||
}
|
||||
|
||||
function gatherKeys()
|
||||
{
|
||||
var voters = new Array();
|
||||
var voterKeyCount = prompt("How many voters do you wish to allow?");
|
||||
for (var i=0; i<voterKeyCount; i++)
|
||||
{
|
||||
voters[i] = createUUID();
|
||||
document.write(voters[i] + "<br>");
|
||||
}
|
||||
return voters;
|
||||
}
|
||||
|
||||
function createUUID()
|
||||
{
|
||||
// http://www.ietf.org/rfc/rfc4122.txt
|
||||
var s = [];
|
||||
var hexDigits = "0123456789abcdef";
|
||||
for (var i = 0; i < 36; i++)
|
||||
{
|
||||
s[i] = hexDigits.substr(Math.floor(Math.random() *
|
||||
0x10), 1);
|
||||
}
|
||||
s[14] = "4"; // bits 12-15 of the time_hi_and_version field
|
||||
// to 0010
|
||||
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); //
|
||||
// bits 6-7 of the clock_seq_hi_and_reserved to 01
|
||||
s[8] = s[13] = s[18] = s[23] = "-";
|
||||
|
||||
var uuid = s.join("");
|
||||
return uuid;
|
||||
}
|
||||
|
||||
function putKey(ballotKey)
|
||||
{
|
||||
var baseURL = "http://askbot.corp.thefnf.net:8080";
|
||||
baseURL = baseURL + "/polkey=" + ballotKey;
|
||||
var client = new XMLHttpRequest();
|
||||
// alert("inputkey");
|
||||
|
||||
client.open('POST', baseURL, true);
|
||||
client.setRequestHeader("Context-Type", "text/plain");
|
||||
|
||||
client.send();
|
||||
// alert("send");
|
||||
}
|
||||
|
||||
|
||||
|
||||
function putKeys()
|
||||
{
|
||||
var url = "http://askbot.corp.thefnf.net:8080/polkey=googoogaagaa";
|
||||
|
||||
var client = new XMLHttpRequest();
|
||||
client.open('POST', url, false);
|
||||
|
||||
alert(client.toString());
|
||||
|
||||
client.setRequestHeader("Content-Type", "text/plain");
|
||||
|
||||
client.send();
|
||||
|
||||
if (client.status == 200)
|
||||
alert("yay");
|
||||
else
|
||||
alert("nay");
|
||||
}
|
||||
|
||||
function begin()
|
||||
{
|
||||
var voters = gatherKeys();
|
||||
alert(voters.length);
|
||||
for (var i=0;i<voters.length;i++)
|
||||
{
|
||||
putKey(voters[i]);
|
||||
}
|
||||
alert("done!");
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<input type="button" onclick="getInfo()" value="Generate Voter Keys" />
|
||||
|
||||
<input type="button" onclick="generateBallotKey()" value="Generate Ballot Key"/>
|
||||
|
||||
<input type="button" onclick="putKeys()" value="Test Shit"/>
|
||||
|
||||
<input type="button" onclick="begin()" value="Begin"/>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user