]> de.git.xonotic.org Git - xonotic/xonstat.git/blob - xonstat/templates/player_info.mako
Initial version of ajax-updating of the accuracy graph.
[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               $.ajax({
45                   url: dataurl,
46                   method: 'GET',
47                   dataType: 'json',
48                   success: plot_acc_graph
49               });
50           });
51       })
52       </script>
53 </%block>
54
55 <%block name="title">
56 Player Information
57 </%block>
58
59
60 % if player is None:
61 <h2>This player is so good we couldn't find him!</h2>
62 <p>Seriously though, he probably doesn't exist...just a figment of your imagination. Carry on then!</p>
63
64 % else:
65 <div class="row">
66   <div class="span8">
67     <h2>${player.nick_html_colors()|n}</h2>
68     <p>
69        Member Since: <small>${player.create_dt.strftime('%m/%d/%Y at %I:%M %p')} </small><br />
70        Last Seen: <small>${recent_games[0][1].fuzzy_date()} </small><br />
71        Playing Time: <small>${total_stats['alivetime']} </small><br />
72        % if total_games > 0 and total_stats['wins'] is not None:
73        Win Percentage: <small>${round(float(total_stats['wins'])/total_games * 100, 2)}% (${total_stats['wins']} wins, ${total_games - total_stats['wins']} losses) </small><br />
74        % endif
75        % if total_stats['kills'] > 0 and total_stats['deaths'] > 0:
76        Kill Ratio: <small>${round(float(total_stats['kills'])/total_stats['deaths'], 3)} (${total_stats['kills']} kills, ${total_stats['deaths']} deaths) </small><br />
77        % endif
78        <% games_breakdown_str = ', '.join(["{0} {1}".format(ng, gt) for (gt, ng) in games_breakdown]) %>
79        Games Played: <small>${total_games} (${games_breakdown_str})</small><br />
80        % if elos_display is not None and len(elos_display) > 0:
81        Elo:
82           <small>${', '.join(elos_display)} </small>
83           <br />
84           %if '*' in ', '.join(elos_display):
85               <small><i>*preliminary Elo</i></small>
86           %endif
87       % endif
88     </p>
89   </div>
90 </div>
91 % endif
92
93
94 % if accs is not None:
95 <div class="row">
96   <div class="span10">
97     <h3>Nex Accuracy</h3>
98     <div id="acc-graph" style="width:800px; height:200px;">
99     </div>
100
101     <div class="acc-weap">
102         Show nex accuracy.
103         <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'nex'})}" title="Show nex accuracy"></a>
104     </div>
105
106     <div class="acc-weap">
107         Show rifle accuracy.
108         <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'rifle'})}" title="Show rifle accuracy"></a>
109     </div>
110
111     <div class="acc-weap">
112         Show minstanex accuracy.
113         <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'minstanex'})}" title="Show minstanex accuracy"></a>
114     </div>
115
116     <div class="acc-weap">
117         Show uzi accuracy.
118         <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'uzi'})}" title="Show uzi accuracy"></a>
119     </div>
120
121     <div class="acc-weap">
122         Show shotgun accuracy.
123         <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'shotgun'})}" title="Show shotgun accuracy"></a>
124     </div>
125
126   </div>
127 </div>
128 % endif
129
130
131 ##### RECENT GAMES (v2) ####
132 % if recent_games:
133 <div class="row">
134   <div class="span12">
135     <h3>Recent Games</h3>
136     <table class="table table-bordered table-condensed">
137       <thead>
138         <tr>
139            <th></th>
140            <th>Type</th>
141            <th>Server</th>
142            <th>Map</th>
143            <th>Result</th>
144            <th>Played</th>
145         </tr>
146       </thead>
147       <tbody>
148       % for (gamestat, game, server, map) in recent_games:
149         <tr>
150            <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>
151            <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>
152            <td>${server.name}</td>
153            <td>${map.name}</td>
154            <td>
155            % if gamestat.team != None:
156              % if gamestat.team == game.winner:
157              Win
158              % else:
159              Loss
160              % endif
161           % else:
162             % if gamestat.rank == 1:
163             Win
164             % else:
165             Loss (#${gamestat.rank})
166             % endif
167           % endif
168            </td>
169            <td>${game.fuzzy_date()}</td>
170         </tr>
171       % endfor
172       </tbody>
173     </table>
174     % if total_games > 10:
175     <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>
176     % endif
177   </div>
178 </div>
179 % endif