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