-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
69 lines (66 loc) · 1.92 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="en">
<head>
<title>Demo for mcverify</title>
<link rel="stylesheet" href="https://cdn.hell.sh/uikit/3.0.3/uikit.css" integrity="sha384-lFY28ULhQ2AiqfvriJizDVK5iE52SU+KE2vWYnl8GiWLYrFdwK15ausceZU7vY+K" crossorigin="anonymous">
</head>
<body class="uk-margin-left uk-margin-right">
<div class="uk-container">
<div class="uk-margin-top uk-margin-bottom">
<h1>Demo for <a href="https://github.com/timmyrs/mcverify">mcverify</a></h1>
<div id="info"><p>Please enable Javascript.</p></div>
</div>
</div>
<script>
const info = document.getElementById("info");
info.innerHTML = "Wait just a moment...";
function sendRequest(path, callback)
{
const xhr = new XMLHttpRequest();
xhr.onload = function()
{
if(xhr.status === 200)
{
callback(xhr.responseText);
}
else
{
alert("There was an unexpected issue.");
}
};
xhr.open("GET", path);
xhr.send();
}
function awaitCompletion(challenge, callback)
{
sendRequest("https://api.mcverify.de/status/" + challenge, function(res)
{
if(res !== "{}")
{
callback(JSON.parse(res));
}
else
{
setTimeout(function()
{
awaitCompletion(challenge, callback);
}, 4000);
}
});
}
sendRequest("https://api.mcverify.de/start?service=the%20website", function(res)
{
const data = JSON.parse(res);
info.innerHTML = '<p>Start Minecraft (1.7.10 or above) and "Direct Connect" to</p><input type="text" class="uk-input" value="' + data.address + '" onfocus="this.select()" readonly></b>';
document.querySelector("input").select();
setTimeout(function()
{
awaitCompletion(data.address, function(data)
{
info.innerHTML = "<h3>Thanks, " + data.username + "!</h3><p>Your UUID is " + data.uuid + ".</p>";
});
}, 7000);
});
</script>
</body>
</html>