]> git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Refactor the presentation of the accuracy graph.
authorAnt Zucaro <azucaro@gmail.com>
Sun, 18 Aug 2013 13:47:18 +0000 (09:47 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Sun, 18 Aug 2013 13:47:18 +0000 (09:47 -0400)
xonstat/templates/accuracy_graph.mako [new file with mode: 0644]
xonstat/templates/player_info.mako

diff --git a/xonstat/templates/accuracy_graph.mako b/xonstat/templates/accuracy_graph.mako
new file mode 100644 (file)
index 0000000..8458b77
--- /dev/null
@@ -0,0 +1,35 @@
+<%def name="accuracy_graph(recent_weapons)">
+### hitscan weapon data is available
+% 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="span12">
+    <h3>Accuracy</h3>
+
+    <div id="acc-graph" class="flot" style="width:95%; height:200px;">
+    </div>
+
+    <div class="weapon-nav accuracy-nav">
+      <ul>
+      % for weapon in ['nex', 'rifle', 'minstanex', 'uzi', 'shotgun']:
+        % if weapon in recent_weapons:
+        <li>
+        ### the nex is underscored first by default (until user selection)
+        % if weapon == 'nex':
+        <div class="acc-weap weapon-active">
+        % else:
+        <div class="acc-weap">
+        % endif
+          <span class="sprite sprite-${weapon}"></span>
+          <p><small>${weapon}</small></p>
+          <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':weapon})}" title="Show ${weapon} accuracy"></a>
+        </div>
+        </li>
+        % endif
+      % endfor
+      </ul>
+    </div>
+
+  </div> <!-- END SPAN12 -->
+</div> <!-- END ROW -->
+% endif
+</%def>
index 677c0580417e0eb5a3d56ca66a991e62ed4ab2a8..293d1d5370478b8bde8de41962d60df7e87815d7 100644 (file)
@@ -1,6 +1,7 @@
 <%inherit file="base.mako"/>
 <%namespace name="nav" file="nav.mako" />
 <%namespace file="accuracy.mako" import="accuracy" />
+<%namespace file="accuracy_graph.mako" import="accuracy_graph" />
 
 <%block name="navigation">
 ${nav.nav('players')}
@@ -331,71 +332,8 @@ Player Information
 </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="span12">
-    <h3>Accuracy</h3>
-    <div id="acc-graph" class="flot" style="width:95%; height:200px;">
-    </div>
-
-    <div class="weapon-nav accuracy-nav">
-      <ul>
-        % if 'nex' in recent_weapons:
-        <li>
-        <div class="acc-weap weapon-active">
-          <span class="sprite sprite-nex"></span>
-          <p><small>Nex</small></p>
-          <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'nex'})}" title="Show nex accuracy"></a>
-        </div>
-        </li>
-        % endif
-
-        % if 'rifle' in recent_weapons:
-        <li>
-        <div class="acc-weap">
-          <span class="sprite sprite-rifle"></span>
-          <p><small>Rifle</small></p>
-          <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'rifle'})}" title="Show rifle accuracy"></a>
-        </div>
-        </li>
-        % endif
-
-        % if 'minstanex' in recent_weapons:
-        <li>
-        <div class="acc-weap">
-          <span class="sprite sprite-minstanex"></span>
-          <p><small>Minstanex</small></p>
-          <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'minstanex'})}" title="Show minstanex accuracy"></a>
-        </div>
-        </li>
-        % endif
-
-        % if 'uzi' in recent_weapons:
-        <li>
-        <div class="acc-weap">
-          <span class="sprite sprite-uzi"></span>
-          <p><small>Uzi</small></p>
-          <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'uzi'})}" title="Show uzi accuracy"></a>
-        </div>
-        </li>
-        % endif
-
-        % if 'shotgun' in recent_weapons:
-        <li>
-        <div class="acc-weap">
-          <span class="sprite sprite-shotgun"></span>
-          <p><small>Shotgun</small></p>
-          <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'shotgun'})}" title="Show shotgun accuracy"></a>
-        </div>
-        </li>
-        % endif
-      </ul>
-    </div>
-
-  </div>
-</div>
-% endif
-
+### ACCURACY GRAPH
+${accuracy_graph(recent_weapons)}
 
 % if 'rocketlauncher' in recent_weapons or 'grenadelauncher' in recent_weapons or 'electro' in recent_weapons or 'crylink' in recent_weapons or 'laser' in recent_weapons:
 <div class="row">