<commit_before>$(function() {
    // Check if line highlighting is needed
    if(!$('.logs:not(.tailing)').length) {
        return;
    }

    var activeLines = [],
        containsLine = function(line) {
            return activeLines.indexOf(line) != -1;
        },
        /**
         * @param line
         */
        addLine = function(line) {
            // we don't want zero
            if(line === 0) {
                return;
            }

            // only add if not already in array
            if(activeLines.indexOf(line) == -1) {
                activeLines.push(line);
            }

            // add class
            $(".logs .line[data-line-num='" + line + "']").addClass('highlighted');
        },
        /**
         * @param line
         */
        removeLine = function(line) {
            // remove line from array
            var index;
            if((index = activeLines.indexOf(line)) > -1) {
                activeLines.splice(index, 1);
            }

            // remove class
            $(".logs .line[data-line-num='" + line + "']").removeClass('highlighted');
        },
        /**
         * @returns {string}
         */
        createHash = function() {
            var result = 'L'; // hash (#) is automatically added
            var first = true;

            activeLines.forEach(function(entry) {
                if(!first) {
                    result += ',';
                }

                first = false;
                result += entry;
            });

            return result;
        },
        hashChange = function() {
            $('.logs .line').removeClass('highlighted');

            var hash = window.location.hash;

            var remainingPart = hash.substr(0, 2);
            if(remainingPart == "#L") {
                if($('.logs').length !== 0) {
                    var remainingParts = hash.substr(2).split(',');
                    for(var i = 0; i < remainingParts.length; i++) {
                        var part = remainingParts[i];

                        if(part.indexOf('-') !== -1) {
                            var re = /([0-9]+)-([0-9]+)/;
                            var match = re.exec(part);
                            if(match.length === 3) {
                                var imin = Number(match[1]);
                                var imax = Number(match[2]);
                                if(imin > imax) {
                                    var tempMax = imax;
                                    imax = imin;
                                    imin = tempMax;
                                }
                                for(var j = imin; j <= imax; j++) {
                                    addLine(j);
                                }
                            }
                        } else {
                            var lineNum = Number(part);
                            if(!isNaN(lineNum)) {
                                addLine(lineNum);
                            }
                        }
                    }
                }
            }
        },
        jumpToFirstLine = function() {
            if(activeLines.length > 0) {
                var shift = Math.min.apply(Math, activeLines);
                var elem = $(".logs .line[data-line-num='" + shift + "']");
                $(window).scrollTop(elem.offset().top - 0.33 * $(window).height());
            }
        };

    // listen for hash changes
    $(window).on('hashchange', function() {
        hashChange();
    });

    // Allow lines to be highlighted by clicking the timestamp next to the log line.
    // The behaviour for clicks is as follows:
    // - Click:
    // ---- highlight single line, un-highlighting any existing highlighted lines
    // - Ctrl + Click:
    // ---- add or remove (if line is already highlighted) a line
    // - Shift + Click:
    // ---- add/remove highlighting to a group of lines
    $(document).on('mousedown', '.logs .timestamp', function(event) {
        event.preventDefault();

        // climb the dom to .line
        var line = $(this).closest('.line').data('line-num');

        // If ctrl/command is being held while clicking, either highlight the line or remove
        // existing highlighting from the line.
        if(event.ctrlKey || event.metaKey) {
            // If the line is already highlighted, remove highlighting
            if(activeLines.indexOf(line) != -1) {
                removeLine(line);
            } else {
                addLine(line);
            }
        } else if(event.shiftKey) {
            // We'll assume the user wants to select a range here

            // I'm arbitrarily deciding that a range will be made up of the last line they added to the list
            // and the line they're clicking now.

            var lastLine = activeLines[activeLines.length - 1];
            if(activeLines.length <= 0) {
                return;
            } else if(containsLine(line)) {
                return;<commit_msg>Don't highlight lines on right click<commit_after>$(function() {
    // Check if line highlighting is needed
    if(!$('.logs:not(.tailing)').length) {
        return;
    }

    var activeLines = [],
        containsLine = function(line) {
            return activeLines.indexOf(line) != -1;
        },
        /**
         * @param line
         */
        addLine = function(line) {
            // we don't want zero
            if(line === 0) {
                return;
            }

            // only add if not already in array
            if(activeLines.indexOf(line) == -1) {
                activeLines.push(line);
            }

            // add class
            $(".logs .line[data-line-num='" + line + "']").addClass('highlighted');
        },
        /**
         * @param line
         */
        removeLine = function(line) {
            // remove line from array
            var index;
            if((index = activeLines.indexOf(line)) > -1) {
                activeLines.splice(index, 1);
            }

            // remove class
            $(".logs .line[data-line-num='" + line + "']").removeClass('highlighted');
        },
        /**
         * @returns {string}
         */
        createHash = function() {
            var result = 'L'; // hash (#) is automatically added
            var first = true;

            activeLines.forEach(function(entry) {
                if(!first) {
                    result += ',';
                }

                first = false;
                result += entry;
            });

            return result;
        },
        hashChange = function() {
            $('.logs .line').removeClass('highlighted');

            var hash = window.location.hash;

            var remainingPart = hash.substr(0, 2);
            if(remainingPart == "#L") {
                if($('.logs').length !== 0) {
                    var remainingParts = hash.substr(2).split(',');
                    for(var i = 0; i < remainingParts.length; i++) {
                        var part = remainingParts[i];

                        if(part.indexOf('-') !== -1) {
                            var re = /([0-9]+)-([0-9]+)/;
                            var match = re.exec(part);
                            if(match.length === 3) {
                                var imin = Number(match[1]);
                                var imax = Number(match[2]);
                                if(imin > imax) {
                                    var tempMax = imax;
                                    imax = imin;
                                    imin = tempMax;
                                }
                                for(var j = imin; j <= imax; j++) {
                                    addLine(j);
                                }
                            }
                        } else {
                            var lineNum = Number(part);
                            if(!isNaN(lineNum)) {
                                addLine(lineNum);
                            }
                        }
                    }
                }
            }
        },
        jumpToFirstLine = function() {
            if(activeLines.length > 0) {
                var shift = Math.min.apply(Math, activeLines);
                var elem = $(".logs .line[data-line-num='" + shift + "']");
                $(window).scrollTop(elem.offset().top - 0.33 * $(window).height());
            }
        };

    // listen for hash changes
    $(window).on('hashchange', function() {
        hashChange();
    });

    // Allow lines to be highlighted by clicking the timestamp next to the log line.
    // The behaviour for clicks is as follows:
    // - Click:
    // ---- highlight single line, un-highlighting any existing highlighted lines
    // - Ctrl + Click:
    // ---- add or remove (if line is already highlighted) a line
    // - Shift + Click:
    // ---- add/remove highlighting to a group of lines
    $(document).on('click', '.logs .timestamp', function(event) {
        event.preventDefault();

        // climb the dom to .line
        var line = $(this).closest('.line').data('line-num');

        // If ctrl/command is being held while clicking, either highlight the line or remove
        // existing highlighting from the line.
        if(event.ctrlKey || event.metaKey) {
            // If the line is already highlighted, remove highlighting
            if(activeLines.indexOf(line) != -1) {
                removeLine(line);
            } else {
                addLine(line);
            }
        } else if(event.shiftKey) {
            // We'll assume the user wants to select a range here

            // I'm arbitrarily deciding that a range will be made up of the last line they added to the list
            // and the line they're clicking now.

            var lastLine = activeLines[activeLines.length - 1];
            if(activeLines.length <= 0) {
                return;
            } else if(containsLine(line)) {
                return;
{'fraction_non_alphanumeric': 0.12488787002890461, 'fraction_numerical': 0.004983554270906011, 'mean_word_length': 1.0982852363028022, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6346790', 'n_tokens_mistral': 2571, 'n_tokens_neox': 2409, 'n_words': 642}