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