Difference between revisions of "Dev/Results"

(lol I forgot a return statement)
(Moved a lot of code around to plug the parsed award data into the table)
Line 17: Line 17:
  
 
<script>
 
<script>
 
//Request the awards data
 
var arrayOfTeamAwards;
 
var resultsRequest = jQuery.ajax({
 
url: 'https://igem.org/awards/json_dump.cgi',
 
type: 'GET',
 
timeout: 30000,
 
dataType: "json",
 
error: function(jqxhr, textStatus, errorThrown) {
 
alert("AJAX error; look at var resultsRequest");
 
},
 
success: function(data, textStatus, jqxhr) {
 
console.log("successfully got team award data, now parsing");
 
arrayOfTeamAwards = parseTeamsToAwards(data);
 
}
 
});
 
  
  
Line 75: Line 59:
  
  
//Initialize dataTable and set up event bindings. **Move this to after the data request comes back and document is ready.
 
 
jQuery(document).ready(function() {
 
jQuery(document).ready(function() {
// var t = jQuery('#table_team').DataTable( {
+
//Request the awards data
// 'lengthMenu': [[10, 25, 50, 100, -1],[10, 25, 50, 100, 'All']],
+
var resultsRequest = jQuery.ajax({
// 'pageLength': -1,
+
url: 'https://igem.org/awards/json_dump.cgi',
// 'deferRender': true, //improves performance
+
type: 'GET',
// // 'ajax': {
+
timeout: 30000,
// // 'url': 'https://igem.org/awards/json_dump.cgi',
+
dataType: "json",
// // 'dataSrc': ''
+
error: function(jqxhr, textStatus, errorThrown) {
// // },
+
alert("AJAX error; look at var resultsRequest");
// //CHANGE DATA SOURCE
+
},
// 'columns': [
+
success: function(data, textStatus, jqxhr) {
// { //Child-table control element
+
console.log("successfully got team award data, now parsing");
// 'className': 'details-control',
+
arrayOfTeamAwards = parseTeamsToAwards(data);
// 'orderable': false,
+
// 'data': null,
+
//Initialize dataTable and set up event bindings.
// 'defaultContent': ''
+
var t = jQuery('#table_team').DataTable( {
// },
+
'lengthMenu': [[10, 25, 50, 100, -1],[10, 25, 50, 100, 'All']],
// {'data': 'team_name'},
+
'pageLength': -1,
// {'data': 'region'},
+
'deferRender': true, //improves performance
// {'data': 'medal',}
+
'data': arrayOfTeamAwards
// ],
+
'columns': [
// 'order': [[1, 'asc']] //I think this sorts by team-name by default
+
{ //Child-table control element
// } );
+
'className': 'details-control',
+
'orderable': false,
// // Add event listener for opening and closing details
+
'data': null,
// $('#table_team tbody').on('click', 'td.details-control', function () {
+
'defaultContent': ''
// var tr = $(this).closest('tr');
+
},
// var row = t.row( tr );
+
{'data': 'team_name'},
+
{'data': 'medal',}
// if ( row.child.isShown() ) {
+
{'data': 'award', 'defaultContent': ' '},
// // This row is already open - close it
+
],
// row.child.hide();
+
'order': [[1, 'asc']] //I think this sorts by team-name by default
// tr.removeClass('shown');
+
} );
// }
+
// else {
+
// Add event listener for opening and closing details
// // Open this row
+
$('#table_team tbody').on('click', 'td.details-control', function () {
// row.child( childRowFormat(row.data()) ).show();
+
var tr = $(this).closest('tr');
// tr.addClass('shown');
+
var row = t.row( tr );
// }
+
// } );
+
if ( row.child.isShown() ) {
 +
// This row is already open - close it
 +
row.child.hide();
 +
tr.removeClass('shown');
 +
}
 +
else {
 +
// Open this row
 +
row.child( childRowFormat(row.data()) ).show();
 +
tr.addClass('shown');
 +
}
 +
} );
  
// jQuery('#table_team').addClass('hover');
+
jQuery('#table_team').addClass('hover'); //What's this?
 +
 +
}
 +
});
 +
 +
  
 
});
 
});
Line 140: Line 138:
 
<TH></TH>
 
<TH></TH>
 
<TH>Team</TH>
 
<TH>Team</TH>
<TH>Region</TH>
 
 
<TH>Medal</TH>
 
<TH>Medal</TH>
 +
<TH>Award</TH>
 
</TR>
 
</TR>
 
</THEAD>
 
</THEAD>

Revision as of 18:47, 23 September 2015

Comprehensive Results from iGEM 2015

View: [All Teams] [Award Winners] [other?]

Team Medal Award