]> de.git.xonotic.org Git - xonotic/xonstat.git/blob - xonstat/templates/player_info.mako
clean dangling commit on actually merged branch
[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                   game_link = '/game/' + data.accs[i][0];
26                   j = 20 - i;
27                   games[i] = [i, '<a href="' + game_link + '">' + j + '</a>'];
28               }
29
30               $.plot(
31                   $("#acc-graph"), 
32                   [ { label: 'average', data: avgs, hoverable: false, clickable: false }, 
33                     { label: 'accuracy', data: accs, lines: {show:true}, points: {show:true}, hoverable: true, clickable: true }, ],
34                   { yaxis: {ticks: 10, min: 0, max: 100 },
35                     xaxis: {ticks: games},
36                     grid: { hoverable: true, clickable: true },
37               });
38           }
39
40           function showTooltip(x, y, contents) {
41             $('<div id="tooltip">' + contents + '</div>').css( {
42                 position: 'absolute',
43                 display: 'none',
44                 top: y - 35,
45                 left: x + 10,
46                 border: '1px solid #fdd',
47                 padding: '2px',
48                 'background-color': '#333333',
49                 opacity: 0.80
50             }).appendTo("body").fadeIn(200);
51           }
52
53           var previousPoint = null;
54           $('#acc-graph').bind("plothover", function (event, pos, item) {
55               if (item) {
56                   if (previousPoint != item.dataIndex) {
57                     previousPoint = item.dataIndex;
58                     
59                     $("#tooltip").remove();
60                     var x = item.datapoint[0].toFixed(2),
61                         y = item.datapoint[1].toFixed(2);
62                     
63                     showTooltip(item.pageX, item.pageY, y + "%");
64                   }
65               }
66               else {
67                   $("#tooltip").remove();
68                   previousPoint = null;
69               }
70           });
71
72           $.ajax({
73               url: '${request.route_url("player_accuracy", id=player.player_id)}',
74               method: 'GET',
75               dataType: 'json',
76               success: plot_acc_graph
77           });
78
79           $(".acc-weap").click(function () {
80               var dataurl = $(this).find('a').attr('href');
81
82               $('.weapon-active').removeClass('weapon-active');
83               $(this).addClass('weapon-active');
84
85               $.ajax({
86                   url: dataurl,
87                   method: 'GET',
88                   dataType: 'json',
89                   success: plot_acc_graph
90               });
91           });
92       })
93       </script>
94     % endif
95 </%block>
96
97 <%block name="title">
98 Player Information
99 </%block>
100
101
102 % if player is None:
103 <h2>This player is so good we couldn't find him!</h2>
104 <p>Seriously though, he probably doesn't exist...just a figment of your imagination. Carry on then!</p>
105
106 % else:
107 <div class="row">
108   <div class="span8">
109     <h2>${player.nick_html_colors()|n}</h2>
110     <p>
111        Member Since: <small>${player.create_dt.strftime('%m/%d/%Y at %I:%M %p')} </small><br />
112        Last Seen: <small>${recent_games[0][1].fuzzy_date()} </small><br />
113        Playing Time: <small>${total_stats['alivetime']} </small><br />
114        % if total_games > 0 and total_stats['wins'] is not None:
115        Win Percentage: <small>${round(float(total_stats['wins'])/total_games * 100, 2)}% (${total_stats['wins']} wins, ${total_games - total_stats['wins']} losses) </small><br />
116        % endif
117        % if total_stats['kills'] > 0 and total_stats['deaths'] > 0:
118        Kill Ratio: <small>${round(float(total_stats['kills'])/total_stats['deaths'], 3)} (${total_stats['kills']} kills, ${total_stats['deaths']} deaths) </small><br />
119        % endif
120        <% games_breakdown_str = ', '.join(["{0} {1}".format(ng, gt) for (gt, ng) in games_breakdown]) %>
121        Games Played: <small>${total_games} (${games_breakdown_str})</small><br />
122        % if elos_display is not None and len(elos_display) > 0:
123        Elo:
124           <small>${', '.join(elos_display)} </small>
125           <br />
126           %if '*' in ', '.join(elos_display):
127               <small><i>*preliminary Elo</i></small>
128           %endif
129       % endif
130     </p>
131   </div>
132 </div>
133
134
135 % if accs is not None:
136 <div class="row">
137   <div class="span10">
138     <h3>Accuracy</h3>
139     <div id="acc-graph" class="flot" style="width:800px; height:200px;">
140     </div>
141
142     <div class="weapon-nav">
143       <ul>
144         % if 'nex' in recent_weapons:
145         <li>
146           <div class="acc-weap weapon-active">
147             <img src="${request.static_url("xonstat:static/images/nex.png")}" />
148             <p><small>Nex</small></p>
149             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'nex'})}" title="Show nex accuracy"></a>
150           </div>
151         </li>
152         % endif
153
154         % if 'rifle' in recent_weapons:
155         <li>
156           <div class="acc-weap">
157             <img src="${request.static_url("xonstat:static/images/rifle.png")}" />
158             <p><small>Rifle</small></p>
159             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'rifle'})}" title="Show rifle accuracy"></a>
160           </div>
161         </li>
162         % endif
163
164         % if 'minstanex' in recent_weapons:
165         <li>
166           <div class="acc-weap">
167             <img src="${request.static_url("xonstat:static/images/minstanex.png")}" />
168             <p><small>Minstanex</small></p>
169             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'minstanex'})}" title="Show minstanex accuracy"></a>
170           </div>
171         </li>
172         % endif
173
174         % if 'uzi' in recent_weapons:
175         <li>
176           <div class="acc-weap">
177             <img src="${request.static_url("xonstat:static/images/uzi.png")}" />
178             <p><small>Uzi</small></p>
179             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'uzi'})}" title="Show uzi accuracy"></a>
180           </div>
181         </li>
182         % endif
183
184         % if 'shotgun' in recent_weapons:
185         <li>
186           <div class="acc-weap">
187             <img src="${request.static_url("xonstat:static/images/shotgun.png")}" />
188             <p><small>Shotgun</small></p>
189             <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'shotgun'})}" title="Show shotgun accuracy"></a>
190           </div>
191         </li>
192         % endif
193       </ul>
194     </div>
195
196   </div>
197 </div>
198 % endif
199
200
201 ##### RECENT GAMES (v2) ####
202 % if recent_games:
203 <div class="row">
204   <div class="span12">
205     <h3>Recent Games</h3>
206     <table class="table table-bordered table-condensed">
207       <thead>
208         <tr>
209            <th></th>
210            <th>Type</th>
211            <th>Server</th>
212            <th>Map</th>
213            <th>Result</th>
214            <th>Played</th>
215         </tr>
216       </thead>
217       <tbody>
218       % for (gamestat, game, server, map) in recent_games:
219         <tr>
220            <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>
221            <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>
222            <td>${server.name}</td>
223            <td>${map.name}</td>
224            <td>
225            % if gamestat.team != None:
226              % if gamestat.team == game.winner:
227              Win
228              % else:
229              Loss
230              % endif
231           % else:
232             % if gamestat.rank == 1:
233             Win
234             % else:
235             Loss (#${gamestat.rank})
236             % endif
237           % endif
238            </td>
239            <td>${game.fuzzy_date()}</td>
240         </tr>
241       % endfor
242       </tbody>
243     </table>
244     % if total_games > 10:
245     <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>
246     % endif
247   </div>
248 </div>
249 % endif
250 % endif