]> de.git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/templates/player_info.mako
Use the gametype icons in the tabs!
[xonotic/xonstat.git] / xonstat / templates / player_info.mako
index 9227c5302f8ef9d11d84af8d82a7407d800c946b..6ec476e68da170501f0277cb88a535b562e57787 100644 (file)
@@ -10,9 +10,20 @@ ${nav.nav('players')}
     % if player is not None:
       <script src="/static/js/jquery-1.7.1.min.js"></script>
       <script src="/static/js/jquery.flot.min.js"></script>
+      <script src="/static/js/bootstrap-tab.js"></script>
       <script type="text/javascript">
       $(function () {
+        $('#gbtab li').click(function(e) {
+            e.preventDefault();
+            $(this).tab('show');
+        })
 
+        $('#gbtab a:first').tab('show');
+      })
+      </script>
+
+      <script type="text/javascript">
+      $(function () {
           // plot the accuracy graph
           function plot_acc_graph(data) {
               var games = new Array();
@@ -80,9 +91,9 @@ ${nav.nav('players')}
           var previousLabel = null;
           $('#acc-graph').bind("plothover", function (event, pos, item) {
               if (item) {
-                  if ((previousLabel != item.series.label) || (previousPoint != item.dataIndex)) {
-                    previousPoint = item.dataIndex;
+                if ((previousLabel != item.series.label) || (previousPoint != item.dataIndex)) {
                     previousLabel = item.series.label;
+                    previousPoint = item.dataIndex;
 
                     $("#tooltip").remove();
                     var x = item.datapoint[0].toFixed(2),
@@ -100,7 +111,7 @@ ${nav.nav('players')}
 
           $('#dmg-graph').bind("plothover", function (event, pos, item) {
               if (item) {
-                  if ((previousLabel != item.series.label) || (previousPoint != item.dataIndex)) {
+                if ((previousLabel != item.series.label) || (previousPoint != item.dataIndex)) {
                     previousPoint = item.dataIndex;
                     previousLabel = item.series.label;
 
@@ -183,70 +194,85 @@ Player Information
 </div>
 
 <div class="row">
-  <div class="span6">
-    <p>
-      Member Since: <small>${player.create_dt.strftime('%m/%d/%Y at %I:%M %p')} </small><br />
+  <div id="gbtabcontainer" class="tabbable tabs-below">
+      <div class="tab-content">
+      % for g in games_played:
+        <div class="tab-pane fade in 
+        % if g.game_type_cd == 'overall':
+          active
+        % endif
+        " id="tab-${g.game_type_cd}">
+          <div class="span5">
+            <p>
+            % if g.game_type_cd in overall_stats:
+            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>
+            % endif
 
-      Last Seen: <small>${recent_games[0][1].fuzzy_date()} </small><br />
+            Games Played: <small>${g.games} <br /></small>
 
-      Playing Time: <small>${total_stats['alivetime']}
-      % if total_stats['alivetime_month'] and total_stats['alivetime'] > total_stats['alivetime_month']:
-          % if total_stats['alivetime_week'] and total_stats['alivetime_month'] > total_stats['alivetime_week']:
-              <br />(${total_stats['alivetime_month']} this month; ${total_stats['alivetime_week']} this week)
-          % else:
-              <br />(${total_stats['alivetime_month']} this month)
-          % endif
-      % endif
-      </small><br />
+            Playing Time: <small>${overall_stats[g.game_type_cd].total_playing_time} <br /></small>
 
-      <% games_breakdown_str = ', '.join(["{0} {1}".format(ng, gt) for (gt, ng) in total_stats['games_breakdown'].items()]) %>
-      Games Played: <small>${total_stats['games']}<br />(${games_breakdown_str})</small><br />
-    </p>
-  </div>
-  <div class="span6">
-    <p>
-      % if fav_server is not None:
-      Favorite Server: <small><a href="${request.route_url('server_info', id=fav_server[0]['id'])}" title="view server info">${fav_server[0]['name']}</a></small><br />
-      % endif
-
-      % if fav_map is not None:
-      Favorite Map: <small><a href="${request.route_url('map_info', id=fav_map[0]['id'])}" title="view map info">${fav_map[0]['name']}</a></small><br />
-      % endif
-
-      % if fav_weapon is not None:
-      Favorite Weapon: <small>${fav_weapon[0]['name']}</small><br />
-      % endif
-
-      % if total_stats['games'] > 0 and total_stats['wins'] is not None:
-      Win Percentage: <small>${round(float(total_stats['wins'])/total_stats['games'] * 100, 2)}% (${total_stats['wins']} wins, ${total_stats['games'] - total_stats['wins']} losses) </small><br />
-      % endif
-
-      % if total_stats['kills'] > 0 and total_stats['deaths'] > 0:
-      Kill Ratio: <small>${round(float(total_stats['kills'])/total_stats['deaths'], 3)} (${total_stats['kills']} kills, ${total_stats['deaths']} deaths, ${total_stats['suicides']} suicides) </small><br />
-      % endif
-    </p>
+            % if g.game_type_cd in fav_maps:
+            Favorite Map: <small>${fav_maps[g.game_type_cd].map_name} <br /></small>
+            % endif
+            </p>
+          </div>
+          <div class="span5">
+            <p>
+            Win Percentage: <small>${round(g.win_pct,2)}% (${g.wins} wins, ${g.losses} losses) <br /></small>
+
+            % if g.game_type_cd in overall_stats:
+              % if overall_stats[g.game_type_cd].k_d_ratio is not None:
+              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>
+              % endif
+            % endif
+
+            % if g.game_type_cd in elos:
+              % if g.game_type_cd == 'overall':
+              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>
+              % else:
+              Elo: <small>${round(elos[g.game_type_cd].elo,2)} (${elos[g.game_type_cd].games} games) <br /></small>
+              % endif
+            % endif
+
+            % if g.game_type_cd in ranks:
+              % if g.game_type_cd == 'overall':
+              Best Rank: <small>${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank} (${ranks[g.game_type_cd].game_type_cd}, percentile: ${round(ranks[g.game_type_cd].percentile,2)})<br /></small>
+
+              % else:
+              Rank: <small>${ranks[g.game_type_cd].rank} of ${ranks[g.game_type_cd].max_rank} (percentile: ${round(ranks[g.game_type_cd].percentile,2)})<br /></small>
+              % endif
+            % endif
+
+            % if g.game_type_cd == 'ctf':
+              % if  overall_stats[g.game_type_cd].cap_ratio is not None:
+                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>
+              % endif
+            % endif
+            </p>
+          </div>
+        </div>
+      % endfor
+      </div>
   </div>
 </div>
-
 <div class="row">
   <div class="span12">
-    <p>
-       % if elos_display is not None and len(elos_display) > 0:
-       Elo:
-          <small>${elos_display} </small>
-          %if '*' in elos_display:
-              <small><i>*preliminary Elo</i></small>
-          %endif
-          <br />
-      % endif
-
-      % if ranks_display != '':
-      Ranks: <small>${ranks_display}</small><br />
-      % endif
-    </p>
+      <ul id="gbtab" class="nav nav-tabs">
+      % for g in games_played:
+        <li>
+          <a href="#tab-${g.game_type_cd}" data-toggle="tab">
+            <img src="/static/images/icons/24x24/${g.game_type_cd}.png"> <br />
+            ${g.game_type_cd} <br />
+            <small>(${g.games})</small>
+          </a>
+        </li>
+      % endfor
+      </ul>
   </div>
 </div>
 
+
 % if 'nex' in recent_weapons or 'rifle' in recent_weapons or 'minstanex' in recent_weapons or 'uzi' in recent_weapons or 'shotgun' in recent_weapons:
 <div class="row">
   <div class="span10">
@@ -261,7 +287,7 @@ Player Information
           <div class="acc-weap weapon-active">
             <img src="${request.static_url("xonstat:static/images/nex.png")}" />
             <p><small>Nex</small></p>
-            <a href="${request.route_url('player_accuracy', id=player.player_id, _query=[('weapon','nex')])}" title="Show nex accuracy"></a>
+            <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'nex'})}" title="Show nex accuracy"></a>
           </div>
         </li>
         % endif
@@ -271,7 +297,7 @@ Player Information
           <div class="acc-weap">
             <img src="${request.static_url("xonstat:static/images/rifle.png")}" />
             <p><small>Rifle</small></p>
-            <a href="${request.route_url('player_accuracy', id=player.player_id, _query=[('weapon','rifle')])}" title="Show rifle accuracy"></a>
+            <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'rifle'})}" title="Show rifle accuracy"></a>
           </div>
         </li>
         % endif
@@ -281,7 +307,7 @@ Player Information
           <div class="acc-weap">
             <img src="${request.static_url("xonstat:static/images/minstanex.png")}" />
             <p><small>Minstanex</small></p>
-            <a href="${request.route_url('player_accuracy', id=player.player_id, _query=[('weapon','minstanex')])}" title="Show minstanex accuracy"></a>
+            <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'minstanex'})}" title="Show minstanex accuracy"></a>
           </div>
         </li>
         % endif
@@ -291,7 +317,7 @@ Player Information
           <div class="acc-weap">
             <img src="${request.static_url("xonstat:static/images/uzi.png")}" />
             <p><small>Uzi</small></p>
-            <a href="${request.route_url('player_accuracy', id=player.player_id, _query=[('weapon','uzi')])}" title="Show uzi accuracy"></a>
+            <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'uzi'})}" title="Show uzi accuracy"></a>
           </div>
         </li>
         % endif
@@ -301,7 +327,7 @@ Player Information
           <div class="acc-weap">
             <img src="${request.static_url("xonstat:static/images/shotgun.png")}" />
             <p><small>Shotgun</small></p>
-            <a href="${request.route_url('player_accuracy', id=player.player_id, _query=[('weapon','shotgun')])}" title="Show shotgun accuracy"></a>
+            <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'shotgun'})}" title="Show shotgun accuracy"></a>
           </div>
         </li>
         % endif
