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