Difference between revisions of "Dev/Results"
(fix table width for mainpage styling) |
(better error reporting) |
||
Line 81: | Line 81: | ||
} | } | ||
return arrayOfTeamAwards; | return arrayOfTeamAwards; | ||
+ | } | ||
+ | |||
+ | //Helper to display a message in the body of the table (eventually overwritten by team data). | ||
+ | function showInTable(text) { | ||
+ | $("#table_team tbody").empty(); | ||
+ | if (typeof text == "string") { | ||
+ | $("#table_team tbody").append("<tr><td colspan='3'>" + text + "</td></tr>"); | ||
+ | } | ||
} | } | ||
Line 86: | Line 94: | ||
jQuery(document).ready(function() { | jQuery(document).ready(function() { | ||
$("#title-year").html(currentYear); | $("#title-year").html(currentYear); | ||
− | $("#table_team tbody").empty().append("<tr><td colspan='3'>Loading...</td></tr>"); | + | // $("#table_team tbody").empty().append("<tr><td colspan='3'>Loading...</td></tr>"); |
+ | showInTable("Loading..."); | ||
//Request team data | //Request team data | ||
Line 96: | Line 105: | ||
data: {command: "get_team_list", year: currentYear}, | data: {command: "get_team_list", year: currentYear}, | ||
error: function(jqxhr, textStatus, errorThrown) { | error: function(jqxhr, textStatus, errorThrown) { | ||
− | + | console.log("Failed to get list of teams. look at var teamsRequest"); | |
+ | showInTable("Error loading list of teams. Please check your internet connection and try again. If the problem persists, contact iGEM HQ."); | ||
} | } | ||
}); | }); | ||
Line 107: | Line 117: | ||
data: {year: currentYear}, | data: {year: currentYear}, | ||
error: function(jqxhr, textStatus, errorThrown) { | error: function(jqxhr, textStatus, errorThrown) { | ||
− | + | console.log("AJAX error; look at var awardsRequest"); | |
+ | showInTable("Error loading competition results. Please check your internet connection and try again. If the problem persists, contact iGEM HQ."); | ||
} | } | ||
}); | }); | ||
Line 113: | Line 124: | ||
//When both requests finish, parse the data and set up the table. | //When both requests finish, parse the data and set up the table. | ||
jQuery.when(teamsRequest, awardsRequest).done(function(teamsReqResult, awardsReqResult) { | jQuery.when(teamsRequest, awardsRequest).done(function(teamsReqResult, awardsReqResult) { | ||
− | + | showInTable(); | |
var teamsData = teamsReqResult[0]; | var teamsData = teamsReqResult[0]; | ||
var awardsData = awardsReqResult[0]; | var awardsData = awardsReqResult[0]; |
Revision as of 02:31, 28 September 2015