@@ -327,7 +353,7 @@ Player Information
           <div class="dmg-weap weapon-active">
             <img src="${request.static_url("xonstat:static/images/rocketlauncher.png")}" />
             <p><small>Rocket</small></p>
-            <a href="${request.route_url('player_damage', id=player.player_id, _query=[('weapon','rocketlauncher')])}" title="Show rocket launcher efficiency"></a>
+            <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'rocketlauncher'})}" title="Show rocket launcher efficiency"></a>
           </div>
         </li>
         % endif
@@ -337,7 +363,7 @@ Player Information
           <div class="dmg-weap">
             <img src="${request.static_url("xonstat:static/images/grenadelauncher.png")}" />
             <p><small>Mortar</small></p>
-            <a href="${request.route_url('player_damage', id=player.player_id, _query=[('weapon','grenadelauncher')])}" title="Show mortar damage efficiency"></a>
+            <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'grenadelauncher'})}" title="Show mortar damage efficiency"></a>
           </div>
         </li>
         % endif
@@ -347,7 +373,7 @@ Player Information
           <div class="dmg-weap">
             <img src="${request.static_url("xonstat:static/images/electro.png")}" />
             <p><small>Electro</small></p>
-            <a href="${request.route_url('player_damage', id=player.player_id, _query=[('weapon','electro')])}" title="Show electro damage efficiency"></a>
+            <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'electro'})}" title="Show electro damage efficiency"></a>
           </div>
         </li>
         % endif
