<commit_before>/////////////////////////////////////////////////////////////////
// WitnessCollectionView displays all of the sources available //
// on the Juxta server, and allows the user to delete and      //
// collate them.                                               //
/////////////////////////////////////////////////////////////////

AV.WitnessCollectionView = Backbone.View.extend({
    el: '#list_witness_container',
    initialize: function() {
        console.log('initialize witnessCollectionView');
        this.listenTo(this.collection, 'all', this.render);
        this.listenTo(Backbone, "source:transformed", this.refresh);
    },
    events: {
	    "click #deleteWitnessButton": "delete",
        "click #collateButton": "collate"
    },
    template: _.template( $("#list_witness_template").html()),
    render: function () {
        this.$el.empty();
        this.$el.html(this.template({witnesses: this.collection.models}));	
    },
    refresh: function() {
        this.collection.fetch();
    },
    delete: function(ev) {
	    //ev is the mouse event. We receive the data-value which contains
	    //the id.
	    var idToDelete = $(ev.currentTarget).data('value');
	    var sourceToRemove = this.collection.find(function (source) {
		    return source.id == idToDelete;});<commit_msg>View refreshes if set 'TOKENIZING'<commit_after>/////////////////////////////////////////////////////////////////
// WitnessCollectionView displays all of the sources available //
// on the Juxta server, and allows the user to delete and      //
// collate them.                                               //
/////////////////////////////////////////////////////////////////

AV.WitnessCollectionView = Backbone.View.extend({
    el: '#list_witness_container',
    initialize: function() {
        console.log('initialize witnessCollectionView');
        this.listenTo(this.collection, 'all', this.render);
        this.listenTo(Backbone, "source:transformed", this.refresh);
    },
    events: {
	    "click #deleteWitnessButton": "delete",
        "click #collateButton": "collate"
    },
    template: _.template( $("#list_witness_template").html()),
    render: function () {
        this.$el.empty();
        this.$el.html(this.template({witnesses: this.collection.models}));	
        if (_.any(this.collection.models,
                  function(model){return model.get('status') == 'TOKENIZING';})){
            this.refresh();
        };
    },
    refresh: function() {
        this.collection.fetch();
    },
    delete: function(ev) {
	    //ev is the mouse event. We receive the data-value which contains
	    //the id.
	    var idToDelete = $(ev.currentTarget).data('value');
	    var sourceToRemove = this.collection.find(function (source) {
		    return source.id == idToDelete;});
{'fraction_non_alphanumeric': 0.2201280227596017, 'fraction_numerical': 0.0, 'mean_word_length': 1.870408163265306, 'pattern_counts': {'":': 4, '<': 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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4729804', 'n_tokens_mistral': 718, 'n_tokens_neox': 694, 'n_words': 165}