<commit_before>define([
    'jquery',
    'backbone',
    'knockout'
], function($, Backbone, ko) {
    var ListView = Backbone.View.extend({

        items: ko.observableArray(),
        single_select: true,

        initialize: function(options) {
            this.filter = ko.observable('');
            this.filter.subscribe(function(newValue){
                var filter = this.filter().toLowerCase();
                this.items().forEach(function(item){
                    var name = typeof item.name === 'string' ? item.name : item.name();
                    item.filtered(true);
                    if(name.toLowerCase().indexOf(filter) !== -1){
                        item.filtered(false);
                    }
                }, this);
            }, this, 'change')

        },

        selectItem: function(item, evt){
            if(this.single_select){
                this.clearSelection();
            }
            item.selected(!item.selected());
            $(evt.currentTarget).toggleClass('selected-card');
        },

        clearSelection: function(){
            this.items().forEach(function(item){<commit_msg>make filter function overridable, re #351<commit_after>define([
    'jquery',
    'backbone',
    'knockout'
], function($, Backbone, ko) {
    var ListView = Backbone.View.extend({

        items: ko.observableArray(),
        single_select: true,
        filter_function: function(newValue){
            var filter = this.filter().toLowerCase();
            this.items().forEach(function(item){
                var name = typeof item.name === 'string' ? item.name : item.name();
                item.filtered(true);
                if(name.toLowerCase().indexOf(filter) !== -1){
                    item.filtered(false);
                }
            }, this);
        },

        initialize: function(options) {
            this.filter = ko.observable('');
            this.filter.subscribe(this.filter_function, this, 'change');
        },

        selectItem: function(item, evt){
            if(this.single_select){
                this.clearSelection();
            }
            item.selected(!item.selected());
            $(evt.currentTarget).toggleClass('selected-card');
        },

        clearSelection: function(){
            this.items().forEach(function(item){
{'fraction_non_alphanumeric': 0.1423027166882277, 'fraction_numerical': 0.0021561017680034496, 'mean_word_length': 1.7488151658767772, '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': '951482', 'n_tokens_mistral': 608, 'n_tokens_neox': 587, 'n_words': 100}