]> de.git.xonotic.org Git - xonotic/xonstat.git/blob - xonstat/templates/player_info.mako
Working charts on the player_info pages. Yeah!
[xonotic/xonstat.git] / xonstat / templates / player_info.mako
1 <%inherit file="base.mako"/>
2 <%namespace name="nav" file="nav.mako" />
3 <%namespace file="accuracy.mako" import="accuracy" />
4 <%namespace file="accuracy_graph.mako" import="accuracy_graph" />
5 <%namespace file="damage_graph.mako" import="damage_graph" />
6
7 <%block name="navigation">
8 ${nav.nav('players')}
9 </%block>
10
11 <%block name="css">
12 ${parent.css()}
13 <link href="/static/css/sprites.css" rel="stylesheet">
14 <link href="/static/css/nv.d3.css" rel="stylesheet" type="text/css">
15 <style>
16 #damageChartSVG, #accuracyChartSVG {
17   height: 300px;
18 }
19 </style>
20 </%block>
21
22 <%block name="js">
23 ${parent.js()}
24 <script src="/static/js/d3.v3.min.js"></script>
25 <script src="/static/js/nv.d3.min.js"></script>
26 <script src="/static/js/weaponCharts.js"></script>
27 <script type="text/javascript">
28 // tabs
29 $(function () {
30   $('#gbtab li').click(function(e) {
31     e.preventDefault();
32     $(this).tab('show');
33   })
34
35   $('#gbtab a:first').tab('show');
36 })
37
38 // weapon accuracy and damage charts
39 d3.json("${request.route_url('player_weaponstats_data_json', id=player.player_id)}", function(err, data) {
40   drawDamageChart(data);
41   drawAccuracyChart(data);
42 });
43
44 % for g in games_played:
45 d3.select('.tab-${g.game_type_cd}').on("click", function() {
46   // have to remove the chart each time
47   d3.select('#damageChartSVG .nvd3').remove();
48   d3.select('#accuracyChartSVG .nvd3').remove();
49   d3.json("${request.route_url('player_weaponstats_data_json', id=player.player_id, _query={'limit':20, 'game_type':g.game_type_cd})}", function(err, data) {
50     drawDamageChart(data);
51     drawAccuracyChart(data);
52   });
53 });
54 % endfor
55
56 </script>
57 </%block>
58
59 <%block name="title">
60 Player Information
61 </%block>
62
63 <div class="row">
64   <div class="span12">
65     <h2>
66       ${player.nick_html_colors()|n}
67     </h2>
68     <h4>
69       <i><span class="abstime" data-epoch="${player.epoch()}" title="${player.create_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">Joined ${player.joined_pretty_date()}</span> (player #${player.player_id})</i>
70       % if cake_day:
71       <img src="/static/images/icons/24x24/cake.png" title="Happy cake day!" />
72       % endif
73     </h4>
74   </div>
75 </div>
76
77 <div class="row">
78   <div id="gbtabcontainer" class="tabbable tabs-below">
79     <div class="tab-content">
80       % for g in games_played:
81       % if not g.game_type_cd in ['cq']:
82       <div class="tab-pane fade in 
83         % if g.game_type_cd == 'overall':
84         active
85         % endif
86         " id="tab-${g.game_type_cd}">
87         <div class="span5">
88           <p>
89           % if g.game_type_cd in overall_stats:
90           Last Played: <small><span class="abstime" data-epoch="${overall_stats[g.game_type_cd].last_played_epoch}" title="${overall_stats[g.game_type_cd].last_played.strftime('%a, %d %b %Y %H:%M:%S UTC')}"> ${overall_stats[g.game_type_cd].last_played_fuzzy} </span> <br /></small>
91           % else:
92           <small><br /></small>
93           % endif
94
95           Games Played: 
96           % if g.game_type_cd == 'overall':
97           <small><a href="${request.route_url("player_game_index", player_id=player.player_id)}" title="View recent games">
98           % else:
99           <small><a href="${request.route_url("player_game_index", player_id=player.player_id, _query={'type':g.game_type_cd})}" title="View recent ${overall_stats[g.game_type_cd].game_type_descr} games">
100           % endif
101           ${g.games}</a> <br /></small>
102
103           Playing Time: <small>${overall_stats[g.game_type_cd].total_playing_time} <br /></small>
104
105           % if g.game_type_cd in fav_maps:
106           Favorite Map: <small><a href="${request.route_url("map_info", id=fav_maps[g.game_type_cd].map_id)}" title="Go to the detail page for this map">${fav_maps[g.game_type_cd].map_name}</a> <br /></small>
107           % else:
108           <small><br /></small>
109           % endif
110
111           % if g.game_type_cd == 'ctf':
112           % if overall_stats[g.game_type_cd].total_captures is not None:
113           <small><a href="${request.route_url("player_captimes", id=player.player_id)}">Fastest flag captures...</a> <br /></small>
114           % else:
115           <small><br /></small>
116           % endif
117           % else:
118           <small><br /></small>
119           % endif
120
121           </p>
122         </div>
123         <div class="span5">
124           <p>
125           Win Percentage: <small>${round(g.win_pct,2)}% (${g.wins} wins, ${g.losses} losses) <br /></small>
126
127           % if g.game_type_cd in overall_stats:
128           % if overall_stats[g.game_type_cd].k_d_ratio is not None:
129           Kill Ratio: <small>${round(overall_stats[g.game_type_cd].k_d_ratio,2)} (${overall_stats[g.game_type_cd].total_kills} kills, ${overall_stats[g.game_type_cd].total_deaths} deaths) <br /></small>
130           % endif
131           % else:
132           <small><br /></small>
133           % endif
134
135           % if g.game_type_cd in elos:
136           % if g.game_type_cd == 'overall':
137           Best Elo: <small>${round(elos[g.game_type_cd].elo,2)} (${elos[g.game_type_cd].game_type_cd}, ${elos[g.game_type_cd].games} games) <br /></small>
138           % else:
139           Elo: <small>${round(elos[g.game_type_cd].elo,2)} (${elos[g.game_type_cd].games} games) <br /></small>
140           % endif
141           % else:
142           <small><br /></small>
143           % endif
144
145           % if g.game_type_cd in ranks:
146           % if g.game_type_cd == 'overall':
147           Best Rank: <small>${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank} (${ranks[g.game_type_cd].game_type_cd}, percentile: ${round(ranks[g.game_type_cd].percentile,2)}) <br /></small>
148           % else:
149           Rank: 
150           <small>
151             <a href="
152               % if ranks[g.game_type_cd].rank % 20 == 0:
153                 ${request.route_url('rank_index', game_type_cd=g.game_type_cd, _query={'page':ranks[g.game_type_cd].rank/20})}
154
155               % else:
156                 ${request.route_url('rank_index', game_type_cd=g.game_type_cd, _query={'page':ranks[g.game_type_cd].rank/20+1})}
157
158               % endif
159             " title="Player rank page for this player">
160             ${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank}</a>
161             (percentile: ${round(ranks[g.game_type_cd].percentile,2)})
162             <br />
163           </small>
164           % endif
165           % else:
166           <small><br /></small>
167           % endif
168
169           % if g.game_type_cd == 'ctf':
170           % if overall_stats[g.game_type_cd].cap_ratio is not None:
171           Cap Ratio: <small>${round(overall_stats[g.game_type_cd].cap_ratio,2)} (${overall_stats[g.game_type_cd].total_captures} captures, ${overall_stats[g.game_type_cd].total_pickups} pickups) <br /></small>
172           % else:
173           <small><br /></small>
174           % endif
175           % else:
176           <small><br /></small>
177           % endif
178           </p>
179         </div>
180       </div>
181       % endif
182       % endfor
183     </div>
184   </div>
185 </div>
186 <div class="row">
187   <div class="span12">
188     <ul id="gbtab" class="nav nav-tabs">
189       % for g in games_played:
190       <li class="tab-${g.game_type_cd}">
191       <a href="#tab-${g.game_type_cd}" data-toggle="tab" alt="${g.game_type_cd}" title="${overall_stats[g.game_type_cd].game_type_descr}">
192         <span class="sprite sprite-${g.game_type_cd}"> </span><br />
193         ${g.game_type_cd} <br />
194         <small>(${g.games})</small>
195       </a>
196       </li>
197       % endfor
198     </ul>
199   </div>
200 </div>
201
202
203 ##### Weapon Accuracy Chart ####
204 <div class="row">
205   <div class="span12">
206     <h3>Weapon Accuracy</h3>
207     <div id="accuracyChart">
208       <svg id="accuracyChartSVG"></svg>
209     </div>
210   </div> <!-- end span12 -->
211 </div> <!-- end row -->
212
213
214 ##### Weapon Damage Chart ####
215 <div class="row">
216   <div class="span12">
217     <h3>Weapon Damage</h3>
218     <div id="damageChart">
219       <svg id="damageChartSVG"></svg>
220     </div>
221   </div> <!-- end span12 -->
222 </div> <!-- end row -->
223
224
225
226 ##### RECENT GAMES (v2) ####
227 % if recent_games:
228 <div class="row">
229   <div class="span12">
230     <h3>Recent Games</h3>
231     <table class="table table-hover table-condensed">
232       <thead>
233         <tr>
234           <th></th>
235           <th>Type</th>
236           <th>Server</th>
237           <th>Map</th>
238           <th>Result</th>
239           <th>Played</th>
240           <th>Elo</th>
241         </tr>
242       </thead>
243       <tbody>
244       % for rg in recent_games:
245       <tr>
246         <td class="tdcenter"><a class="btn btn-primary btn-small" href="${request.route_url('game_info', id=rg.game_id)}" title="View detailed information about this game">view</a></td>
247         <td class="tdcenter"><span class="sprite sprite-${rg.game_type_cd}" alt="${rg.game_type_cd}" title="${rg.game_type_descr}"></span></td>
248         <td><a href="${request.route_url('server_info', id=rg.server_id)}" title="Go to the detail page for this server">${rg.server_name}</a></td>
249         <td><a href="${request.route_url('map_info', id=rg.map_id)}" title="Go to the detail page for this map">${rg.map_name}</a></td>
250         <td>
251           % if rg.team != None:
252           % if rg.team == rg.winner:
253           Win
254           % else:
255           Loss
256           % endif
257           % else:
258           % if rg.rank == 1:
259           Win
260           % else:
261           Loss (#${rg.rank})
262           % endif
263           % endif
264         </td>
265         <td><span class="abstime" data-epoch="${rg.epoch}" title="${rg.start_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${rg.fuzzy_date}</span></td>
266         <td class="tdcenter">
267           <a href="${request.route_url('game_info', id=rg.game_id, _query={'show_elo':1})}" title="View detailed information about this game">
268             % if rg.elo_delta is not None:
269             % if round(rg.elo_delta,2) > 0:
270             <span class="eloup" title="Elo went up by ${round(rg.elo_delta,2)}"><i class="glyphicon glyphicon-arrow-up"></i></span>
271             % elif round(rg.elo_delta,2) < 0:
272             <span class="elodown" title="Elo went down by ${round(-rg.elo_delta,2)}"><i class="glyphicon glyphicon-arrow-down"></i></span>
273             % else:
274             <span class="eloneutral" title="Elo did not change"><i class="glyphicon glyphicon-minus"></i></span>
275             % endif
276             % else:
277             <span class="eloneutral" title="Elo did not change"><i class="glyphicon glyphicon-minus"></i></span>
278             % endif
279           </a>
280         </td>
281       </tr>
282       % endfor
283       </tbody>
284     </table>
285     % if total_games > 10:
286     <p><a href="${request.route_url("player_game_index", player_id=player.player_id, page=1)}" title="Game index for ${player.stripped_nick}">More...</a></p>
287     % endif
288   </div>
289 </div>
290 % endif