<commit_before>/*jslint browser: true */

var domready = require('domready');

var Canvas = require('./canvas');
var Board = require('./board');
var Display = require('./display');
var Mouse = require('./mouse');

var config = {
    columns: 10,
    rows: 10,
    cellSize: 30,  // pixels
    timer: 500     // miliseconds
};

var appState = {
    mouseColumn: -1,
    mouseRow: -1
};

var board = Board.createRandom(config.columns, config.rows);

domready(function () {
    var canvas = Canvas.create(
        document.getElementById("canvas"),
        config.columns,
        config.rows,
        config.cellSize
    );

    canvas.element.width = (config.columns * config.cellSize);
    canvas.element.height = (config.rows * config.cellSize);
    canvas.element.addEventListener('mousemove', function (e) {
        Mouse.position(canvas, e, function (x, y) {
            var c = Math.floor(x / canvas.cellSize);
            var r = Math.floor(y / canvas.cellSize);
            appState.mouseColumn = c;
            appState.mouseRow = r;
        });
    });

    var animate = function () {
        Display.drawBoard(canvas, board, appState);
        board = Board.nextGeneration(board);
    };

    setInterval(animate, config.timer);
});
<commit_msg>Adding handlers for clicking and mouseout<commit_after>/*jslint browser: true */

var domready = require('domready');

var Canvas = require('./canvas');
var Board = require('./board');
var Display = require('./display');
var Mouse = require('./mouse');

var config = {
    columns: 20,
    rows: 10,
    cellSize: 30,  // pixels
    timer: 500     // miliseconds
};

var appState = {
    mouseColumn: -1,
    mouseRow: -1
};

var board = Board.createRandom(config.columns, config.rows);

domready(function () {
    var canvas = Canvas.create(
        document.getElementById("canvas"),
        config.columns,
        config.rows,
        config.cellSize
    );

    canvas.element.width = (config.columns * config.cellSize);
    canvas.element.height = (config.rows * config.cellSize);

    canvas.element.addEventListener('mousemove', function (e) {
        Mouse.position(canvas, e, function (x, y) {
            var c = Math.floor(x / canvas.cellSize);
            var r = Math.floor(y / canvas.cellSize);
            appState.mouseColumn = c;
            appState.mouseRow = r;
        });
    });

    canvas.element.addEventListener('mouseout', function (e) {
        appState.mouseColumn = -1;
        appState.mouseRow = -1;
    });

    canvas.element.addEventListener('click', function (e) {
        Mouse.position(canvas, e, function (x, y) {
            var c = Math.floor(x / canvas.cellSize);
            var r = Math.floor(y / canvas.cellSize);
            Board.setCell(board, c, r, 1);
        });
    });

    var animate = function () {
        Display.drawBoard(canvas, board, appState);
        board = Board.nextGeneration(board);
    };

    setInterval(animate, config.timer);
});

{'fraction_non_alphanumeric': 0.14584740040513167, 'fraction_numerical': 0.008440243079000676, 'mean_word_length': 2.453379953379953, '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': '5139311', 'n_tokens_mistral': 899, 'n_tokens_neox': 864, 'n_words': 200}