<commit_before>function Board(
  boardState,
  lineColor,
  deadCellColor,
  aliveYoungCellColor,
  aliveOldCellColor,
  cellWidth,
  cellHeight,
  rowPadding,
  colPadding,
  canvas
) {

  this.onClick = function(clickHandler) {
    canvas.addEventListener('click', (e) => {
      const x = e.clientX - canvas.getBoundingClientRect().left
      const y = e.clientY - canvas.getBoundingClientRect().top
      const cellX = Math.floor(x / 14)
      const cellY = Math.floor(y / 14)
      clickHandler(cellX, cellY)
    })
  }

  this.draw = function() {
    canvasWidth = (cellWidth + rowPadding) * 50 - 2
    canvasHeight = (cellHeight + colPadding) * 30 - 2
    canvas.width = canvasWidth
    canvas.height = canvasHeight
    console.log(canvas.width, canvas.height)
    canvas.style.background =  lineColor
    canvas.style.boxShadow = '5px 5px 25px 0px rgba(46, 61, 73, 0.2)'
    this.ctx = canvas.getContext('2d')
    this.cellWidth = cellWidth
    this.cellHeight = cellHeight
    this.update(boardState)
  }


  this.update = function(state) {
    const cellColorFromState = [deadCellColor, aliveOldCellColor, aliveYoungCellColor]
    state.forEach((row, rowIndex) => {
      const y = (this.cellHeight + colPadding) * rowIndex
      row.forEach((cell, cellIndex) => {
        const x = (this.cellWidth + rowPadding) * cellIndex
        this.ctx.fillStyle = cellColorFromState[cell]
        this.ctx.fillRect(x, y, this.cellWidth, this.cellHeight)
      })
    })
  }

  this.handleResize = function(windowWidth, state) {
    const scale = windowWidth / canvasWidth
    if (scale < 1) {
      canvas.width = canvasWidth * (scale - 0.1)
      canvas.height = canvasHeight * (scale - 0.1)
      this.cellWidth = canvas.width / 50
      this.cellHeight = canvas.height / 30
      console.log(canvas.width, this.cellWidth)
      this.update(state)
    } else {
      canvas.width = canvasWidth
      canvas.height = canvasHeight
      this.cellWidth = cellWidth
      this.cellHeight = cellHeight
      this.update(state)
    }
  }
}

define(() => Board)<commit_msg>responsiveness improved<commit_after>function Board(
  boardState,
  lineColor,
  deadCellColor,
  aliveYoungCellColor,
  aliveOldCellColor,
  cellWidth,
  cellHeight,
  rowPadding,
  colPadding,
  canvas
) {

  this.onClick = function(clickHandler) {
    canvas.addEventListener('click', (e) => {
      const x = e.clientX - canvas.getBoundingClientRect().left
      const y = e.clientY - canvas.getBoundingClientRect().top
      const cellX = Math.floor(x / 14)
      const cellY = Math.floor(y / 14)
      clickHandler(cellX, cellY)
    })
  }

  this.draw = function() {
    canvasWidth = (cellWidth + rowPadding) * 50 - 2
    canvasHeight = (cellHeight + colPadding) * 30 - 2
    canvas.width = canvasWidth
    canvas.height = canvasHeight
    console.log(canvas.width, canvas.height)
    canvas.style.background =  lineColor
    canvas.style.boxShadow = '5px 5px 25px 0px rgba(46, 61, 73, 0.2)'
    this.ctx = canvas.getContext('2d')
    this.cellWidth = cellWidth
    this.cellHeight = cellHeight
    this.update(boardState)
  }


  this.update = function(state) {
    const cellColorFromState = [deadCellColor, aliveOldCellColor, aliveYoungCellColor]
    state.forEach((row, rowIndex) => {
      const y = (this.cellHeight + colPadding) * rowIndex
      row.forEach((cell, cellIndex) => {
        const x = (this.cellWidth + rowPadding) * cellIndex
        this.ctx.fillStyle = cellColorFromState[cell]
        this.ctx.fillRect(x, y, this.cellWidth, this.cellHeight)
      })
    })
  }

  this.handleResize = function(windowWidth, state) {
    const scale = windowWidth / canvasWidth
    if (scale < 1) {
      canvas.width = canvasWidth * (scale - 0.1)
      canvas.height = canvasHeight * (scale - 0.1)
      this.cellWidth = (canvas.width - (2 * 50)) / 50
      this.cellHeight = (canvas.height - (2 * 30)) / 30
      console.log(canvas.width, this.cellWidth)
      this.update(state)
    } else {
      canvas.width = canvasWidth
      canvas.height = canvasHeight
      this.cellWidth = cellWidth
      this.cellHeight = cellHeight
      this.update(state)
    }
  }
}

define(() => Board)
{'fraction_non_alphanumeric': 0.11697027804410355, 'fraction_numerical': 0.01725790987535954, 'mean_word_length': 2.828440366972477, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '6803906', 'n_tokens_mistral': 1389, 'n_tokens_neox': 1319, 'n_words': 276}