<commit_before>$(document).ready(function() {
    $(".search-box").on("input", function(){
        var val = $(this).val().toLowerCase();

        var notags = [];
        var nomatches = val.match(/notag:\w+/g);
        if (nomatches) {
            $.each(nomatches, function(k, v) {
                notags.push(v.substring(6).toLowerCase());
            });
        }
        val = $.trim(val.replace(/\s*notag:\w+/g, ""));

        var tags = [];

        var show_online = false;
        var show_offline = false;

        var matches = val.match(/tag:\w+/g);
        if (matches) {
            $.each(matches, function(k, v) {
                var tag = v.substring(4).toLowerCase();
                if (tag == "online") {
                    show_online = true;
                }
                else if (tag == "offline") {
                    show_offline = true;
                }
                else {
                    tags.push(tag);
                }
            });
        }
        val = $.trim(val.replace(/\s*tag:\w+/g, ""));

        matches = val.match(/type:\w+/g);
        var types = [];
        if (matches) {
            $.each(matches, function(k, v) {
                types.push(v.substring(5).toLowerCase());
            });
        }
        val = $.trim(val.replace(/\s*type:\w+/g, ""));

        var search_objects = $(this).data("search");
        var search_fields = $(this).data("fields").split(",");
        $(search_objects).each(function(k, v) {
            var t = $(this);
            var fields = $.map(search_fields, function(val, i) {
                return t.find(val).text().toLowerCase();
            });
            var show = true;
            var site_tags = null;
            if (tags.length || notags.length) {
                site_tags = [];
                $(this).find(".tag").each(function(k, v) {
                    site_tags.push($(this).text().replace(/\W/g, "").toLowerCase());
                });
            }
            if (tags.length) {
                show = false;
                $.each(tags, function(k, v) {
                    $.each(site_tags, function(k2, v2) {
                        if (v2.indexOf(v) != -1) {
                            show = true;
                            return false;
                        }
                    });
                });
            }
            if (notags.length) {
                $.each(notags, function(k, v) {
                    $.each(site_tags, function(k2, v2) {
                        if (v2.indexOf(v) != -1) {
                            show = false;
                            return false;
                        }
                    });
                });
            }
            var matches = false;
            $.each(fields, function(k, v) {
                if (v.includes(val)) {
                    matches = true;
                    return false;
                }
            });
            if (show_offline) {
                if (!$(this).find(".fa.pull-left span").hasClass("red")) {
                    show = false;
                }
            }
            if (show_online) {
                if (!$(this).find(".fa.pull-left span").hasClass("green")) {
                    show = false;
                }
            }
            if (types) {
                var cmpObj = $(this).find(".fa.pull-left");
                var cmp = "other";
                if (cmpObj.hasClass("fa-user")) {
                    cmp = "user";
                }
                else if (cmpObj.hasClass("fa-snowflake")) {
                    cmp = "legacy";
                }
                else if (cmpObj.hasClass("fa-globe")) {
                    cmp = "activity";
                }
                if (types.indexOf(cmp) == -1) {
                    show = false;
                }
            }
            if (show && matches) {
                $(this).show();
            }
            else {
                $(this).hide();
            }<commit_msg>fix search<commit_after>$(document).ready(function() {
    $(".search-box").on("input", function(){
        var val = $(this).val().toLowerCase();

        var notags = [];
        var nomatches = val.match(/notag:\w+/g);
        if (nomatches) {
            $.each(nomatches, function(k, v) {
                notags.push(v.substring(6).toLowerCase());
            });
        }
        val = $.trim(val.replace(/\s*notag:\w+/g, ""));

        var tags = [];

        var show_online = false;
        var show_offline = false;

        var matches = val.match(/tag:\w+/g);
        if (matches) {
            $.each(matches, function(k, v) {
                var tag = v.substring(4).toLowerCase();
                if (tag == "online") {
                    show_online = true;
                }
                else if (tag == "offline") {
                    show_offline = true;
                }
                else {
                    tags.push(tag);
                }
            });
        }
        val = $.trim(val.replace(/\s*tag:\w+/g, ""));

        matches = val.match(/type:\w+/g);
        var types = [];
        if (matches) {
            $.each(matches, function(k, v) {
                types.push(v.substring(5).toLowerCase());
            });
        }
        val = $.trim(val.replace(/\s*type:\w+/g, ""));

        var search_objects = $(this).data("search");
        var search_fields = $(this).data("fields").split(",");
        $(search_objects).each(function(k, v) {
            var t = $(this);
            var fields = $.map(search_fields, function(val, i) {
                return t.find(val).text().toLowerCase();
            });
            var show = true;
            var site_tags = null;
            if (tags.length || notags.length) {
                site_tags = [];
                $(this).find(".tag").each(function(k, v) {
                    site_tags.push($(this).text().replace(/\W/g, "").toLowerCase());
                });
            }
            if (tags.length) {
                show = false;
                $.each(tags, function(k, v) {
                    $.each(site_tags, function(k2, v2) {
                        if (v2.indexOf(v) != -1) {
                            show = true;
                            return false;
                        }
                    });
                });
            }
            if (notags.length) {
                $.each(notags, function(k, v) {
                    $.each(site_tags, function(k2, v2) {
                        if (v2.indexOf(v) != -1) {
                            show = false;
                            return false;
                        }
                    });
                });
            }
            var matches = false;
            $.each(fields, function(k, v) {
                if (v.includes(val)) {
                    matches = true;
                    return false;
                }
            });
            if (show_offline) {
                if (!$(this).find(".fa.pull-left span").hasClass("red")) {
                    show = false;
                }
            }
            if (show_online) {
                if (!$(this).find(".fa.pull-left span").hasClass("green")) {
                    show = false;
                }
            }
            if (types.length) {
                var cmpObj = $(this).find(".fa.pull-left");
                var cmp = "other";
                if (cmpObj.hasClass("fa-user")) {
                    cmp = "user";
                }
                else if (cmpObj.hasClass("fa-snowflake-o")) {
                    cmp = "legacy";
                }
                else if (cmpObj.hasClass("fa-globe")) {
                    cmp = "activity";
                }
                if (types.indexOf(cmp) == -1) {
                    show = false;
                }
            }
            if (show && matches) {
                $(this).show();
            }
            else {
                $(this).hide();
            }
{'fraction_non_alphanumeric': 0.15346163459135218, 'fraction_numerical': 0.0029992501874531365, 'mean_word_length': 0.9500487329434698, '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': '86267', 'n_tokens_mistral': 2228, 'n_tokens_neox': 2104, 'n_words': 377}