]> de.git.xonotic.org Git - xonotic/xonstat.git/blob - xonstat/templates/player_info.mako
Port over all older styles (tables in particular).
[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
5 <%block name="navigation">
6 ${nav.nav('players')}
7 </%block>
8
9 <%block name="css">
10 ${parent.css()}
11 <link href="/static/css/sprites.css" rel="stylesheet">
12 </%block>
13
14 <%block name="js">
15 ${parent.js()}
16 % if player is not None:
17 <script src="/static/js/jquery.flot.min.js"></script>
18 <script type="text/javascript">
19 $(function () {
20   $('#gbtab li').click(function(e) {
21     e.preventDefault();
22     $(this).tab('show');
23   })
24
25   $('#gbtab a:first').tab('show');
26 })
27 </script>
28
29 <script type="text/javascript">
30 $(function () {
31     // plot the accuracy graph
32     function plot_acc_graph(data) {
33     var games = new Array();
34     var avgs = new Array();
35     var accs = new Array();
36
37   var i=0;
38   for(i=0; i < data.games; i++) {
39     avgs[i] = [i, data.avg];
40     accs[i] = [i, data.accs[i][1]];
41     game_link = '/game/' + data.accs[i][0];
42     j = data.games - i;
43     games[i] = [i, '<a href="' + game_link + '">' + j + '</a>'];
44   }
45
46   $.plot(
47     $("#acc-graph"), 
48     [ { label: 'average', data: avgs, hoverable: true, clickable: false }, 
49       { label: 'accuracy', data: accs, lines: {show:true}, points: {show:false}, hoverable: true, clickable: true }, ],
50       { yaxis: {ticks: 10, min: 0, max: 100 },
51         xaxis: {ticks: games},
52         grid: { hoverable: true, clickable: true },
53       });
54 }
55
56 // plot the damage graph
57 function plot_dmg_graph(data) {
58   var games = new Array();
59   var avgs = new Array();
60   var dmgs = new Array();
61
62 var i=0;
63 for(i=0; i < data.games; i++) {
64   avgs[i] = [i, data.avg];
65   dmgs[i] = [i, data.dmgs[i][1]];
66   game_link = '/game/' + data.dmgs[i][0];
67   j = data.games - i;
68   games[i] = [i, '<a href="' + game_link + '">' + j + '</a>'];
69 }
70
71 $.plot(
72   $("#dmg-graph"), 
73   [ { label: 'average', data: avgs, hoverable: true, clickable: false }, 
74     { label: 'efficiency', data: dmgs, lines: {show:true}, points: {show:false}, hoverable: true, clickable: true }, ],
75     { yaxis: {ticks: 10, min: 0 },
76       xaxis: {ticks: games},
77       grid: { hoverable: true, clickable: true },
78     });
79           }
80
81           function showTooltip(x, y, contents) {
82             $('<div id="tooltip">' + contents + '</div>').css( {
83               position: 'absolute',
84               display: 'none',
85               top: y - 35,
86               left: x + 10,
87               border: '1px solid #fdd',
88               padding: '2px',
89               'background-color': '#333333',
90               opacity: 0.80
91             }).appendTo("body").fadeIn(200);
92           }
93
94           var previousPoint = null;
95           var previousLabel = null;
96           $('#acc-graph').bind("plothover", function (event, pos, item) {
97             if (item) {
98               if ((previousLabel != item.series.label) || (previousPoint != item.dataIndex)) {
99                 previousLabel = item.series.label;
100                 previousPoint = item.dataIndex;
101
102                 $("#tooltip").remove();
103                 var x = item.datapoint[0].toFixed(2),
104                 y = item.datapoint[1].toFixed(2);
105
106                 showTooltip(item.pageX, item.pageY, y + "%");
107               }
108             }
109             else {
110               $("#tooltip").remove();
111               previousPoint = null;
112               previousLabel = null;
113             }
114           });
115
116           $('#dmg-graph').bind("plothover", function (event, pos, item) {
117             if (item) {
118               if ((previousLabel != item.series.label) || (previousPoint != item.dataIndex)) {
119                 previousPoint = item.dataIndex;
120                 previousLabel = item.series.label;
121
122                 $("#tooltip").remove();
123                 var x = item.datapoint[0].toFixed(2),
124                 y = item.datapoint[1].toFixed(2);
125
126                 showTooltip(item.pageX, item.pageY, y);
127               }
128             }
129             else {
130               $("#tooltip").remove();
131               previousPoint = null;
132               previousLabel = null;
133             }
134           });
135
136 // bind click events to the weapon images
137 $(".acc-weap").click(function () {
138     var dataurl = $(this).find('a').attr('href');
139
140           $('.accuracy-nav').find('.weapon-active').removeClass('weapon-active');
141           $(this).addClass('weapon-active');
142
143           $.ajax({
144             url: dataurl,
145             method: 'GET',
146             dataType: 'json',
147             success: plot_acc_graph
148           });
149 });
150
151 $(".dmg-weap").click(function () {
152   var dataurl = $(this).find('a').attr('href');
153
154   $('.damage-nav').find('.weapon-active').removeClass('weapon-active');
155   $(this).addClass('weapon-active');
156
157   $.ajax({
158     url: dataurl,
159     method: 'GET',
160     dataType: 'json',
161     success: plot_dmg_graph
162   });
163 });
164
165 // populate the graphs with the default weapons
166 $.ajax({
167 url: '${request.route_url("player_accuracy", id=player.player_id)}',
168 method: 'GET',
169 dataType: 'json',
170 success: plot_acc_graph
171 });
172
173 $.ajax({
174   url: '${request.route_url("player_damage", id=player.player_id)}',
175   method: 'GET',
176   dataType: 'json',
177   success: plot_dmg_graph
178 });
179 })
180 </script>
181 % endif
182 </%block>
183
184 <%block name="title">
185 Player Information
186 </%block>
187
188
189 % if player is None:
190 <h2>This player is so good we couldn't find him!</h2>
191 <p>Seriously though, he probably doesn't exist...just a figment of your imagination. Carry on then!</p>
192
193 % else:
194 <div class="row">
195   <div class="span12">
196     <h2>${player.nick_html_colors()|n}</h2>
197   </div>
198 </div>
199
200 <div class="row">
201   <div id="gbtabcontainer" class="tabbable tabs-below">
202     <div class="tab-content">
203       % for g in games_played:
204       <div class="tab-pane fade in 
205         % if g.game_type_cd == 'overall':
206         active
207         % endif
208         " id="tab-${g.game_type_cd}">
209         <div class="span5">
210           <p>
211           % if g.game_type_cd in overall_stats:
212           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>
213           % endif
214
215           Games Played: <small>${g.games} <br /></small>
216
217           Playing Time: <small>${overall_stats[g.game_type_cd].total_playing_time} <br /></small>
218
219           % if g.game_type_cd in fav_maps:
220           Favorite Map: <small>${fav_maps[g.game_type_cd].map_name} <br /></small>
221           % endif
222           </p>
223         </div>
224         <div class="span5">
225           <p>
226           Win Percentage: <small>${round(g.win_pct,2)}% (${g.wins} wins, ${g.losses} losses) <br /></small>
227
228           % if g.game_type_cd in overall_stats:
229           % if overall_stats[g.game_type_cd].k_d_ratio is not None:
230           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>
231           % endif
232           % endif
233
234           % if g.game_type_cd in elos:
235           % if g.game_type_cd == 'overall':
236           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>
237           % else:
238           Elo: <small>${round(elos[g.game_type_cd].elo,2)} (${elos[g.game_type_cd].games} games) <br /></small>
239           % endif
240           % endif
241
242           % if g.game_type_cd in ranks:
243           % if g.game_type_cd == 'overall':
244           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>
245
246           % else:
247           Rank: <small>${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank} (percentile: ${round(ranks[g.game_type_cd].percentile,2)})<br /></small>
248           % endif
249           % endif
250
251           % if g.game_type_cd == 'ctf':
252           % if  overall_stats[g.game_type_cd].cap_ratio is not None:
253           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>
254           % endif
255           % endif
256           </p>
257         </div>
258       </div>
259       % endfor
260     </div>
261   </div>
262 </div>
263 <div class="row">
264   <div class="span12">
265     <ul id="gbtab" class="nav nav-tabs">
266       % for g in games_played:
267       <li>
268       <a href="#tab-${g.game_type_cd}" data-toggle="tab">
269         <span class="sprite sprite-${g.game_type_cd}"> </span><br />
270         ${g.game_type_cd} <br />
271         <small>(${g.games})</small>
272       </a>
273       </li>
274       % endfor
275     </ul>
276   </div>
277 </div>
278
279
280 % if 'nex' in recent_weapons or 'rifle' in recent_weapons or 'minstanex' in recent_weapons or 'uzi' in recent_weapons or 'shotgun' in recent_weapons:
281 <div class="row">
282   <div class="span10">
283     <h3>Accuracy</h3>
284     <div id="acc-graph" class="flot" style="width:900px; height:200px;">
285     </div>
286
287     <div class="weapon-nav accuracy-nav">
288       <ul>
289         % if 'nex' in recent_weapons:
290         <li>
291         <div class="acc-weap weapon-active">
292           <span class="sprite sprite-nex"></span>
293           <p><small>Nex</small></p>
294           <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'nex'})}" title="Show nex accuracy"></a>
295         </div>
296         </li>
297         % endif
298
299         % if 'rifle' in recent_weapons:
300         <li>
301         <div class="acc-weap">
302           <span class="sprite sprite-rifle"></span>
303           <p><small>Rifle</small></p>
304           <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'rifle'})}" title="Show rifle accuracy"></a>
305         </div>
306         </li>
307         % endif
308
309         % if 'minstanex' in recent_weapons:
310         <li>
311         <div class="acc-weap">
312           <span class="sprite sprite-minstanex"></span>
313           <p><small>Minstanex</small></p>
314           <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'minstanex'})}" title="Show minstanex accuracy"></a>
315         </div>
316         </li>
317         % endif
318
319         % if 'uzi' in recent_weapons:
320         <li>
321         <div class="acc-weap">
322           <span class="sprite sprite-uzi"></span>
323           <p><small>Uzi</small></p>
324           <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'uzi'})}" title="Show uzi accuracy"></a>
325         </div>
326         </li>
327         % endif
328
329         % if 'shotgun' in recent_weapons:
330         <li>
331         <div class="acc-weap">
332           <span class="sprite sprite-shotgun"></span>
333           <p><small>Shotgun</small></p>
334           <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'shotgun'})}" title="Show shotgun accuracy"></a>
335         </div>
336         </li>
337         % endif
338       </ul>
339     </div>
340
341   </div>
342 </div>
343 % endif
344
345
346 % if 'rocketlauncher' in recent_weapons or 'grenadelauncher' in recent_weapons or 'electro' in recent_weapons or 'crylink' in recent_weapons or 'laser' in recent_weapons:
347 <div class="row">
348   <div class="span10">
349     <h3>Damage Efficiency</h3>
350     <div id="dmg-graph" class="flot" style="width:900px; height:200px;">
351     </div>
352
353     <div class="weapon-nav damage-nav">
354       <ul>
355         % if 'rocketlauncher' in recent_weapons:
356         <li>
357         <div class="dmg-weap weapon-active">
358           <span class="sprite sprite-rocketlauncher"></span>
359           <p><small>Rocket</small></p>
360           <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'rocketlauncher'})}" title="Show rocket launcher efficiency"></a>
361         </div>
362         </li>
363         % endif
364
365         % if 'grenadelauncher' in recent_weapons:
366         <li>
367         <div class="dmg-weap">
368           <span class="sprite sprite-grenadelauncher"></span>
369           <p><small>Mortar</small></p>
370           <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'grenadelauncher'})}" title="Show mortar damage efficiency"></a>
371         </div>
372         </li>
373         % endif
374
375         % if 'electro' in recent_weapons:
376         <li>
377         <div class="dmg-weap">
378           <span class="sprite sprite-electro"></span>
379           <p><small>Electro</small></p>
380           <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'electro'})}" title="Show electro damage efficiency"></a>
381         </div>
382         </li>
383         % endif
384
385         % if 'crylink' in recent_weapons:
386         <li>
387         <div class="dmg-weap">
388           <span class="sprite sprite-crylink"></span>
389           <p><small>Crylink</small></p>
390           <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'crylink'})}" title="Show crylink damage efficiency"></a>
391         </div>
392         </li>
393         % endif
394
395         % if 'hagar' in recent_weapons:
396         <li>
397         <div class="dmg-weap">
398           <span class="sprite sprite-hagar"></span>
399           <p><small>Hagar</small></p>
400           <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'hagar'})}" title="Show hagar damage efficiency"></a>
401         </div>
402         </li>
403         % endif
404
405         % if 'laser' in recent_weapons:
406         <li>
407         <div class="dmg-weap">
408           <span class="sprite sprite-laser"></span>
409           <p><small>Laser</small></p>
410           <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'laser'})}" title="Show laser damage efficiency"></a>
411         </div>
412         </li>
413         % endif
414
415       </ul>
416     </div>
417
418   </div>
419 </div>
420 % endif
421
422
423 ##### RECENT GAMES (v2) ####
424 % if recent_games:
425 <div class="row">
426   <div class="span12">
427     <h3>Recent Games</h3>
428     <table class="table table-hover table-condensed">
429       <thead>
430         <tr>
431           <th></th>
432           <th>Type</th>
433           <th>Server</th>
434           <th>Map</th>
435           <th>Result</th>
436           <th>Played</th>
437           <th>Elo</th>
438         </tr>
439       </thead>
440       <tbody>
441       % for rg in recent_games:
442       <tr>
443         <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>
444         <td class="tdcenter"><span class="sprite sprite-${rg.game_type_cd}" alt="${rg.game_type_cd}" title="${rg.game_type_descr}"></span></td>
445         <td>${rg.server_name}</td>
446         <td>${rg.map_name}</td>
447         <td>
448           % if rg.team != None:
449           % if rg.team == rg.winner:
450           Win
451           % else:
452           Loss
453           % endif
454           % else:
455           % if rg.rank == 1:
456           Win
457           % else:
458           Loss (#${rg.rank})
459           % endif
460           % endif
461         </td>
462         <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>
463         <td class="tdcenter">
464           <a href="${request.route_url('game_info', id=rg.game_id, _query={'show_elo':1})}" title="View detailed information about this game">
465             % if rg.elo_delta is not None:
466             % if round(rg.elo_delta,2) > 0:
467             <span title="Elo went up by ${round(rg.elo_delta,2)}"><i class="icon-arrow-up icon-white"></i></span>
468             % elif round(rg.elo_delta,2) < 0:
469             <span title="Elo went down by ${round(-rg.elo_delta,2)}"><i class="icon-arrow-down icon-white"></i></span>
470             % else:
471             <span title="Elo did not change"><i class="icon-minus icon-white"></i></span>
472             % endif
473             % else:
474             <span title="Elo did not change"><i class="icon-minus icon-white"></i></span>
475             % endif
476           </a>
477         </td>
478       </tr>
479       % endfor
480       </tbody>
481     </table>
482     % if total_games > 10:
483     <p><a href="${request.route_url("player_game_index", player_id=player.player_id, page=1)}" title="Game index for ${player.nick}">More...</a></p>
484     % endif
485   </div>
486 </div>
487 % endif
488 % endif