<commit_before>function PPSinglesEditController(player1TextId, player2TextId, player1RadioId, player2RadioId, tournament) {
  if (player1TextId == null || player2TextId == null || player1RadioId == null || player2RadioId == null) {
    throw new Error("PPSinglesEditController missing required parameter.");
  }

  this.superclass(tournament);

  this.player1TextId = player1TextId;
  this.player2TextId = player2TextId;
  this.player1RadioId = player1RadioId;
  this.player2RadioId = player2RadioId;

  var self = this;
  // Bind to html elements when document is loaded.
  PPUtils.bind("load", window, function () {self.bind();} );
}

// This must be in between the constructor definition and
// new method definitions in order for it to work.
PPUtils.extend (PPSinglesEditController, PPEditController);

PPSinglesEditController.prototype.bind = function () {
  var self = this;
  PPUtils.bind("keyup", $(this.player1TextId), function () {self.updatePlayer1(self.player1TextId);} );
  PPUtils.bind("keyup", $(this.player2TextId), function () {self.updatePlayer2(self.player2TextId);} );
  PPUtils.bind("click", $(this.player1RadioId), function () {self.setMatchWinner();} );
  PPUtils.bind("click", $(this.player2RadioId), function () {self.setMatchWinner();} );
}


PPSinglesEditController.prototype.setMatchWinner = function() {
  var selectedMatch = this.tournament.getSelectedMatch();

  if (selectedMatch == null ) {
    throw new Error("Unexpected state");
  }

  if ( $(this.player1RadioId).checked ) {
    selectedMatch.setWinner(PPMatch.player1);
  } else {
    selectedMatch.setWinner(PPMatch.player2);
  }

}<commit_msg>Use getSelectedMatch, fix spelling mistake for global var reference.<commit_after>function PPSinglesEditController(player1TextId, player2TextId, player1RadioId, player2RadioId, tournament) {
  if (player1TextId == null || player2TextId == null || player1RadioId == null || player2RadioId == null) {
    throw new Error("PPSinglesEditController missing required parameter.");
  }

  this.superclass(tournament);

  this.player1TextId = player1TextId;
  this.player2TextId = player2TextId;
  this.player1RadioId = player1RadioId;
  this.player2RadioId = player2RadioId;

  var self = this;
  // Bind to html elements when document is loaded.
  PPUtils.bind("load", window, function () {self.bind();} );
}

// This must be in between the constructor definition and
// new method definitions in order for it to work.
PPUtils.extend (PPSinglesEditController, PPEditController);

PPSinglesEditController.prototype.bind = function () {
  var self = this;
  PPUtils.bind("keyup", $(this.player1TextId), function () {self.updatePlayer1(self.player1TextId);} );
  PPUtils.bind("keyup", $(this.player2TextId), function () {self.updatePlayer2(self.player2TextId);} );
  PPUtils.bind("click", $(this.player1RadioId), function () {self.setMatchWinner();} );
  PPUtils.bind("click", $(this.player2RadioId), function () {self.setMatchWinner();} );
}


PPSinglesEditController.prototype.setMatchWinner = function() {
  var selectedMatch = this.getSelectedMatch();

  if ( $(this.player1RadioId).checked ) {
    selectedMatch.setWinner(PPMatch.Player1);
  } else {
    selectedMatch.setWinner(PPMatch.Player2);
  }

}
{'fraction_non_alphanumeric': 0.1318069306930693, 'fraction_numerical': 0.01670792079207921, 'mean_word_length': 5.30214424951267, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7134008', 'n_tokens_mistral': 1018, 'n_tokens_neox': 1001, 'n_words': 209}