<commit_before>if (typeof diff_match_patch !== 'undefined') {
    diff_match_patch.prototype.diff_prettyHtml = function(diffs) {
        /* An override of prettyHthml from diff_match_patch. This
           one will not put any style attrs in the ins or del. */
        var html = [];
        var k = 1, // Line numbers of existing or added lines.
            dk = 1; // Line numbers of deleted lines.
        for (var x = 0; x < diffs.length; x++) {
            var op = diffs[x][0];    // Operation (insert, delete, equal)
            var data = diffs[x][1];  // Text of change.
            var text = data.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
            /* As as side effect, add in line numbers */
            var lines = text.split('\n');
            if (lines[lines.length-1] === '') {
                lines.pop();
            }
            if (lines[0] === '') {
                lines.splice(0, 1);
            }
            for (var t = 0; t < lines.length; t++) {
                switch (op) {
                    case DIFF_INSERT:
                        // TODO (andym): templates might work here as suggested by cvan
                        html.push(format('<div class="line add"><span class="number"><a href="#L{0}" name="L{0}">{0}</a> +' +
                                         '</span><span class="code">{1}</span></div>', k++, lines[t]));
                        break;
                    case DIFF_DELETE:
                        html.push(format('<div class="line delete"><span class="number"><a href="#D{0}" name="D{0}"></a> -</span>' +
                                         '<span class="code">{1}</span></div>', dk++, lines[t]));
                        break;
                    case DIFF_EQUAL:
                        html.push(format('<div class="line"><span class="number"><a href="#L{0}" name="L{0}">{0}</a>&nbsp;&nbsp;' +
                                         '</span><span class="code">{1}</span></div>', k++, lines[t]));
                        break;
                }
            }
        }
        return html.join('');
    };
}

