-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloadout.html
148 lines (138 loc) · 6.03 KB
/
loadout.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
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
<!doctype html>
<html>
<head>
<title>Your Hacker Team</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link href="/static/css/create.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="static/css/tipsy.css">
<style>
#page {
text-align: center;
}
#start_hackathon {
width: 100px;
height: 30px;
background: #D0D0D0;
border: none;
font-size: 18px;
}
#start_hackathon:hover {
background: #F0F0F0;
transition: background 0.5s;
-webkit-transition: background 0.5s;
}
#start_hackathon:active {
background: #C0C0C0;
}
.level {
position: absolute;
top: 7px;
right: 5px;
font-size: 16px;
border: 1px solid #666;
border-radius: 10px;
background: #000;
}
</style>
</head>
<body>
<div id="page">
<div id="connection_failure" class="hidden">Failed to connect - try refreshing the page</div>
<button id="start_hackathon">Play</button>
<div id="waiting_for_game" class="hidden">Waiting for game...</div>
<h1>Your hackathon team</h1>
<div id="your_hackers"></div>
</div>
<script src="/static/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="/_ah/channel/jsapi"></script>
<script src="/static/js/jquery.tipsy.js"></script>
<script src="/static/js/util.js"></script>
<!-- user interaction, etc -->
<script>
$(function() {
$(".icon").tipsy({'gravity': 'sw'});
});
{% for hacker in user.hackers %}
var html = insert_hacker({
name: '{{ hacker.first_name }} {{ hacker.last_name }}',
level: {{ hacker.level }},
clss: '{{ hacker.class }}',
img: '{{ hacker.imageset }}',
energy: {{ hacker.base_energy }},
productivity: {{ hacker.base_productivity }},
teamwork: {{ hacker.base_teamwork }}
}, true);
$("#your_hackers").append(html);
{% endfor %}
$(".statbar").each(function(index) {
make_stat_bar($(this), 100);
});
$("#start_hackathon").click(function() {
$.get('/hackathon/find', {}, function(data) {
// TODO check for error
console.log(data);
});
$("#waiting_for_game").show();
});
function insert_hacker(args) {
var output = $("<div class='hacker element'></div>")
.append("<div class='level'>" + args.level + "</div>")
.append("<div class='name'>" + args.name + "</div>")
.append("<div class='class'>" + args.clss + "</div>")
.append("<img src='/static/images/hackers/" + args.img + "front.png' />")
.data('name', args.name)
.data('clss', args.clss)
.data('img', args.img)
.data('energy', args.energy)
.data('productivity', args.productivity)
.data('teamwork', args.teamwork);
var table = $("<table class='stats_table'></table>")
.append("<tr><th><div class='energy icon' title='Energy determines how long the hacker can work for'></div></th><td><div class='statbar energy'>" + args.energy + "</div></td></tr>")
.append("<tr><th><div class='productivity icon' title='Productivity determines how quickly the hacker works'></div></th><td><div class='statbar productivity'>" + args.productivity + "</div></td></tr>")
.append("<tr><th><div class='teamwork icon' title='Teamwork determines how effectively the hacker works with others'></div></th><td><div class='statbar teamwork'>" + args.teamwork + "</div></td></tr>")
output.append(table);
return output;
}
</script>
<!-- channel messaging -->
<script >
var TOKEN = "{{ token }}";
var channel = {};
channel.disconnected = false;
var loadTimeout = null;
channel.init = function() {
try{
var channel_instance = new goog.appengine.Channel(TOKEN);
var socket = channel_instance.open();
socket.onopen = function(){channel.onConnect()};
socket.onmessage = function(msg){channel.onMessage(msg.data)};
socket.onerror = function(err) {console.log(err);};
socket.onclose = function(){channel.onDisconnect()};
}
catch(ex){console.log("SocketIO Error: "+ex); }
loadTimeout = setTimeout(function () {
$("#connection_failure").show();
}, 10000);
}
channel.onConnect = function() {
clearTimeout(loadTimeout);
console.log('Connected');
}
channel.onMessage = function(msg) {
var args = jQuery.parseJSON(msg);
if (args.success === "match found") {
window.location = "/hackathon";
}
}
channel.onDisconnect = function() {
console.log("Websocket disconnected, reconnecting...");
}
channel.quit = function(){
if (typeof sock !== 'undefined')
sock.close();
sock=null;
}
channel.init();
</script>
</body>
</html>