<commit_before>var Gol = Gol || {};

(function() {
  'use strict';

  /*
   * A proper modulus operator.
   */
  Number.prototype.mod = function(n) {
    return ((this % n) + n) % n;
  };

  /*
   * A mouse object, which maintains an internal state and is responsible for
   * attaching the relevant mouse event handlers.
   */
  var Mouse = function() {
    this.x = 0,
    this.y = 0,
    this.leftDown = false;

    /*
     * Given a mouse object, create a new cell if the mouse is positioned over a
     * cell.
     */
    function spawnCellUnderMouse(mouse) {

      /*
       * Returns the cell at the mouse point, or null if the mouse is not over
       * one.
       */
      function getCellAtMouse(mouse) {
        /* Get the i, j coordinates of the cell. */
        var col = Math.floor((mouse.x - tile.offX) / (tile.size + tile.margin));
        var row = Math.floor((mouse.y - tile.offY) / (tile.size + tile.margin));

        /* Return nothing if the coordinates are invalid */
        if (col > grid.w || col < 0 || row > grid.h || row < 0)
          return null;

        /* Return the cell */
        return cells[row * grid.w + col];
      }

      var cell = getCellAtMouse(mouse);

      if (cell !== null)
        cell.spawn();
    }

    /* Event listeners */
    canvas.addEventListener('mousemove', function(event) {
      this.x = event.clientX - bounds.left;
      this.y = event.clientY - bounds.top;

      if (this.leftDown)
        spawnCellUnderMouse(this);
    }, false);

    canvas.addEventListener('mousedown', function(event) {
      if (event.button == 0) {
        this.leftDown = true;
        spawnCellUnderMouse(this);
      } else if (event.button == 2)
        paused = true;
    }, false);

    canvas.addEventListener('mouseup', function(event) {
      if (event.button == 0)
        this.leftDown = false;
      else if (event.button == 2)<commit_msg>gol: JavaScript refactors<commit_after>var Gol = Gol || {};

(function() {
  'use strict';

  /*
   * A proper modulus operator.
   */
  Number.prototype.mod = function(n) {
    return ((this % n) + n) % n;
  };

  /*
   * A mouse object, which maintains an internal state and is responsible for
   * attaching the relevant mouse event handlers.
   */
  var Mouse = function() {
    this.x = 0,
    this.y = 0,
    this.leftDown = false;

    /*
     * Create a new cell if the mouse is positioned over a cell.
     */
    function spawnCell(mouse) {
      var cell;

      /*
       * Returns the cell at the mouse point, or null if the mouse is not over
       * one.
       */
      function getCellAtPos(x, y) {
        /* Get the i, j coordinates of the cell. */
        var col = Math.floor((x - tile.offX) / (tile.size + tile.margin));
        var row = Math.floor((y - tile.offY) / (tile.size + tile.margin));

        /* Return nothing if the coordinates are invalid */
        if (col > grid.w || col < 0 || row > grid.h || row < 0)
          return null;

        /* Return the cell */
        return cells[row * grid.w + col];
      }

      /* Spawn a cell if possible. */
      if ((cell = getCellAtPos(mouse.x, mouse.y)) !== null)
        cell.spawn();
    };

    /* Event listeners */
    canvas.addEventListener('mousemove', function(event) {
      this.x = event.clientX - bounds.left;
      this.y = event.clientY - bounds.top;

      if (this.leftDown)
        spawnCell(this);
    }, false);

    canvas.addEventListener('mousedown', function(event) {
      if (event.button == 0) {
        this.leftDown = true;
        spawnCell(this);
      } else if (event.button == 2)
        paused = true;
    }, false);

    canvas.addEventListener('mouseup', function(event) {
      if (event.button == 0)
        this.leftDown = false;
      else if (event.button == 2)
{'fraction_non_alphanumeric': 0.1345492994977531, 'fraction_numerical': 0.0042294475284166, 'mean_word_length': 1.9984152139461173, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1619993', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1139, 'n_words': 348}