<commit_before>(function () {
  if (typeof Snakes === "undefined") {
    window.Snakes = {};
  }

  var View = Snakes.View = function (board, $el) {
    this.$el = $el;
    this.$snakeContent = this.$el.find(".snake-content");
    this.board = board;
    this.boardRows = board.numRows;
    this.boardCols = board.numCols;
    this.eatAppleEffect = [];
    this.highestScore = 0;
    this.initialize();
    this.bindHandlers();
  };
  View.SNAKEDIR = {
      "N": "head-north",
      "S": "head-south",
      "E": "head-east",
      "W": "head-west"
    };

    View.prototype.initialize = function(){
      this.setupBoard();
      this.speedOptionButton();
      this.$el.find(".highest-score").remove();
      var $highScore = $("<h3 class='highest-score'>");
      $highScore.text("Your highest score: " + this.highestScore);
      $highScore.insertBefore(this.$snakeContent);
      var $introMsg = $("<p class='intro-msg'>").text("Use Arrow Key to Move!");
      this.$el.append($introMsg);
      setTimeout(function(){
        this.$el.find(".intro-msg").remove();
      }.bind(this), 3000);
    };

    View.prototype.bindHandlers = function(){
      this.handleChooseSpeed();
      this.handlekeypress();
      this.playAgain();
    };

    View.prototype.handleChooseSpeed = function () {
      this.$snakeContent.on("click", "button.speed-option", function(event){
        event.preventDefault();
        var option = $(event.currentTarget).data("speed");
        this.board.speed = option * 1000;
        this.$snakeContent.find(".speed-choices").remove();
        this.$snakeContent.append("<h2 class='score'>Score: " + this.board.score + "<h2>");
        this.makeMove();
      }.bind(this));
    };

    View.prototype.playAgain = function(){
      this.$snakeContent.on("click", "button.play-again", function(event){
        event.preventDefault();
        this.$snakeContent.empty();
        this.board = new Snakes.Board(this.boardRows, this.boardCols);
        this.initialize();
      }.bind(this));
    };

    View.prototype.makeMove = function () {
      var intervalId = setInterval(function(){
        this.board.snake.move();
        if(this.board.generateApple()){
          this.eatAppleEffect = this.board.snake.head().neighbors(this.board);
        };
        if (!this.board.inBoard(this.board.snake.segments[0]) ||
              this.board.snake.eatSelf()) {
          this.$snakeContent.append("<h2 class='lose-msg'>Oops, You died :(</h2>");
          this.$snakeContent.append("<button class='play-again'>Play Again!</button>");
          clearInterval(intervalId);
        } else {
          this.render();
          this.renderEffect();
        }
      }.bind(this), this.board.speed);
    };

    View.prototype.setupBoard = function () {
      var $ul = $("<ul class='snake-grid group'>");
      for (var i = 0; i < this.boardRows; i++){
        for (var j = 0; j < this.boardCols; j++){
          var $li = $("<li class='grid-square'>");
          $li.attr("data-pos", [i, j]);
          $ul.append($li);
        };
      };
      $ul.css({
        "width": 30 * this.boardCols,
        "height": 30 * this.boardRows
      })
      this.$snakeContent.append($ul);
    };

    View.prototype.speedOptionButton = function(){
      var $fastOption = $("<button>").text("Master")
                                     .addClass("speed-fast speed-option")
                                     .data("speed", 0.07);<commit_msg>Remove eat apple effect<commit_after>(function () {
  if (typeof Snakes === "undefined") {
    window.Snakes = {};
  }

  var View = Snakes.View = function (board, $el) {
    this.$el = $el;
    this.$snakeContent = this.$el.find(".snake-content");
    this.board = board;
    this.boardRows = board.numRows;
    this.boardCols = board.numCols;
    this.eatAppleEffect = [];
    this.highestScore = 0;
    this.initialize();
    this.bindHandlers();
  };
  View.SNAKEDIR = {
      "N": "head-north",
      "S": "head-south",
      "E": "head-east",
      "W": "head-west"
    };

    View.prototype.initialize = function(){
      this.setupBoard();
      this.speedOptionButton();
      this.$el.find(".highest-score").remove();
      var $highScore = $("<h3 class='highest-score'>");
      $highScore.text("Your highest score: " + this.highestScore);
      $highScore.insertBefore(this.$snakeContent);
      var $introMsg = $("<p class='intro-msg'>").text("Use Arrow Key to Move!");
      this.$el.append($introMsg);
      setTimeout(function(){
        this.$el.find(".intro-msg").remove();
      }.bind(this), 3000);
    };

    View.prototype.bindHandlers = function(){
      this.handleChooseSpeed();
      this.handlekeypress();
      this.playAgain();
    };

    View.prototype.handleChooseSpeed = function () {
      this.$snakeContent.on("click", "button.speed-option", function(event){
        event.preventDefault();
        var option = $(event.currentTarget).data("speed");
        this.board.speed = option * 1000;
        this.$snakeContent.find(".speed-choices").remove();
        this.$snakeContent.append("<h2 class='score'>Score: " + this.board.score + "<h2>");
        this.makeMove();
      }.bind(this));
    };

    View.prototype.playAgain = function(){
      this.$snakeContent.on("click", "button.play-again", function(event){
        event.preventDefault();
        this.$snakeContent.empty();
        this.board = new Snakes.Board(this.boardRows, this.boardCols);
        this.initialize();
      }.bind(this));
    };

    View.prototype.makeMove = function () {
      var intervalId = setInterval(function(){
        this.board.snake.move();
        if(this.board.generateApple()){
          this.eatAppleEffect = this.board.snake.head().neighbors(this.board);
        };
        if (!this.board.inBoard(this.board.snake.segments[0]) ||
              this.board.snake.eatSelf()) {
          this.$snakeContent.append("<h2 class='lose-msg'>Oops, You died :(</h2>");
          this.$snakeContent.append("<button class='play-again'>Play Again!</button>");
          clearInterval(intervalId);
        } else {
          this.render();
          // this.renderEffect();
        }
      }.bind(this), this.board.speed);
    };

    View.prototype.setupBoard = function () {
      var $ul = $("<ul class='snake-grid group'>");
      for (var i = 0; i < this.boardRows; i++){
        for (var j = 0; j < this.boardCols; j++){
          var $li = $("<li class='grid-square'>");
          $li.attr("data-pos", [i, j]);
          $ul.append($li);
        };
      };
      $ul.css({
        "width": 30 * this.boardCols,
        "height": 30 * this.boardRows
      })
      this.$snakeContent.append($ul);
    };

    View.prototype.speedOptionButton = function(){
      var $fastOption = $("<button>").text("Master")
                                     .addClass("speed-fast speed-option")
                                     .data("speed", 0.07);
{'fraction_non_alphanumeric': 0.18415355751190648, 'fraction_numerical': 0.006927406552172031, 'mean_word_length': 2.3624454148471616, 'pattern_counts': {'":': 12, '<': 29, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6231754', 'n_tokens_mistral': 2219, 'n_tokens_neox': 2108, 'n_words': 346}