<commit_before>function TimelineController(timelineDataService, $location, $element, $scope) {

    var _this = this;

    // These variables should be constant variables. Set to var because of an error with safari.
    var margin = 15;
    var maxZoomYears = 5;
    var minStartYear = -10000;
    var maxStartYear = new Date().getFullYear();
    var barHeight = 20;
    var buttonZoomFactor = 0.5;
    // -------

    var timeline;
    var canvas;
    var axis, axisElement;
    var bars, barRects, barTexts;
    var tooltip;
    var zoom, drag;
    var x, y;

    var timelineData;

    var totalXDomain = [];
    var startXDomain = [];
    var startYDomain = [];

    var width;
    var height;

    var initialized = false;

    d3.select(window).on('resize', _this.resize);

    this.$onChanges = function() {
        if (this.periods) this.initialize();
    };

    this.initialize = function() {

        width = this.getWidth();                  // Größe des zur Verfügung stehenden Fensters
        height = this.getHeight();

        y = d3.scale.linear()                    // y-Skala erstellen
            .domain([0, barHeight * 20])         // Anzahl Hierarchie-Ebenen
            .range([0, parseInt(height) - 30]);  // auf welcher Pixel-Fläche, minus Skalenbeschriftung

        timelineData = timelineDataService.getTimelineData(this.periods);
        totalXDomain = timelineData.xDomain;

        this.setStartDomains(timelineData.periodsMap);

        x = d3.scale.linear()
            .domain(startXDomain)                // z.B. -10.000 bis 2000 n.Chr.
            .range([0, parseInt(width)]);        // auf welcher Pixel-Fläche

        y.domain(startYDomain);

        timeline = d3.select('#timeline').append('svg')
            .attr('width', parseInt(width))
            .attr('height', parseInt(height))
            .classed('timeline', true);

        if (this.inactive) timeline.classed('inactive', true);

        canvas = timeline.append('svg')
            .attr('width', parseInt(width))
            .attr('height', parseInt(height) - 30);

        axis = d3.svg.axis()                    // Skalenbeschriftung
            .scale(x)
            .orient('bottom')
            .ticks(parseInt(this.axisTicks))                           // Anzahl Skalenschritte
            .tickSize(10, 0);

        axisElement = timeline.append('svg')
            .attr('y', parseInt(height) - 30)
            .attr('width', parseInt(width))
            .classed('axis', true)
            .call(axis);


        if (!this.inactive) {
            var minZoom = (startXDomain[1] - startXDomain[0])
                / (totalXDomain[1] - totalXDomain[0]);
            var maxZoom = (startXDomain[1] - startXDomain[0]) / maxZoomYears;

            zoom = d3.behavior.zoom()
                .x(x)
                .scaleExtent([minZoom, maxZoom])
                .on('zoom', function () {
                    axisElement.call(axis);
                    _this.updateBars();              // aktualisiert die Achsen, nochmal neu gemalt
                });

            drag = d3.behavior.drag()
                .on('drag', function () {
                    var domain = y.domain();
                    domain[0] -= d3.event.dy;     // Verschiebung unten/oben
                    domain[1] -= d3.event.dy;
                    y.domain(domain);
                    axisElement.call(axis);
                    _this.updateBars();
                });

            timeline.call(zoom).call(drag);

            tooltip = d3.select('body')
                .append('div')
                .classed('timeline-tooltip', true);
        }

        bars = canvas.selectAll('g').data(timelineData.periods).enter(); // bar = Rechteck von einer Period, bars = alle diese Rechtecke
        barRects = bars.append('g')
            .attr('class', function(d) { // CSS class für richtige Farbe und Helligkeit
                var barClass = 'bar level' + (d.level + 1);
                if (_this.inactive) {
                    barClass += ' inactive';
                } else {
                    barClass += ' group' + d.colorGroup;
                }
                return barClass;
            })
            .append('rect')
            .attr('rx', '5')
            .attr('ry', '5');
        if (!this.inactive) barRects.on('click', _this.showPeriod);
        this.addTooltipBehavior(barRects);

        if (this.selectedPeriodId) {
            barRects.filter(function (d) {
                return d.id == _this.selectedPeriodId;
            }).classed('selected', true);
        }

        barTexts = canvas.selectAll('g')
            .append('text')
            .classed('text', true)
            .on('click', _this.showPeriod);
        if (this.inactive) barTexts.classed('inactive', true);
        this.addTooltipBehavior(barTexts, tooltip);

        this.updateBars();

        initialized = true;
    };

    this.resize = function() {

        if (!initialized) return;

        var width = this.getWidth();
        var height = this.getHeight();

        y.range([0, parseInt(height) - 30]);
        x.range([0, parseInt(width)]);

        timeline.attr('width', parseInt(width))
            .attr('height', parseInt(height));

        canvas.attr('width', parseInt(width))
            .attr('height', parseInt(height) - 30);

        axisElement.attr('width', parseInt(width));
        axisElement.call(axis);

        this.updateBars();
    };

    this.getWidth = function() {
        return $element[0].parentNode.clientWidth - margin; // margin: für weiße Ränder
    };<commit_msg>fix bug during mousemove events on inactive timeline<commit_after>function TimelineController(timelineDataService, $location, $element, $scope) {

    var _this = this;

    // These variables should be constant variables. Set to var because of an error with safari.
    var margin = 15;
    var maxZoomYears = 5;
    var minStartYear = -10000;
    var maxStartYear = new Date().getFullYear();
    var barHeight = 20;
    var buttonZoomFactor = 0.5;
    // -------

    var timeline;
    var canvas;
    var axis, axisElement;
    var bars, barRects, barTexts;
    var tooltip;
    var zoom, drag;
    var x, y;

    var timelineData;

    var totalXDomain = [];
    var startXDomain = [];
    var startYDomain = [];

    var width;
    var height;

    var initialized = false;

    d3.select(window).on('resize', _this.resize);

    this.$onChanges = function() {
        if (this.periods) this.initialize();
    };

    this.initialize = function() {

        width = this.getWidth();                  // Größe des zur Verfügung stehenden Fensters
        height = this.getHeight();

        y = d3.scale.linear()                    // y-Skala erstellen
            .domain([0, barHeight * 20])         // Anzahl Hierarchie-Ebenen
            .range([0, parseInt(height) - 30]);  // auf welcher Pixel-Fläche, minus Skalenbeschriftung

        timelineData = timelineDataService.getTimelineData(this.periods);
        totalXDomain = timelineData.xDomain;

        this.setStartDomains(timelineData.periodsMap);

        x = d3.scale.linear()
            .domain(startXDomain)                // z.B. -10.000 bis 2000 n.Chr.
            .range([0, parseInt(width)]);        // auf welcher Pixel-Fläche

        y.domain(startYDomain);

        timeline = d3.select('#timeline').append('svg')
            .attr('width', parseInt(width))
            .attr('height', parseInt(height))
            .classed('timeline', true);

        if (this.inactive) timeline.classed('inactive', true);

        canvas = timeline.append('svg')
            .attr('width', parseInt(width))
            .attr('height', parseInt(height) - 30);

        axis = d3.svg.axis()                    // Skalenbeschriftung
            .scale(x)
            .orient('bottom')
            .ticks(parseInt(this.axisTicks))                           // Anzahl Skalenschritte
            .tickSize(10, 0);

        axisElement = timeline.append('svg')
            .attr('y', parseInt(height) - 30)
            .attr('width', parseInt(width))
            .classed('axis', true)
            .call(axis);


        if (!this.inactive) {
            var minZoom = (startXDomain[1] - startXDomain[0])
                / (totalXDomain[1] - totalXDomain[0]);
            var maxZoom = (startXDomain[1] - startXDomain[0]) / maxZoomYears;

            zoom = d3.behavior.zoom()
                .x(x)
                .scaleExtent([minZoom, maxZoom])
                .on('zoom', function () {
                    axisElement.call(axis);
                    _this.updateBars();              // aktualisiert die Achsen, nochmal neu gemalt
                });

            drag = d3.behavior.drag()
                .on('drag', function () {
                    var domain = y.domain();
                    domain[0] -= d3.event.dy;     // Verschiebung unten/oben
                    domain[1] -= d3.event.dy;
                    y.domain(domain);
                    axisElement.call(axis);
                    _this.updateBars();
                });

            timeline.call(zoom).call(drag);

            tooltip = d3.select('body')
                .append('div')
                .classed('timeline-tooltip', true);
        }

        bars = canvas.selectAll('g').data(timelineData.periods).enter(); // bar = Rechteck von einer Period, bars = alle diese Rechtecke
        barRects = bars.append('g')
            .attr('class', function(d) { // CSS class für richtige Farbe und Helligkeit
                var barClass = 'bar level' + (d.level + 1);
                if (_this.inactive) {
                    barClass += ' inactive';
                } else {
                    barClass += ' group' + d.colorGroup;
                }
                return barClass;
            })
            .append('rect')
            .attr('rx', '5')
            .attr('ry', '5');
        if (!this.inactive) {
            barRects.on('click', _this.showPeriod);
            this.addTooltipBehavior(barRects);
        }

        if (this.selectedPeriodId) {
            barRects.filter(function (d) {
                return d.id == _this.selectedPeriodId;
            }).classed('selected', true);
        }

        barTexts = canvas.selectAll('g')
            .append('text')
            .classed('text', true)
            .on('click', _this.showPeriod);
        if (this.inactive) {
            barTexts.classed('inactive', true);
        } else {
            this.addTooltipBehavior(barTexts);
        }

        this.updateBars();

        initialized = true;
    };

    this.resize = function() {

        if (!initialized) return;

        var width = this.getWidth();
        var height = this.getHeight();

        y.range([0, parseInt(height) - 30]);
        x.range([0, parseInt(width)]);

        timeline.attr('width', parseInt(width))
            .attr('height', parseInt(height));

        canvas.attr('width', parseInt(width))
            .attr('height', parseInt(height) - 30);

        axisElement.attr('width', parseInt(width));
        axisElement.call(axis);

        this.updateBars();
    };

    this.getWidth = function() {
        return $element[0].parentNode.clientWidth - margin; // margin: für weiße Ränder
    };
{'fraction_non_alphanumeric': 0.13466489125610298, 'fraction_numerical': 0.01118508655126498, 'mean_word_length': 1.6633569739952718, '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': '7569472', 'n_tokens_mistral': 3369, 'n_tokens_neox': 3180, 'n_words': 669}