From: Ant Zucaro <azucaro@gmail.com> Date: Sun, 29 Apr 2012 16:10:14 +0000 (-0400) Subject: Initial version of ajax-updating of the accuracy graph. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=026915c9eeffb932fe2efbd702f850cfc65efc90;p=xonotic%2Fxonstat.git Initial version of ajax-updating of the accuracy graph. 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. --- diff --git a/xonstat/templates/player_info.mako b/xonstat/templates/player_info.mako index 5f3071c..d822845 100755 --- a/xonstat/templates/player_info.mako +++ b/xonstat/templates/player_info.mako @@ -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 diff --git a/xonstat/views/player.py b/xonstat/views/player.py index 9f2751f..cef4a52 100755 --- a/xonstat/views/player.py +++ b/xonstat/views/player.py @@ -269,7 +269,7 @@ def player_accuracy(request): games = over how many games to display accuracy. Can be up to 50. """ player_id = request.matchdict['id'] - allowed_weapons = ['nex', 'shotgun', 'uzi', 'minstanex'] + allowed_weapons = ['nex', 'rifle', 'shotgun', 'uzi', 'minstanex'] weapon_cd = 'nex' games = 20