Difference between revisions of "Dev/Results"
(Removed index column stuff. Plugged in AJAX data source. Hope it works.) |
(paste from igem.org) |
||
Line 1: | Line 1: | ||
{{2015Top}} | {{2015Top}} | ||
<html> | <html> | ||
+ | <!--put 2015Top above here--> | ||
− | <script src='https://igem.org/common/DataTables-1.10.7/media/js/jquery.dataTables | + | <script src='https://igem.org/common/DataTables-1.10.7/media/js/jquery.dataTables.js'></script> |
<link rel='stylesheet' type='text/css' href='https://igem.org/common/DataTables-1.10.7/media/css/jquery.dataTables.css'> | <link rel='stylesheet' type='text/css' href='https://igem.org/common/DataTables-1.10.7/media/css/jquery.dataTables.css'> | ||
− | < | + | |
+ | <style type="text/css"> | ||
+ | /* Additional style for the +/- buttons */ | ||
+ | td.details-control { | ||
+ | background: url('../resources/details_open.png') no-repeat center center; | ||
+ | cursor: pointer; | ||
+ | } | ||
+ | tr.shown td.details-control { | ||
+ | background: url('../resources/details_close.png') no-repeat center center; | ||
+ | } | ||
+ | </style> | ||
<script> | <script> | ||
− | + | ||
+ | //Function to generate the supplementary-info child rows | ||
+ | function childRowFormat(data) { | ||
+ | return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+ | ||
+ | '<tr>'+ | ||
+ | '<td><a target="_blank" href="https://2015.igem.org/Team:' + data.team_name + '">Wiki</a></td>'+ | ||
+ | '<td><a target="_blank" href="https://igem.org/Team.cgi?id=' + data.team_id + '">Team Profile</td>'+ | ||
+ | '</tr>'+ | ||
+ | '</table>'; | ||
+ | } | ||
+ | |||
+ | jQuery(document).ready(function() { | ||
var t = jQuery('#table_team').DataTable( { | var t = jQuery('#table_team').DataTable( { | ||
− | + | 'lengthMenu': [[10, 25, 50, 100, -1],[10, 25, 50, 100, 'All']], | |
− | + | 'pageLength': -1, | |
− | + | 'deferRender': true, //improves performance | |
− | + | 'ajax': { | |
− | + | 'url': 'https://igem.org/awards/json_dump.cgi', | |
− | + | 'dataSrc': '' | |
− | + | }, | |
− | + | 'columns': [ | |
− | + | { //Child-table control element | |
− | + | 'className': 'details-control', | |
− | //' | + | 'orderable': false, |
− | //' | + | 'data': null, |
− | //' | + | 'defaultContent': '' |
− | } ); | + | }, |
+ | {'data': 'team_name'}, | ||
+ | {'data': 'region'}, | ||
+ | {'data': 'section'}, | ||
+ | {'data': 'medal'} | ||
+ | ], | ||
+ | 'order': [[1, 'asc']] //This came in with the child-table control element but I don't know why | ||
+ | } ); | ||
+ | |||
+ | // Add event listener for opening and closing details | ||
+ | $('#table_team tbody').on('click', 'td.details-control', function () { | ||
+ | var tr = $(this).closest('tr'); | ||
+ | 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'); | |
− | + | }); | |
</script> | </script> | ||
Line 39: | Line 85: | ||
<h2>Comprehensive Results from iGEM 2015</h2> | <h2>Comprehensive Results from iGEM 2015</h2> | ||
− | <p> | + | <p>View: [All Teams] [Award Winners] [other?]</p> |
− | + | ||
− | + | ||
Line 47: | Line 91: | ||
<THEAD> | <THEAD> | ||
<TR> | <TR> | ||
+ | <TH></TH> | ||
<TH>Team</TH> | <TH>Team</TH> | ||
<TH>Region</TH> | <TH>Region</TH> | ||
Line 58: | Line 103: | ||
<!-- end of content ----------------------------------------> | <!-- end of content ----------------------------------------> | ||
+ | |||
+ | |||
</div> | </div> | ||
<div class="clear"></div> | <div class="clear"></div> |
Revision as of 16:09, 23 September 2015