function bind_viewer(nodes) {
    function Viewer() {
        this.nodes = nodes;
        this.wrapped = true;
        this.hidden = false;
        this.fix_vertically = function($inner, $outer) {
            function update() {
                var $sb_top = $outer.position().top,
                    $sb_bottom = $sb_top + $outer.height() - $inner.height();

                if ($(window).scrollTop() > $sb_bottom) {
                    $inner.css({'position': 'absolute', 'top': $sb_bottom});
                } else if ($(window).scrollTop() > $sb_top) {
                    $inner.css({'position': 'fixed', 'top': 0});
                } else {
                    $inner.css({'position': 'absolute', 'top': $sb_top});
                }
            }
            $(window).scroll(debounce(update), 200);
            update();
        };
        this.compute = function(node) {
            var $content = node.find('#content'),
                $diff = node.find('#diff');
            if ($content.length) {
                var splitted = $content.text().split('\n'),
                    length = splitted.length,
                    html = [];
                if (splitted.slice(length-1) == '') {
                    length = length - 1;
                }
                for (var k = 0; k < length; k++) {
                    if (splitted[k] !== undefined) {
                        var text = splitted[k].replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
                        html.push(format('<div class="line"><span class="number"><a href="#L{0}" name="L{0}">{0}</a></span>' +
                                         '<span class="code"> {1}</span></div>', k+1, text));
                    }
                }
                $content.html(html.join('')).show();
            }

            if ($diff.length) {
                var dmp = new diff_match_patch();
                // Line diffs http://code.google.com/p/google-diff-match-patch/wiki/LineOrWordDiffs
                var a = dmp.diff_linesToChars_($diff.siblings('.left').text(), $diff.siblings('.right').text());
                var diffs = dmp.diff_main(a[0], a[1], false);
                dmp.diff_charsToLines_(diffs, a[2]);
                $diff.html(dmp.diff_prettyHtml(diffs)).show();

                var $sb = $diff.siblings('.diff-bar').eq(0);
                var $lines = $diff.find('.line');
                var state = {'start':1, 'type':$lines.eq(0).attr('class'),
                             'href':$lines.eq(0).find('a').attr('href')};
                for (var j = 1; j < $lines.length; j++) {
                    var $node = $lines.eq(j);
                    if ($node.attr('class') != state.type) {
                        this.side_bar_append($sb, state, j, $lines.length);
                        state = {'start': j, 'type': $node.attr('class'),
                                 'href': $node.find('a').attr('href')};
                    }
                }
                this.side_bar_append($sb, state, j, $lines.length);
                this.fix_vertically($sb, $diff);
                $sb.show();
            }

            if (!window.location.hash) {
                window.location.hash = 'top';
            }
            window.location = window.location;<commit_msg>getting different answers for .position, but only need to calculate it once anyway<commit_after>if (typeof diff_match_patch !== 'undefined') {
    diff_match_patch.prototype.diff_prettyHtml = function(diffs) {
        /* An override of prettyHthml from diff_match_patch. This
           one will not put any style attrs in the ins or del. */
        var html = [];
        var k = 1, // Line numbers of existing or added lines.
            dk = 1; // Line numbers of deleted lines.
        for (var x = 0; x < diffs.length; x++) {
            var op = diffs[x][0];    // Operation (insert, delete, equal)
            var data = diffs[x][1];  // Text of change.
            var text = data.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
            /* As as side effect, add in line numbers */
            var lines = text.split('\n');
            if (lines[lines.length-1] === '') {
                lines.pop();
            }
            if (lines[0] === '') {
                lines.splice(0, 1);
            }
            for (var t = 0; t < lines.length; t++) {
                switch (op) {
                    case DIFF_INSERT:
                        // TODO (andym): templates might work here as suggested by cvan
                        html.push(format('<div class="line add"><span class="number"><a href="#L{0}" name="L{0}">{0}</a> +' +
                                         '</span><span class="code">{1}</span></div>', k++, lines[t]));
                        break;
                    case DIFF_DELETE:
                        html.push(format('<div class="line delete"><span class="number"><a href="#D{0}" name="D{0}"></a> -</span>' +
                                         '<span class="code">{1}</span></div>', dk++, lines[t]));
                        break;
                    case DIFF_EQUAL:
                        html.push(format('<div class="line"><span class="number"><a href="#L{0}" name="L{0}">{0}</a>&nbsp;&nbsp;' +
                                         '</span><span class="code">{1}</span></div>', k++, lines[t]));
                        break;
                }
            }
        }
        return html.join('');
    };
}

function bind_viewer(nodes) {
    function Viewer() {
        this.nodes = nodes;
        this.wrapped = true;
        this.hidden = false;
        this.top = null;
        this.fix_vertically = function($inner, $outer) {
            var $self = this;
            if (!$self.top) {
                $self.top = $outer.position().top;
            }
            function update() {
                var sb_bottom = $self.top + $outer.height() - $inner.height();
                if ($(window).scrollTop() > sb_bottom) {
                    $inner.css({'position': 'absolute', 'top': sb_bottom});
                } else if ($(window).scrollTop() > $self.top) {
                    $inner.css({'position': 'fixed', 'top': 0});
                } else {
                    $inner.css({'position': 'absolute', 'top': $self.top});
                }
            }
            $(window).scroll(debounce(update), 200);
            update();
        };
        this.compute = function(node) {
            var $content = node.find('#content'),
                $diff = node.find('#diff');
            if ($content.length) {
                var splitted = $content.text().split('\n'),
                    length = splitted.length,
                    html = [];
                if (splitted.slice(length-1) == '') {
                    length = length - 1;
                }
                for (var k = 0; k < length; k++) {
                    if (splitted[k] !== undefined) {
                        var text = splitted[k].replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
                        html.push(format('<div class="line"><span class="number"><a href="#L{0}" name="L{0}">{0}</a></span>' +
                                         '<span class="code"> {1}</span></div>', k+1, text));
                    }
                }
                $content.html(html.join('')).show();
            }

            if ($diff.length) {
                var dmp = new diff_match_patch();
                // Line diffs http://code.google.com/p/google-diff-match-patch/wiki/LineOrWordDiffs
                var a = dmp.diff_linesToChars_($diff.siblings('.left').text(), $diff.siblings('.right').text());
                var diffs = dmp.diff_main(a[0], a[1], false);
                dmp.diff_charsToLines_(diffs, a[2]);
                $diff.html(dmp.diff_prettyHtml(diffs)).show();

                var $sb = $diff.siblings('.diff-bar').eq(0);
                var $lines = $diff.find('.line');
                var state = {'start':0, 'type':$lines.eq(0).attr('class'),
                             'href':$lines.eq(0).find('a').attr('href')};
                for (var j = 1; j < $lines.length; j++) {
                    var $node = $lines.eq(j);
                    if ($node.attr('class') != state.type) {
                        this.side_bar_append($sb, state, j, $lines.length);
                        state = {'start': j, 'type': $node.attr('class'),
                                 'href': $node.find('a').attr('href')};
                    }
                }
                this.side_bar_append($sb, state, j, $lines.length);
                this.fix_vertically($sb, $diff);
                $sb.show();
            }

            if (!window.location.hash) {
                window.location.hash = 'top';
            }
            window.location = window.location;
{'fraction_non_alphanumeric': 0.1759766338079591, 'fraction_numerical': 0.007484483388097846, 'mean_word_length': 1.3685689580631215, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2100813', 'n_tokens_mistral': 3158, 'n_tokens_neox': 3011, 'n_words': 636}