forked from JGillam/openflagserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.html
More file actions
195 lines (176 loc) · 7.13 KB
/
main.html
File metadata and controls
195 lines (176 loc) · 7.13 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="/static/favicon.ico">
<title>Flag Submission Server</title>
<!-- Bootstrap core CSS -->
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="/static/css/main.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<!--<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>-->
<!--<![endif]-->
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Flag Submission Server</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li id="leader-tab" class="active"><a href="#">Leaderboard</a></li>
<li id="flags-tab"><a href="#">Flags</a></li>
<li id="help-tab"><a href="#">Help</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>
<div class="container">
<div class="lead" id="header"></div>
<div id="leaderboard">
<h1>Leaderboard</h1>
<table id="leadertable" class="table table-striped">
</table>
</div>
<div id="flags">
<h1>Team Flags</h1>
<div class="row">
<div class="col-md-8 .col-xs-12">
<input type="text" id="flag-entry" name="flag" class="form-control" placeholder="Enter Flag" required autofocus>
</div>
<div class="col-md-4 .col-xs-6">
<button id="submit-flag" class="btn btn-lg btn-primary btn-block" type="submit">Submit</button>
</div>
</div>
<div class="row">
<table id="flaglist" class="table table-striped">
</table>
</div>
<div id="results" class="row lead"> </div>
</div>
<div id="help">
</div>
</div>
<!-- /.container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<!--<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>-->
<script type="text/javascript">
$(document).ready(function() {
initUI();
$("#flags").hide();
$("#flags-tab").click(function() {
$("#navbar ul li").removeClass("active");
$("#flags-tab").addClass("active");
$("#leaderboard").hide();
$("#help").hide();
$("#flags").show();
listflags();
});
$("#leader-tab").click(function() {
$("#navbar ul li").removeClass("active");
$("#leader-tab").addClass("active");
$("#flags").hide();
$("#help").hide();
$("#leaderboard").show();
});
$("#help-tab").click(function() {
$("#navbar ul li").removeClass("active");
$("#help-tab").addClass("active");
$("#flags").hide();
$("#leaderboard").hide();
$("#help").show();
});
listleaders();
setInterval("listleaders()", 30000);
$("#submit-flag").click(function() {
$.ajax({
url:"/submitflag",
method:"POST",
data: {"flag": $("#flag-entry").val()},
success: function ( data ) {
if ("id" in data) {
$("#results").html("Found flag '" + data["id"] + "' for " + data["value"] + " points!");
listleaders();
} else {
$("#results").html("Sorry, that's either not a flag or you already have it.");
}
$("#results").show();
$("#results").fadeOut(5000, listflags());
}
});
});
$("#help").hide().load("/help");
});
function initUI(){
$.ajax({
url: "/initui",
data: {},
success: function( data ) {
if( "handle" in data) {
$("#header").html("Hi "+data["handle"]+"! (not you? <a href='logout'>logout</a>).");
$("#flags-tab").show();
} else {
$("#header").html("<a href='/login'>Login</a> / <a href='/register'>Register</a>");
$("#flags-tab").hide();
}
}
});
}
function listleaders(){
$.ajax({
url: "/listleaders",
data: {},
success: function( data ) {
$("#leadertable").empty();
if(data.length == 0){
$("#leadertable").append("<tr><td>None yet. Be the first!</td></tr>");
}else {
$("#leadertable").append("<tr><th>Team</th><th>Flags</th><th>Score</th></tr>");
for (var i=0;i<data.length;i++){
$("#leadertable").append("<tr><td>"+data[i]["handle"]+"</td><td>"+data[i]["flags"]+"</td><td>"+data[i]["score"]+"</td></tr>");
}
}
}
});
}
function listflags(){
$.ajax({
url: "/listflags",
data: {},
success: function( data ) {
$("#flaglist").empty();
if(data.length == 0){
$("#flaglist").append("<tr><td>None yet. Keep looking!</td></tr>");
}else {
$("#flaglist").append("<tr><th>Flag</th><th>Time</th></tr>");
for (var i=0;i<data.length;i++){
$("#flaglist").append("<tr><td>"+data[i]["id"]+"</td><td>"+data[i]["time"]+"</td></tr>");
}
}
}
});
}
</script>
</body>
</html>