]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Use jQuery instead of D3 for selection & AJAX.
authorAnt Zucaro <azucaro@gmail.com>
Thu, 18 Dec 2014 02:03:57 +0000 (21:03 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Thu, 18 Dec 2014 02:03:57 +0000 (21:03 -0500)
xonstat/templates/player_info.mako

index 4322750330a56944dbe4c2af244731aa1c5bb0f8..8d41fa69c69c1684d87e7334706cd4a17cca81b4 100644 (file)
@@ -21,11 +21,10 @@ ${parent.css()}
 
 <%block name="js">
 ${parent.js()}
-<script src="/static/js/d3.v3.min.js"></script>
 <script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['corechart']}]}"></script>
 <script src="/static/js/weaponCharts.js"></script>
-
 <script type="text/javascript">
+
 // tabs
 $(function () {
   $('#gbtab li').click(function(e) {
@@ -38,7 +37,7 @@ $(function () {
 
 // weapon accuracy and damage charts
 google.load('visualization', '1.1', {packages: ['corechart']});
-d3.json("${request.route_url('player_weaponstats_data_json', id=player.player_id, _query={'limit':20})}", function(err, data) {
+$.getJSON("${request.route_url('player_weaponstats_data_json', id=player.player_id, _query={'limit':20})}", function(data) {
   if(data.games.length < 5) {
     d3.select(".row #damageChart").remove();
     d3.select(".row #accuracyChart").remove();
@@ -47,18 +46,16 @@ d3.json("${request.route_url('player_weaponstats_data_json', id=player.player_id
   drawAccuracyChart(data);
 });
 
+
+// game type buttons
 % for g in games_played:
-d3.select('.tab-${g.game_type_cd}').on("click", function() {
-  // have to remove the chart each time
-  d3.select('#damageChartSVG .nvd3').remove();
-  d3.select('#accuracyChartSVG .nvd3').remove();
-  d3.json("${request.route_url('player_weaponstats_data_json', id=player.player_id, _query={'limit':20, 'game_type':g.game_type_cd})}", function(err, data) {
+$('.tab-${g.game_type_cd}').click(function() {
+  $.getJSON("${request.route_url('player_weaponstats_data_json', id=player.player_id, _query={'limit':20, 'game_type':g.game_type_cd})}", function(data) {
     drawDamageChart(data);
     drawAccuracyChart(data);
   });
 });
 % endfor
-
 </script>
 <script src="https://login.persona.org/include.js" type="text/javascript"></script>
 <script type="text/javascript">${request.persona_js}</script>