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