<commit_before>define(function(require) {
    'use strict';

    function MouseEventHandler() {
        this.x = null;
        this.y = null;
        this.path = [];
        this.isMouseDown = false;
    }

    MouseEventHandler.prototype.mouseDown = function(event, mouseObj) {
        mouseObj.isMouseDown = true;
        mouseObj.path.push({
            x: event.offsetX || event.layerX,
            y: event.offsetY || event.layerY
        });
        //console.log(mouseObj.isMouseDown);
    }

    MouseEventHandler.prototype.mouseUp = function(event, mouseObj) {
        mouseObj.isMouseDown = false;
        this.path = [];
        //console.log(mouseObj.isMouseDown);
    };

    MouseEventHandler.prototype.updateCoords = function(event, mouseObj, updateInterval) {
        if (mouseObj.isMouseDown) {
            event = event || window.event;
            if (mouseObj.path.length > 7) {
                mouseObj.path.shift();
            }

            mouseObj.path.push({
                x: event.offsetX || event.layerX,
                y: event.offsetY || event.layerY
            });
        }
    };

    MouseEventHandler.prototype.getCoords = function() {
        if (this.x == null || this.y == null) {
            throw {
                message: 'Coordinates are not set yet',
                name: 'NullCoordinatesException'
            }
        }

        var coords = (function(x, y) {
            return {
                x: x,
                y: y
            }
        })(this.x, this.y);

        console.log(coords);

        return coords;
    };

    return MouseEventHandler;
});<commit_msg>Bugfix: The drawn path did not change (get shorter) when mouse is not moved. Add a timer that makes it shorter every 100ms.<commit_after>define(function (require) {
    'use strict';

    function MouseEventHandler() {
        this.x = null;
        this.y = null;
        this.path = [];
        this.isMouseDown = false;
    }

    MouseEventHandler.prototype.mouseDown = function (event, mouseObj) {
        mouseObj.isMouseDown = true;
        mouseObj.path.push({
            x: event.offsetX || event.layerX,
            y: event.offsetY || event.layerY
        });
        //console.log(mouseObj.isMouseDown);
    }

    MouseEventHandler.prototype.mouseUp = function (event, mouseObj) {
        mouseObj.isMouseDown = false;
        this.path = [];
        //console.log(mouseObj.isMouseDown);
    };

    var timeoutID = null;

    function mouseMoveTimeOut(mouseObj) {
        console.log('mtimeout 1');
        mouseObj.path.shift();
        console.log('mtimeout 2');
        if (mouseObj.path.length != 0)
            timeoutID = setTimeout(function () {
                mouseMoveTimeOut(mouseObj);
            }, 100);
        else
            timeoutID = null;
    }

    MouseEventHandler.prototype.updateCoords = function (event, mouseObj, updateInterval) {
        if (mouseObj.isMouseDown) {
            if (timeoutID !== null) {
                clearTimeout(timeoutID);
            }
            timeoutID = setTimeout(function () {
                mouseMoveTimeOut(mouseObj);
            }, 100);

            event = event || window.event;
            if (mouseObj.path.length > 10) {
                mouseObj.path.shift();
            }

            mouseObj.path.push({
                x: event.offsetX || event.layerX,
                y: event.offsetY || event.layerY
            });
        }
    };

    MouseEventHandler.prototype.getCoords = function () {
        if (this.x == null || this.y == null) {
            throw {
                message: 'Coordinates are not set yet',
                name: 'NullCoordinatesException'
            }
        }

        var coords = (function (x, y) {
            return {
                x: x,
                y: y
            }
        })(this.x, this.y);

        console.log(coords);

        return coords;
    };

    return MouseEventHandler;
});
{'fraction_non_alphanumeric': 0.11645569620253164, 'fraction_numerical': 0.0037974683544303796, 'mean_word_length': 1.578981723237598, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3515640', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1086, 'n_words': 223}