@@ -357,7 +383,7 @@ Player Information
           <div class="dmg-weap">
             <img src="${request.static_url("xonstat:static/images/crylink.png")}" />
             <p><small>Crylink</small></p>
-            <a href="${request.route_url('player_damage', id=player.player_id, _query=[('weapon','crylink')])}" title="Show crylink damage efficiency"></a>
+            <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'crylink'})}" title="Show crylink damage efficiency"></a>
           </div>
         </li>
         % endif
@@ -367,7 +393,7 @@ Player Information
           <div class="dmg-weap">
             <img src="${request.static_url("xonstat:static/images/hagar.png")}" />
             <p><small>Hagar</small></p>
-            <a href="${request.route_url('player_damage', id=player.player_id, _query=[('weapon','hagar')])}" title="Show hagar damage efficiency"></a>
+            <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'hagar'})}" title="Show hagar damage efficiency"></a>
           </div>
         </li>
         % endif
@@ -377,7 +403,7 @@ Player Information
           <div class="dmg-weap">
             <img src="${request.static_url("xonstat:static/images/laser.png")}" />
             <p><small>Laser</small></p>
-            <a href="${request.route_url('player_damage', id=player.player_id, _query=[('weapon','laser')])}" title="Show laser damage efficiency"></a>
+            <a href="${request.route_url('player_damage', id=player.player_id, _query={'weapon':'laser'})}" title="Show laser damage efficiency"></a>
           </div>
         </li>
         % endif
