Difference between revisions of "Dev/Results"

(cleaned up -- deleted old commented-out code)
(Improved the functions that specify column content)
Line 6: Line 6:
  
 
<style type="text/css">
 
<style type="text/css">
#table_team tbody img {
+
#table_team tbody img {
padding: 0px;
+
padding: 0px;
margin-left: auto;
+
margin-left: auto;
margin-right: auto; /* **I can't get them to center, for some reason*/
+
margin-right: auto; /* **I can't get them to center, for some reason*/
}
+
}
 
</style>
 
</style>
  
Line 19: Line 19:
 
String.prototype.capitalize = function() {
 
String.prototype.capitalize = function() {
 
     return this.charAt(0).toUpperCase() + this.slice(1);
 
     return this.charAt(0).toUpperCase() + this.slice(1);
 +
}
 +
 +
function canonicalizeMedal(m) {
 +
m = m.toLowerCase();
 +
if (['gold', 'silver', 'bronze', 'no medal'].indexOf(m) == -1) {
 +
return 'missing';
 +
}
 +
return m;
 
}
 
}
  
Line 55: Line 63:
 
delete teamAwardObj.awards; //delete the array of awards
 
delete teamAwardObj.awards; //delete the array of awards
 
teamAwardObj.award = award; //add the one award back
 
teamAwardObj.award = award; //add the one award back
 +
teamAwardObj.medal = canonicalizeMedal(teamAwardObj.medal); //canonicalize the medal
 
arrayOfTeamAwards.push(teamAwardObj); //and put the team*award on the list to return
 
arrayOfTeamAwards.push(teamAwardObj); //and put the team*award on the list to return
 
});
 
});
Line 98: Line 107:
 
'lengthMenu': [[10, 25, 50, 100, -1],[10, 25, 50, 100, 'All']],
 
'lengthMenu': [[10, 25, 50, 100, -1],[10, 25, 50, 100, 'All']],
 
'pageLength': -1,
 
'pageLength': -1,
//'deferRender': true, //improves performance
+
'order': [[1, 'asc']] //I think this sorts by team-name by default
 
'data': arrayOfTeamAwards,
 
'data': arrayOfTeamAwards,
 
'columns': [
 
'columns': [
{
+
{ //Medal Column
 
'data': function(row, type, val, meta) {
 
'data': function(row, type, val, meta) {
if (row.medal.toUpperCase() == "GOLD") {
+
var medals_info = {
return "<img title='Gold Medal' src='https://igem.org/images/medals/seal_gold.png'>";
+
'gold': {
 +
sort: 1,
 +
filter: 'gold medal',
 +
html: "<img title='Gold Medal' src='https://igem.org/images/medals/seal_gold.png'>"
 +
},
 +
'silver': {
 +
sort: 2,
 +
filter: 'silver medal',
 +
html: "<img title='Silver Medal' src='https://igem.org/images/medals/seal_silver.png'>"
 +
},
 +
'bronze': {
 +
sort: 3,
 +
filter: 'bronze medal',
 +
html: "<img title='Bronze Medal' src='https://igem.org/images/medals/seal_bronze.png'>"
 +
},
 +
'no medal': {
 +
sort: 4,
 +
filter: 'no medal',
 +
html: "<img title='No Medal' src='http://web.mit.edu/kdrinkwa/Public/Pictures/seal_transparent.png'>"
 +
},
 +
'missing': {
 +
sort: 5,
 +
filter: 'medal data missing unavailable',
 +
html: "<img title='Medal Data Not Available' src='https://igem.org/images/medals/seal_blocked.png'>"
 +
}
 +
};
 +
if (type == 'sort') {
 +
return medals_info[row.medal].sort;
 
}
 
}
else if (row.medal.toUpperCase() == "SILVER") {
+
else if (type == 'filter') {
return "<img title='Silver Medal' src='https://igem.org/images/medals/seal_silver.png'>";
+
return medals_info[row.medal].filter;
}
+
else if (row.medal.toUpperCase() == "BRONZE") {
+
return "<img title='Bronze Medal' src='https://igem.org/images/medals/seal_bronze.png'>";
+
}
+
else if (row.medal.toUpperCase() == "NO MEDAL") {
+
return "<img title='No Medal' src='http://web.mit.edu/kdrinkwa/Public/Pictures/seal_transparent.png'>";
+
 
}
 
}
 
else {
 
else {
return "<img title='Medal Data Not Available' src='https://igem.org/images/medals/seal_blocked.png'>";
+
return medals_info[row.medal].html;
 
}
 
}
 
}
 
}
 
},
 
},
{
+
{ //Team Name Column
 
'data': function(row, type, val, meta) {
 
'data': function(row, type, val, meta) {
return "<a class='team-info-control' style='cursor: pointer;'>" + row.team_name + "</a>";
+
if (type == 'display') {
 +
return "<a class='team-info-control' style='cursor: pointer;'>" + row.team_name + "</a>";
 +
}
 +
else {
 +
return row.team_name;
 +
}
 
}
 
}
 
},
 
},
{'data': 'award', 'defaultContent': ' '}
+
{ //Award Column
 +
'data': 'award',  
 +
'defaultContent': ' '
 +
}
 
],
 
],
'order': [[1, 'asc']] //I think this sorts by team-name by default
 
 
} );
 
} );
 
 

Revision as of 21:03, 23 September 2015

Comprehensive Results from iGEM

View: [All Teams] [Award Winners] | [Africa] [Asia] [Europe] [Latin America][other?]

Team Award