|
|
Line 1: |
Line 1: |
− | <html>
| |
− | <style>
| |
− | #teamListTable {
| |
− | font-size: 10pt;
| |
− | }
| |
− | </style>
| |
− | <script>
| |
| | | |
− | //initialize form_info
| |
− | var form_info = {};
| |
− | form_info.name = "2016_check_in";
| |
− | form_info.year = "2016";
| |
− | form_info.ajax_URL = "https://2016.igem.org/cgi/forms/form.cgi";
| |
− |
| |
− | function get_team_list(form_info) {
| |
− | jQuery.ajax({
| |
− | url: "https://igem.org/aj/team_list.cgi",
| |
− | method: "GET",
| |
− | timeout: 30000,
| |
− | data: {command: "get_team_list", year: form_info.year},
| |
− | dataType: "json",
| |
− | error: function(jqxhr, textStatus, errorThrown) {
| |
− | console.log("Error: Failed to get team list");
| |
− | },
| |
− | success: function(data, textStatus, jqXHR) {
| |
− | console.log("Success: Received team list");
| |
− | display_teams_in_table(data);
| |
− | }
| |
− | })
| |
− | }
| |
− |
| |
− | function get_sub_form_list(form_info, teamid) {
| |
− |
| |
− | jQuery.ajax({
| |
− | url: form_info.ajax_URL,
| |
− | method: "GET",
| |
− | timeout: 30000,
| |
− | data: {command: "get_sub_form_list", form_name: "2016_check_in", team_id: teamid},
| |
− | dataType: "json",
| |
− | error: function(jqxhr, textStatus, errorThrown) {
| |
− | console.log("Error: Failed to get sub form list");
| |
− | },
| |
− | success: function(data, textStatus, jqXHR) {
| |
− | display_subforms_in_table(data.sub_forms);
| |
− | }
| |
− | })
| |
− |
| |
− | }
| |
− |
| |
− | function generate_data_obj(form_info, team_data) {
| |
− | var request_data = [];
| |
− | team_data.forEach(function(team) {
| |
− | var single_request_data = {};
| |
− | single_request_data.command = "get_sub_form_list";
| |
− | single_request_data.form_name = form_info.name;
| |
− | single_request_data.team_id = team.id;
| |
− | request_data.push(single_request_data);
| |
− | });
| |
− | return request_data;
| |
− | }
| |
− |
| |
− | function display_teams_in_table(team_data) {
| |
− | // Example: {"country":"Germany","track":"","status":"Accepted","region":"Europe","name":"Aachen","kind":"collegiate","title":"","id":"2225"}
| |
− | var teamList = "";
| |
− |
| |
− | team_data.forEach(function(team) {
| |
− | teamList += "<tr id='" + team.id + "'><td>" + team.name + "</td><td>" + team.country + "</td><td>" + team.kind + "</td><td>" + + "</td></tr>";
| |
− |
| |
− |
| |
− | });
| |
− | $("#teamListRows").append(teamList);
| |
− |
| |
− | }
| |
− |
| |
− | function display_subforms_in_table(subformdata) {
| |
− | subformdata.forEach(function (subform) {
| |
− | console.log(JSON.stringify(subform.sub_form));
| |
− | });
| |
− | }
| |
− |
| |
− | $(document).ready(function(){
| |
− | get_team_list(form_info);
| |
− | })
| |
− | </script>
| |
− |
| |
− | <table>
| |
− | <thead>
| |
− | <tr>
| |
− | <th>Team Name</th>
| |
− | <th>Country*</th>
| |
− | <th>Kind</th>
| |
− | <th>Check-Ins</th>
| |
− | </tr>
| |
− | </thead>
| |
− | <tbody id="teamListRows">
| |
− | </tbody>
| |
− | </table>
| |
− | </html>
| |