]> de.git.xonotic.org Git - xonotic/xonstat.git/blob - xonstat/templates/player_info.mako
Merge branch 'master' into zykure/wip
[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>
197       ${player.nick_html_colors()|n}
198     </h2>
199     <h4>
200       <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>
201       % if cake_day:
202       <img src="/static/images/icons/24x24/cake.png" title="Happy cake day!" />
203       % endif
204     </h4>
205   </div>
206 </div>
207
208 <div class="row">
209   <div id="gbtabcontainer" class="tabbable tabs-below">
210     <div class="tab-content">
211       % for g in games_played:
212       % if not g.game_type_cd in ['cq']:
213       <div class="tab-pane fade in 
214         % if g.game_type_cd == 'overall':
215         active
216         % endif
217         " id="tab-${g.game_type_cd}">
218         <div class="span5">
219           <p>
220           % if g.game_type_cd in overall_stats:
221           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>
222           % else:
223           <small><br /></small>
224           % endif
225
226           Games Played: 
227           % if g.game_type_cd == 'overall':
228           <small><a href="${request.route_url("player_game_index", player_id=player.player_id)}" title="View recent games">
229           % else:
230           <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">
231           % endif
232           ${g.games}</a> <br /></small>
233
234           Playing Time: <small>${overall_stats[g.game_type_cd].total_playing_time} <br /></small>
235
236           % if g.game_type_cd in fav_maps:
237           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>
238           % else:
239           <small><br /></small>
240           % endif
241           
242           % if g.game_type_cd == 'ctf':
243           % if overall_stats[g.game_type_cd].total_captures is not None:
244           <small><a href="${request.route_url("player_captimes", id=player.player_id)}">Fastest flag captures...</a> <br /></small>
245           % else:
246           <small><br /></small>
247           % endif
248           % else:
249           <small><br /></small>
250           % endif
251           
252           </p>
253         </div>
254         <div class="span5">
255           <p>
256           Win Percentage: <small>${round(g.win_pct,2)}% (${g.wins} wins, ${g.losses} losses) <br /></small>
257
258           % if g.game_type_cd in overall_stats:
259           % if overall_stats[g.game_type_cd].k_d_ratio is not None:
260           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>
261           % endif
262           % else:
263           <small><br /></small>
264           % endif
265
266           % if g.game_type_cd in elos:
267           % if g.game_type_cd == 'overall':
268           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>
269           % else:
270           Elo: <small>${round(elos[g.game_type_cd].elo,2)} (${elos[g.game_type_cd].games} games) <br /></small>
271           % endif
272           % else:
273           <small><br /></small>
274           % endif
275
276           % if g.game_type_cd in ranks:
277           % if g.game_type_cd == 'overall':
278           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>
279           % else:
280           Rank: 
281           <small>
282             <a href="
283               % if ranks[g.game_type_cd].rank % 20 == 0:
284                 ${request.route_url('rank_index', game_type_cd=g.game_type_cd, _query={'page':ranks[g.game_type_cd].rank/20})}
285
286               % else:
287                 ${request.route_url('rank_index', game_type_cd=g.game_type_cd, _query={'page':ranks[g.game_type_cd].rank/20+1})}
288
289               % endif
290             " title="Player rank page for this player">
291             ${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank}</a>
292             (percentile: ${round(ranks[g.game_type_cd].percentile,2)})
293             <br />
294           </small>
295           % endif
296           % else:
297           <small><br /></small>
298           % endif
299
300           % if g.game_type_cd == 'ctf':
301           % if overall_stats[g.game_type_cd].cap_ratio is not None:
302           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>
303           % else:
304           <small><br /></small>
305           % endif
306           % else:
307           <small><br /></small>
308           % endif
309           </p>
310         </div>
311       </div>
312       % endif
313       % endfor
314     </div>
315   </div>
316 </div>
317 <div class="row">
318   <div class="span12">
319     <ul id="gbtab" class="nav nav-tabs">
320       % for g in games_played:
321       <li>
322       <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}">
323         <span class="sprite sprite-${g.game_type_cd}"> </span><br />
324         ${g.game_type_cd} <br />
325         <small>(${g.games})</small>
326       </a>
327       </li>
328       % endfor
329     </ul>
330   </div>
331 </div>
332
333
334 % 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:
335 <div class="row">
336   <div class="span12">
337     <h3>Accuracy</h3>
338     <div id="acc-graph" class="flot" style="width:95%; height:200px;">
339     </div>
340
341     <div class="weapon-nav accuracy-nav">
342       <ul>
343         % if 'nex' in recent_weapons:
344         <li>
345         <div class="acc-weap weapon-active">
346           <span class="sprite sprite-nex"></span>
347           <p><small>Nex</small></p>
348           <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'nex'})}" title="Show nex accuracy"></a>
349         </div>
350         </li>
351         % endif
352
353         % if 'rifle' in recent_weapons:
354         <li>
355         <div class="acc-weap">
356           <span class="sprite sprite-rifle"></span>
357           <p><small>Rifle</small></p>
358           <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'rifle'})}" title="Show rifle accuracy"></a>
359         </div>
360         </li>
361         % endif
362
363         % if 'minstanex' in recent_weapons:
364         <li>
365         <div class="acc-weap">
366           <span class="sprite sprite-minstanex"></span>
367           <p><small>Minstanex</small></p>
368           <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'minstanex'})}" title="Show minstanex accuracy"></a>
369         </div>
370         </li>
371         % endif
372
373         % if 'uzi' in recent_weapons:
374         <li>
375         <div class="acc-weap">
376           <span class="sprite sprite-uzi"></span>
377           <p><small>Uzi</small></p>
378           <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'uzi'})}" title="Show uzi accuracy"></a>
379         </div>
380         </li>
381         % endif
382
383         % if 'shotgun' in recent_weapons:
384         <li>
385         <div class="acc-weap">
386           <span class="sprite sprite-shotgun"></span>
387           <p><small>Shotgun</small></p>
388           <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'shotgun'})}" title="Show shotgun accuracy"></a>
389         </div>
390         </li>
391         % endif
392       </ul>
393     </div>
394
395   </div>
396 </div>
397 % endif
398
399
400 % 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:
401 <div class="row">
402   <div class="span12">
403     <h3>Damage Efficiency</h3>
404     <div id="dmg-graph" class="flot" style="width:95%; height:200px;">
405     </div>
406
407     <div class="weapon-nav damage-nav">
408       <ul>
409         % if 'rocketlauncher' in recent_weapons:
410         <li>
411         <div class="dmg-weap weapon-active">
412           <span class="sprite sprite-rocketlauncher"></span>
413           <p><small>Rocket</small></p>
414           <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'rocketlauncher'})}" title="Show rocket launcher efficiency"></a>
415         </div>
416         </li>
417         % endif
418
419         % if 'grenadelauncher' in recent_weapons:
420         <li>
421         <div class="dmg-weap">
422           <span class="sprite sprite-grenadelauncher"></span>
423           <p><small>Mortar</small></p>
424           <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'grenadelauncher'})}" title="Show mortar damage efficiency"></a>
425         </div>
426         </li>
427         % endif
428
429         % if 'electro' in recent_weapons:
430         <li>
431         <div class="dmg-weap">
432           <span class="sprite sprite-electro"></span>
433           <p><small>Electro</small></p>
434           <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'electro'})}" title="Show electro damage efficiency"></a>
435         </div>
436         </li>
437         % endif
438
439         % if 'crylink' in recent_weapons:
440         <li>
441         <div class="dmg-weap">
442           <span class="sprite sprite-crylink"></span>
443           <p><small>Crylink</small></p>
444           <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'crylink'})}" title="Show crylink damage efficiency"></a>
445         </div>
446         </li>
447         % endif
448
449         % if 'hagar' in recent_weapons:
450         <li>
451         <div class="dmg-weap">
452           <span class="sprite sprite-hagar"></span>
453           <p><small>Hagar</small></p>
454           <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'hagar'})}" title="Show hagar damage efficiency"></a>
455         </div>
456         </li>
457         % endif
458
459         % if 'laser' in recent_weapons:
460         <li>
461         <div class="dmg-weap">
462           <span class="sprite sprite-laser"></span>
463           <p><small>Laser</small></p>
464           <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'laser'})}" title="Show laser damage efficiency"></a>
465         </div>
466         </li>
467         % endif
468
469       </ul>
470     </div>
471
472   </div>
473 </div>
474 % endif
475
476
477 ##### RECENT GAMES (v2) ####
478 % if recent_games:
479 <div class="row">
480   <div class="span12">
481     <h3>Recent Games</h3>
482     <table class="table table-hover table-condensed">
483       <thead>
484         <tr>
485           <th></th>
486           <th>Type</th>
487           <th>Server</th>
488           <th>Map</th>
489           <th>Result</th>
490           <th>Played</th>
491           <th>Elo</th>
492         </tr>
493       </thead>
494       <tbody>
495       % for rg in recent_games:
496       <tr>
497         <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>
498         <td class="tdcenter"><span class="sprite sprite-${rg.game_type_cd}" alt="${rg.game_type_cd}" title="${rg.game_type_descr}"></span></td>
499         <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>
500         <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>
501         <td>
502           % if rg.team != None:
503           % if rg.team == rg.winner:
504           Win
505           % else:
506           Loss
507           % endif
508           % else:
509           % if rg.rank == 1:
510           Win
511           % else:
512           Loss (#${rg.rank})
513           % endif
514           % endif
515         </td>
516         <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>
517         <td class="tdcenter">
518           <a href="${request.route_url('game_info', id=rg.game_id, _query={'show_elo':1})}" title="View detailed information about this game">
519             % if rg.elo_delta is not None:
520             % if round(rg.elo_delta,2) > 0:
521             <span class="eloup" title="Elo went up by ${round(rg.elo_delta,2)}"><i class="glyphicon glyphicon-arrow-up"></i></span>
522             % elif round(rg.elo_delta,2) < 0:
523             <span class="elodown" title="Elo went down by ${round(-rg.elo_delta,2)}"><i class="glyphicon glyphicon-arrow-down"></i></span>
524             % else:
525             <span class="eloneutral" title="Elo did not change"><i class="glyphicon glyphicon-minus"></i></span>
526             % endif
527             % else:
528             <span class="eloneutral" title="Elo did not change"><i class="glyphicon glyphicon-minus"></i></span>
529             % endif
530           </a>
531         </td>
532       </tr>
533       % endfor
534       </tbody>
535     </table>
536     % if total_games > 10:
537     <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>
538     % endif
539   </div>
540 </div>
541 % endif
542 % endif