function parseResultsFromJSON(tournament) {
  tournament += ".json";
  console.log("Requesting JSON from " + tournament);

  // Let's have some fun with jQuery!
  $.getJSON(tournament, function(data) {
    // Apply the filters requested
    matches = data.match;
    matches = filterByPlayer(matches);
    matches = filterBySets(matches);
    matches = filterByRound(matches);

    // Generate the table with the results
    console.log("Generating rows for " + data.name + " " + data.year);

    var table = $("#results-table");
    table.find("tbody").remove();

    matches.forEach(function(match) {
      var tbody = $("<tbody>");

      match.player.forEach(function(player) {
        var row = $("<tr>").addClass(player.outcome);
        row.append($("<td>").html(match.round));
        row.append(
          $("<td>")
            .addClass("name")
            .html(player.name)
        );

        var setsCount = 0;
        player.set.forEach(function(set) {
          setsCount++;
          row.append($("<td>").text(set));
        });

        for (var i = setsCount; i < 5; i++) {
          row.append($("<td>"));
        }
        tbody.append(row);
      });

      table.append(tbody);
    });
  });
}
// Loads the JSON file and generates a table with the results
Loads the JSON file and generates a table with the results
Loads the JSON file and generates a table with the results
function parseResultsFromJSON(tournament) {
  tournament += ".json";
  console.log("Requesting JSON from " + tournament);
  $.getJSON(tournament, function(data) {
    matches = data.match;
    matches = filterByPlayer(matches);
    matches = filterBySets(matches);
    matches = filterByRound(matches);
    console.log("Generating rows for " + data.name + " " + data.year);
    var table = $("#results-table");
    table.find("tbody").remove();
    matches.forEach(function(match) {
      var tbody = $("<tbody>");
      match.player.forEach(function(player) {
        var row = $("<tr>").addClass(player.outcome);
        row.append($("<td>").html(match.round));
        row.append(
          $("<td>")
            .addClass("name")
            .html(player.name)
        );
        var setsCount = 0;
        player.set.forEach(function(set) {
          setsCount++;
          row.append($("<td>").text(set));
        });
        for (var i = setsCount; i < 5; i++) {
          row.append($("<td>"));
        }
        tbody.append(row);
      });
      table.append(tbody);
    });
  });
}
function parseResultsFromJSON ( tournament ) { tournament += ".json" ; console . log ( "Requesting JSON from " + tournament ) ; $ . getJSON ( tournament , function ( data ) { matches = data . match ; matches = filterByPlayer ( matches ) ; matches = filterBySets ( matches ) ; matches = filterByRound ( matches ) ; console . log ( "Generating rows for " + data . name + " " + data . year ) ; var table = $ ( "#results-table" ) ; table . find ( "tbody" ) . remove ( ) ; matches . forEach ( function ( match ) { var tbody = $ ( "<tbody>" ) ; match . player . forEach ( function ( player ) { var row = $ ( "<tr>" ) . addClass ( player . outcome ) ; row . append ( $ ( "<td>" ) . html ( match . round ) ) ; row . append ( $ ( "<td>" ) . addClass ( "name" ) . html ( player . name ) ) ; var setsCount = 0 ; player . set . forEach ( function ( set ) { setsCount ++ ; row . append ( $ ( "<td>" ) . text ( set ) ) ; } ) ; for ( var i = setsCount ; i < 5 ; i ++ ) { row . append ( $ ( "<td>" ) ) ; } tbody . append ( row ) ; } ) ; table . append ( tbody ) ; } ) ; } ) ; }
Loads the JSON file and generates a table with the results
Loads the JSON file and generates a table with the results
// Let's have some fun with jQuery! // Apply the filters requested // Generate the table with the results