]> de.git.xonotic.org Git - xonotic/xonstat.git/blob - xonstat/templates/player_info.mako
Fix player_info template for missing player.
[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="js">
10     % if player is not None:
11       <script src="/static/js/jquery-1.7.1.min.js"></script>
12       <script src="/static/js/jquery.flot.min.js"></script>
13       <script type="text/javascript">
14       $(function () {
15
16           function plot_acc_graph(data) {
17               var games = new Array();
18               var avgs = new Array();
19               var accs = new Array();
20
21               var i=0;
22               for(i=0; i < data.games; i++) {
23                   avgs[i] = [i, data.avg];
24                   accs[i] = [i, data.accs[i][1]];
25                   games[i] = [i, data.accs[i][0]];
26               }
27
28               $.plot(
29                   $("#acc-graph"), 
30                   [ { data: avgs }, { data: accs }, ],
31                   { yaxis: {ticks: 10, min: 0, max: 100 },
32               });
33           }
34
35           $.ajax({
36               url: '${request.route_url("player_accuracy", id=player.player_id)}',
37               method: 'GET',
38               dataType: 'json',
39               success: plot_acc_graph
40           });
41
42           $(".acc-weap").click(function () {
43               var dataurl = $(this).find('a').attr('href');
44
45               $('.weapon-active').removeClass('weapon-active');
46               $(this).addClass('weapon-active');
47
48               $.ajax({
49                   url: dataurl,
50                   method: 'GET',
51                   dataType: 'json',
52                   success: plot_acc_graph
53               });
54           });
55       })
56       </script>
57     % endif
58 </%block>
59
60 <%block name="title">
61 Player Information
62 </%block>
63
64
65 % if player is None:
66 <h2>This player is so good we couldn't find him!</h2>
67 <p>Seriously though, he probably doesn't exist...just a figment of your imagination. Carry on then!</p>
68
69 % else:
70 <div class="row">
71   <div class="span8">
72     <h2>${player.nick_html_colors()|n}</h2>
73     <p>
74        Member Since: <small>${player.create_dt.strftime('%m/%d/%Y at %I:%M %p')} </small><br />
75        Last Seen: <small>${recent_games[0][1].fuzzy_date()} </small><br />
76        Playing Time: <small>${total_stats['alivetime']} </small><br />
77        % if total_games > 0 and total_stats['wins'] is not None:
78        Win Percentage: <small>${round(float(total_stats['wins'])/total_games * 100, 2)}% (${total_stats['wins']} wins, ${total_games - total_stats['wins']} losses) </small><br />
79        % endif
80        % if total_stats['kills'] > 0 and total_stats['deaths'] > 0:
81        Kill Ratio: <small>${round(float(total_stats['kills'])/total_stats['deaths'], 3)} (${total_stats['kills']} kills, ${total_stats['deaths']} deaths) </small><br />
82        % endif
83        <% games_breakdown_str = ', '.join(["{0} {1}".format(ng, gt) for (gt, ng) in games_breakdown]) %>
84        Games Played: <small>${total_games} (${games_breakdown_str})</small><br />
85        % if elos_display is not None and len(elos_display) > 0:
86        Elo:
87           <small>${', '.join(elos_display)} </small>
88           <br />
89           %if '*' in ', '.join(elos_display):
90               <small><i>*preliminary Elo</i></small>
91           %endif
92       % endif
93     </p>
94   </div>
95 </div>
96
97
98 % if accs is not None:
99 <div class="row">
100   <div class="span10">
101     <h3>Accuracy</h3>
102     <div id="acc-graph" style="width:800px; height:200px;">
103     </div>
104
105     <div class="weapon-nav">
106       <ul>
107         % if 'nex' in recent_weapons:
108         <li>
109           <div class="acc-weap weapon-active">
110             <img src="${request.static_url("xonstat:static/images/nex.png")}" />
111             <p><small>Nex</small></p>
112             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'nex'})}" title="Show nex accuracy"></a>
113           </div>
114         </li>
115         % endif
116
117         % if 'rifle' in recent_weapons:
118         <li>
119           <div class="acc-weap">
120             <img src="${request.static_url("xonstat:static/images/rifle.png")}" />
121             <p><small>Rifle</small></p>
122             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'rifle'})}" title="Show rifle accuracy"></a>
123           </div>
124         </li>
125         % endif
126
127         % if 'minstanex' in recent_weapons:
128         <li>
129           <div class="acc-weap">
130             <img src="${request.static_url("xonstat:static/images/minstanex.png")}" />
131             <p><small>Minstanex</small></p>
132             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'minstanex'})}" title="Show minstanex accuracy"></a>
133           </div>
134         </li>
135         % endif
136
137         % if 'uzi' in recent_weapons:
138         <li>
139           <div class="acc-weap">
140             <img src="${request.static_url("xonstat:static/images/uzi.png")}" />
141             <p><small>Uzi</small></p>
142             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'uzi'})}" title="Show uzi accuracy"></a>
143           </div>
144         </li>
145         % endif
146
147         % if 'shotgun' in recent_weapons:
148         <li>
149           <div class="acc-weap">
150             <img src="${request.static_url("xonstat:static/images/shotgun.png")}" />
151             <p><small>Shotgun</small></p>
152             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'shotgun'})}" title="Show shotgun accuracy"></a>
153           </div>
154         </li>
155         % endif
156       </ul>
157     </div>
158
159   </div>
160 </div>
161 % endif
162
163
164 ##### RECENT GAMES (v2) ####
165 % if recent_games:
166 <div class="row">
167   <div class="span12">
168     <h3>Recent Games</h3>
169     <table class="table table-bordered table-condensed">
170       <thead>
171         <tr>
172            <th></th>
173            <th>Type</th>
174            <th>Server</th>
175            <th>Map</th>
176            <th>Result</th>
177            <th>Played</th>
178         </tr>
179       </thead>
180       <tbody>
181       % for (gamestat, game, server, map) in recent_games:
182         <tr>
183            <td><a class="btn btn-primary btn-small" href="${request.route_url('game_info', id=game.game_id)}" title="View detailed information about this game">view</a></td>
184            <td style="width:20px;"><img title="${game.game_type_cd}" src="/static/images/icons/24x24/${game.game_type_cd}.png" alt="${game.game_type_cd}" /></td>
185            <td>${server.name}</td>
186            <td>${map.name}</td>
187            <td>
188            % if gamestat.team != None:
189              % if gamestat.team == game.winner:
190              Win
191              % else:
192              Loss
193              % endif
194           % else:
195             % if gamestat.rank == 1:
196             Win
197             % else:
198             Loss (#${gamestat.rank})
199             % endif
200           % endif
201            </td>
202            <td>${game.fuzzy_date()}</td>
203         </tr>
204       % endfor
205       </tbody>
206     </table>
207     % if total_games > 10:
208     <a href="${request.route_url("player_game_index", player_id=player.player_id, page=1)}" title="Game index for ${player.nick}">More games played by ${player.nick_html_colors()|n}...</a>
209     % endif
210   </div>
211 </div>
212 % endif
213 % endif