]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Initial version of ajax-updating of the accuracy graph.
authorAnt Zucaro <azucaro@gmail.com>
Sun, 29 Apr 2012 16:10:14 +0000 (12:10 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Sun, 29 Apr 2012 16:10:14 +0000 (12:10 -0400)
The accuracy view needs to be changed to accommodate clicking on weapons where not enough data is supplied. Right now it results in a JS error that halts all further updates to the graph.

xonstat/templates/player_info.mako
xonstat/views/player.py

index 5f3071cf43f906ed10a9e663a6ca69b1274eca33..d822845bbbc5da01068a748f86ca9955a8fcbf76 100755 (executable)
@@ -11,6 +11,7 @@ ${nav.nav('players')}
       <script src="/static/js/jquery.flot.min.js"></script>
       <script type="text/javascript">
       $(function () {
+
           function plot_acc_graph(data) {
               var games = new Array();
               var avgs = new Array();
@@ -36,16 +37,18 @@ ${nav.nav('players')}
               dataType: 'json',
               success: plot_acc_graph
           });
+
+          $(".acc-weap").click(function () {
+              var dataurl = $(this).find('a').attr('href');
+
+              $.ajax({
+                  url: dataurl,
+                  method: 'GET',
+                  dataType: 'json',
+                  success: plot_acc_graph
+              });
+          });
       })
-          // var avg = ${avg};
-          // var accs = ${accs};
-
-          // $.plot($("#acc-graph"), [
-            // { data: avg },
-            // { data: accs },
-          // ],
-          // { yaxis: {ticks: 10, min: 0, max: 100 },
-          // });
       </script>
 </%block>
 
@@ -94,6 +97,32 @@ Player Information
     <h3>Nex Accuracy</h3>
     <div id="acc-graph" style="width:800px; height:200px;">
     </div>
+
+    <div class="acc-weap">
+        Show nex accuracy.
+        <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'nex'})}" title="Show nex accuracy"></a>
+    </div>
+
+    <div class="acc-weap">
+        Show rifle accuracy.
+        <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'rifle'})}" title="Show rifle accuracy"></a>
+    </div>
+
+    <div class="acc-weap">
+        Show minstanex accuracy.
+        <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'minstanex'})}" title="Show minstanex accuracy"></a>
+    </div>
+
+    <div class="acc-weap">
+        Show uzi accuracy.
+        <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'uzi'})}" title="Show uzi accuracy"></a>
+    </div>
+
+    <div class="acc-weap">
+        Show shotgun accuracy.
+        <a href="${request.route_url('player_accuracy', id=player.player_id, _query={'weapon':'shotgun'})}" title="Show shotgun accuracy"></a>
+    </div>
+
   </div>
 </div>
 % endif
index 9f2751f86b1c6ee2b92aa5a4d5161aaa8115cd27..cef4a52a9e117c987b891c60bf2c2fb7b3ed2e65 100755 (executable)
@@ -269,7 +269,7 @@ def player_accuracy(request):
        games = over how many games to display accuracy. Can be up to 50.\r
     """\r
     player_id = request.matchdict['id']\r
-    allowed_weapons = ['nex', 'shotgun', 'uzi', 'minstanex']\r
+    allowed_weapons = ['nex', 'rifle', 'shotgun', 'uzi', 'minstanex']\r
     weapon_cd = 'nex'\r
     games = 20\r
 \r