d0d619f1131cc18089c84ae6690f5ac0f8383799
[xonotic/xonstat.git] / xonstat / templates / player_info.mako
1 <%inherit file="base.mako"/>
2 <%namespace name="nav" file="nav.mako" />
3
4 <%block name="navigation">
5     ##### Disable the login button until a replacement is implemented.
6     ${nav.nav('players', False)}
7 </%block>
8
9 <%block name="css">
10   ${parent.css()}
11   <link href="/static/css/nv.d3.min.css" rel="stylesheet">
12   <style>
13     #damageChart, #accuracyChart {
14       height: 300px;
15     }
16   </style>
17 </%block>
18
19 <%block name="js">
20   ${parent.js()}
21   <script type="text/javascript" src="/static/js/vendor/d3.min.js"></script>
22   <script type="text/javascript" src="/static/js/vendor/nv.d3.min.js"></script>
23   <script type="text/javascript" src="/static/js/weaponCharts.min.js"></script>
24   ##### <script src="/static/js/weaponCharts.min.js"></script>
25   <script type="text/javascript">
26
27     // game type buttons
28     % for g in games_played:
29     $('#tab-${g.game_type_cd}').click(function() {
30       $.getJSON("${request.route_url('player_weaponstats_data_json', id=player.player_id, _query={'limit':20, 'game_type':g.game_type_cd})}", function(data) {
31         drawDamageChart("#damageChart", data);
32         drawAccuracyChart("#accuracyChart", data);
33       });
34     });
35     % endfor
36
37     // weapon accuracy and damage charts
38     $.getJSON("${request.route_url('player_weaponstats_data_json', id=player.player_id, _query={'limit':20})}", function(data) {
39     
40       if(data.games.length < 5) {
41         d3.select(".row #damageChart").remove();
42         d3.select(".row #accuracyChart").remove();
43       }
44       drawDamageChart("#damageChart", data);
45       drawAccuracyChart("#accuracyChart", data);
46     });
47   </script>
48 </%block>
49
50 <%block name="title">
51   Player Information
52 </%block>
53
54 <div class="row">
55   <div class="small-12 columns">
56     <h2> 
57       ${player.nick_html_colors()|n} 
58       % for medal in medals:
59         <img src="/static/medals/${medal.image}" alt="${medal.alt}" title="${medal.alt}" />
60       % endfor
61     </h2>
62
63     <h5>
64       <i><span class="abstime" data-epoch="${player.epoch()}" title="${player.create_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">Joined ${player.fuzzy_date()}</span> (player #${player.player_id})</i>
65       % if cake_day:
66         <img src="/static/images/icons/24x24/cake.png" title="Happy cake day!" />
67       % endif
68     </h5>
69   </div>
70 </div>
71
72 ##### TABS #####
73 <div class="row">
74   <div class="small-12 columns">
75     <ul class="tabs text-center" data-tab>
76       % for g in games_played:
77         <li class="tab-title
78           % if g.game_type_cd == 'overall':
79             active
80           % endif
81         ">
82           <a id="tab-${g.game_type_cd}" href="#tab-${g.game_type_cd}" title="${overall_stats[g.game_type_cd].game_type_descr}">
83             <span class="sprite sprite-${g.game_type_cd}"></span><br />
84             ${g.game_type_cd} <br />
85             <small>(${g.games})</small>
86           </a>
87         </li>
88       % endfor
89     </ul>
90   </div>
91 </div>
92
93 <div class="tabs-content">
94   % for g in games_played:
95     <div class="content
96       % if g.game_type_cd == 'overall':
97         active
98       % endif
99     " id="tab-${g.game_type_cd}">
100
101         ##### LEFT PANE #####
102         <div class="small-12 medium-6 columns">
103           <p>
104             % if g.game_type_cd in overall_stats:
105               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>
106             % else:
107             <small><br /></small>
108             % endif
109
110             Games Played: 
111             % if g.game_type_cd == 'overall':
112               <small><a href="${request.route_url("player_game_index", player_id=player.player_id)}" title="View recent games">
113             % else:
114               <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">
115             % endif
116             ${g.games}</a> <br /></small>
117
118             Playing Time: <small>${overall_stats[g.game_type_cd].total_playing_time} <br /></small>
119
120             % if g.game_type_cd in fav_maps:
121               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>
122             % else:
123               <small><br /></small>
124             % endif
125
126             % if g.game_type_cd == 'ctf':
127               % if overall_stats[g.game_type_cd].total_captures is not None:
128                 <small><a href="${request.route_url("player_captimes", player_id=player.player_id)}">Fastest flag captures...</a> <br /></small>
129               % else:
130                 <small><br /></small>
131               % endif
132             % else:
133               <small><br /></small>
134             % endif
135           </p>
136         </div>
137
138         ##### RIGHT PANE #####
139         <div class="small-12 medium-6 columns">
140           <p>
141             Win Percentage: <small>${round(g.win_pct,2)}% (${g.wins} wins, ${g.losses} losses) <br /></small>
142
143             % if g.game_type_cd in overall_stats:
144               % if overall_stats[g.game_type_cd].k_d_ratio is not None:
145                 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>
146               % endif
147             % else:
148               <small><br /></small>
149             % endif
150
151             % if g.game_type_cd in elos:
152               % if g.game_type_cd == 'overall':
153                 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>
154               % else:
155                 Elo: <small>${round(elos[g.game_type_cd].elo,2)} (${elos[g.game_type_cd].games} games) <br /></small>
156               % endif
157             % else:
158               <small><br /></small>
159             % endif
160
161             % if g.game_type_cd in ranks:
162               % if g.game_type_cd == 'overall':
163                 Best Rank: 
164                 <small>
165                   <a href="${request.route_url('rank_index', game_type_cd=ranks[g.game_type_cd].game_type_cd, _query={'page':(ranks[g.game_type_cd].rank-1)/20+1})}" title="Player rank page for this player">
166                     ${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank}
167                   </a>
168                   (${ranks[g.game_type_cd].game_type_cd}, percentile: ${round(ranks[g.game_type_cd].percentile,2)}) 
169                   <br />
170                 </small>
171               % else:
172                 Rank: 
173                 <small>
174                   <a href="${request.route_url('rank_index', game_type_cd=g.game_type_cd, _query={'page':(ranks[g.game_type_cd].rank-1)/20+1})}" title="Player rank page for this player">
175                     ${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank}
176                   </a>
177                   (percentile: ${round(ranks[g.game_type_cd].percentile,2)})
178                   <br />
179                 </small>
180               % endif
181             % else:
182               <small><br /></small>
183             % endif
184
185             % if g.game_type_cd == 'ctf':
186               % if overall_stats[g.game_type_cd].cap_ratio is not None:
187                 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>
188               % else:
189                 <small><br /></small>
190               % endif
191             % else:
192               <small><br /></small>
193             % endif
194           </p>
195         </div>
196     </div>
197   % endfor
198 </div>
199
200 ##### ACCURACY CHART ####
201 <div class="row" id="accuracyChartRow">
202   <div class="small-12 columns">
203     <h5>Weapon Accuracy</h5>
204     <noscript>
205       Sorry, but you've disabled JavaScript! It is required to draw the accuracy chart.
206     </noscript>
207     <div id="accuracyChart">
208       <svg id="accuracyChartSVG"></svg>
209     </div>
210   </div>
211 </div>
212
213 ##### DAMAGE CHART ####
214 <div class="row" id="damageChartRow">
215   <div class="small-12 columns">
216     <h5>Weapon Damage</h5>
217     <noscript>
218       Sorry, but you've disabled JavaScript! It is required to draw the damage chart.
219     </noscript>
220     <div id="damageChart">
221       <svg id="damageChartSVG"></svg>
222     </div>
223   </div> 
224 </div>
225
226 ##### RECENT GAMES (v2) ####
227 % if recent_games:
228   <div class="row">
229     <div class="small-12 columns">
230       <h5>Recent Games <a href="${request.route_url("player_game_index", player_id=player.player_id, page=1)}" title="Game index for ${player.stripped_nick}"><i class="fa fa-plus-circle"></i></a></h5>
231       <table class="table-hover table-condensed">
232         <thead>
233           <tr>
234             <th class="small-1 text-center"></th>
235             <th class="small-1">Type</th>
236             <th class="show-for-medium-up small-3">Server</th>
237             <th class="small-2">Map</th>
238             <th class="show-for-medium-up small-1">Result</th>
239             <th class="show-for-medium-up small-2">Played</th>
240             <th class="small-1">Elo</th>
241           </tr>
242         </thead>
243         <tbody>
244         % for rg in recent_games:
245           <tr>
246             <td class="text-center"><a class="tiny button" href="${request.route_url('game_info', id=rg.game_id)}" title="View detailed information about this game">view</a></td>
247             <td class="text-center"><span class="sprite sprite-${rg.game_type_cd}" alt="${rg.game_type_cd}" title="${rg.game_type_descr}"></span></td>
248             <td class="show-for-medium-up no-stretch"><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 class="no-stretch"><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 class="show-for-medium-up">
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 class="show-for-medium-up"><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="text-center">
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">+${round(rg.elo_delta,2)}</span>
271                   % elif round(rg.elo_delta,2) < 0:
272                     <span class="elodown">${round(rg.elo_delta,2)}</span>
273                   % else:
274                     <span class="eloneutral"><i class="fa fa-minus"></i></span>
275                   % endif
276                 % else:
277                   <span class="eloneutral"><i class="fa fa-minus"></i></span>
278                 % endif
279               </a>
280             </td>
281           </tr>
282         % endfor
283         </tbody>
284       </table>
285     </div>
286   </div>
287 % endif