@@ -389,55 +415,9 @@ Player Information
 </div>
 % endif
 
-<div class="row">
-  <div class="span12">
-    <h3>Game Breakdown</h3>
-    <table class="table table-bordered table-condensed">
-      <thead>
-        <tr>
-           <th>Type</th>
-           <th>Games Played</th>
-           <th>Win Percentage</th>
-           <th>Kill/Cap Ratio</th>
-        </tr>
-      </thead>
-      <tbody>
-      <% gametypes = ['Duel', 'DM', 'TDM', 'CTF'] %>
-      % for gtc in gametypes:
-        <% gtc_key = gtc.lower() %>
-        % if total_stats['games_breakdown'].has_key(gtc_key):
-        <tr>
-           <td style="width:20px;"><img title="${gtc}" src="/static/images/icons/24x24/${gtc_key}.png" alt="${gtc}" /></td>
-           <% total     = total_stats['games_breakdown'][gtc_key] %>
-           <% wins      = total_stats[gtc_key+'_wins'] %>
-           <% losses    = total - wins %>
-           <td>${total}</td>
-           <td><big>${round(float(wins)/total * 100, 2)}%</big>  (${wins} wins, ${losses} losses)</td>
-           % if gtc.lower() == "ctf":
-             <% caps      = total_stats[gtc_key+'_caps'] %>
-             <% pickups   = total_stats[gtc_key+'_pickups'] %>
-             <% returns   = total_stats[gtc_key+'_returns'] %>
-             <% drops     = total_stats[gtc_key+'_drops'] %>
-             <% fckills   = total_stats[gtc_key+'_fckills'] %>
-           <td><big>${round(float(caps)/pickups, 3)}</big>  (${caps} caps, ${pickups} pickups, ${drops} drops, ${returns} returns, ${fckills} fckills)</td>
-           % else:
-             <% kills     = total_stats[gtc_key+'_kills'] %>
-             <% deaths    = total_stats[gtc_key+'_deaths'] %>
-             <% suicides  = total_stats[gtc_key+'_suicides'] %>
-           <td><big>${round(float(kills)/deaths, 3)}</big>  (${kills} kills, ${deaths} deaths, ${suicides} suicides)</td>
-           % endif
-        </tr>
-        % endif
-      % endfor
-      </tbody>
-    </table>
-  </div>
-</div>
-
 
 ##### RECENT GAMES (v2) ####
 % if recent_games:
-<br />
 <div class="row">
   <div class="span12">
     <h3>Recent Games</h3>
@@ -474,7 +454,7 @@ Player Information
             % endif
           % endif
            </td>
-           <td>${game.fuzzy_date()}</td>
+           <td><span class="abstime" data-epoch="${game.epoch()}" title="${game.create_dt.strftime('%a, %d %b %Y %H:%M:%S UTC')}">${game.fuzzy_date()}</span></td>
         </tr>
       % endfor
       </tbody>