-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwelcome.html
80 lines (76 loc) · 2.21 KB
/
welcome.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
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<script>
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function add_kill(k)
{
var ul=document.getElementById("hs_list")
var li=document.createElement("li")
li.appendChild(document.createTextNode(k.name+" "+k.kills))
ul.appendChild(li)
}
function get_highscore() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4) {
if(this.status==200)
{
var kills= JSON.parse(this.responseText);
kills.sort(function (a,b) {
return b.kills-a.kills
})
for (var i = 0; i < Math.min(kills.length,10); i++) {
add_kill(kills[i])
}
}
}
};
xhttp.open("GET", "get_kills", true);
xhttp.send();
}
</script>
<header>
<h1>Dwarf fortress</h1>
<p>The multiplayer experience: the fortening</p>
</header>
<div id='motd'><b>MOTD: !!message_of_the_day!!</b></div>
<div id='user_play'></div>
<p>To play:<a href="login">Login</a>. If you don't have an account, it will be created when you try to login with that name.</p>
<p>Or you can just <a href="spectate">Spectate</a>.</p>
<p>More info in forums: <a href="http://www.bay12forums.com/smf/index.php?topic=165168.0"> DF forum thread</a> Source code:<a href="https://github.com/warmist/df_multiplay">Github repo</a></p>
<div id='highscore'>
Highscore:
<ul id="hs_list">
</ul>
</div>
<script type="text/javascript">
get_highscore()
//show play if you are logged in
var user=getCookie('username')
if(user!="")
{
document.getElementById("user_play").innerHTML = "<p> Welcome back "+user+". Would you like to <a href=play>Play</a>?</p>"
}
</script>
</header>
</body>
</html>