<commit_before>window.SidebarView = Backbone.View.extend({

    id: 'sidebar',

    events: {
        "click a.clear": "onClear",
        "click a.send": "onSend",
        "click a.flip": "onFlip"
    },

    initialize: function () {
        this.marks = [];

        $(window).resize(_.bind(this.onResize, this));

        window.server.bind("info-loaded", _.bind(this.onInfoLoaded, this));
        window.markList.bind("add", _.bind(this.onMarkAdded, this));
        window.markList.bind("remove", _.bind(this.onMarkRemoved, this));
        window.markList.bind("reset", _.bind(this.onListReset, this));
    },

    render: function () {
        $(this.el).html(templates.sidebarView);
        $('#main').append(this.el);

        this.onResize();

        $(this.el).resizable({
            handles: 'e'
        });

        this.$('#marks').sortable({
            update: _.bind(this.onMarkListSortUpdate, this)
        });
        this.$('#marks').disableSelection();

        return this;
    },

    onInfoLoaded: function () {
        var algorithms = window.server.get('algorithms');
        var $algorithms = this.$('#algorithms');

        if (!_.isUndefined(algorithms) && algorithms.length > 0) {
            $algorithms.children().remove();
            for (var i in algorithms) {
                if (!algorithms[i].details.hidden)
                    $algorithms.append('<option value="' + algorithms[i].urlsuffix + '">' + $._(algorithms[i].name) + '</option>');
            }
        }
    },

    onMarkAdded: function (model, collection, options) {
        if (this.marks.length === 0)
            this.$('#marks').html('');

        var view = new MarkView({model: model}).render();
        this.marks.push(view);
        model.set({view: view});

        this._sortMarks();
    },

    onMarkRemoved: function (model, collection) {
        for (var i in this.marks) {
            if (_.isEqual(this.marks[i].cid, model.get('view').cid))
                this.marks.splice(i, 1);
        }
        model.get('view').remove();

        if (this.marks.length === 0)
            this.$('#marks').html('No points defined!');

        this._sortMarks();
    },

    onMarkListSortUpdate: function (event, ui) {
        var mark = ui.item;
        var cid = mark.attr('id').split('_')[1];

        var markModel = window.markList.getByCid(cid);
        window.markList.moveMark(markModel, mark.index());
    },

    onListReset: function () {
        this.marks = [];

        if (window.markList.length === 0) {
            _markerNameSuffix = "A";
            this.$('#marks').html($._('No points defined!'));
        } else {
            for (var i = 0; i < window.markList.length; ++i)
                this.marks.push(new MarkView({model: window.markList.at(i)}));
            this._sortMarks();
        }
    },

    onSend: function () {
        var alg = this.$('#algorithms').val();
        if (_.isUndefined(alg) || _.isEmpty(alg))  {
            new MessageView({
                title: $._('Error'),
                message: $._('No algorithm selected.')
            }).render();
        } else if (window.markList.length < window.server.get("algorithms")[$('#algorithms')[0].selectedIndex].constraints.minPoints) {
            new MessageView({
               title: $._('Error'),
               message: $._('Not enough points defined.')
            }).render();
        } else {
            loadingView = new LoadingView($._('Waiting for response from server ...')).render();
            window.api.alg({
                alg: this.$('#algorithms').val(),
                points: window.markList.toJSON(),<commit_msg>It's now details not constraints where we find minPoints<commit_after>window.SidebarView = Backbone.View.extend({

    id: 'sidebar',

    events: {
        "click a.clear": "onClear",
        "click a.send": "onSend",
        "click a.flip": "onFlip"
    },

    initialize: function () {
        this.marks = [];

        $(window).resize(_.bind(this.onResize, this));

        window.server.bind("info-loaded", _.bind(this.onInfoLoaded, this));
        window.markList.bind("add", _.bind(this.onMarkAdded, this));
        window.markList.bind("remove", _.bind(this.onMarkRemoved, this));
        window.markList.bind("reset", _.bind(this.onListReset, this));
    },

    render: function () {
        $(this.el).html(templates.sidebarView);
        $('#main').append(this.el);

        this.onResize();

        $(this.el).resizable({
            handles: 'e'
        });

        this.$('#marks').sortable({
            update: _.bind(this.onMarkListSortUpdate, this)
        });
        this.$('#marks').disableSelection();

        return this;
    },

    onInfoLoaded: function () {
        var algorithms = window.server.get('algorithms');
        var $algorithms = this.$('#algorithms');

        if (!_.isUndefined(algorithms) && algorithms.length > 0) {
            $algorithms.children().remove();
            for (var i in algorithms) {
                if (!algorithms[i].details.hidden)
                    $algorithms.append('<option value="' + algorithms[i].urlsuffix + '">' + $._(algorithms[i].name) + '</option>');
            }
        }
    },

    onMarkAdded: function (model, collection, options) {
        if (this.marks.length === 0)
            this.$('#marks').html('');

        var view = new MarkView({model: model}).render();
        this.marks.push(view);
        model.set({view: view});

        this._sortMarks();
    },

    onMarkRemoved: function (model, collection) {
        for (var i in this.marks) {
            if (_.isEqual(this.marks[i].cid, model.get('view').cid))
                this.marks.splice(i, 1);
        }
        model.get('view').remove();

        if (this.marks.length === 0)
            this.$('#marks').html('No points defined!');

        this._sortMarks();
    },

    onMarkListSortUpdate: function (event, ui) {
        var mark = ui.item;
        var cid = mark.attr('id').split('_')[1];

        var markModel = window.markList.getByCid(cid);
        window.markList.moveMark(markModel, mark.index());
    },

    onListReset: function () {
        this.marks = [];

        if (window.markList.length === 0) {
            _markerNameSuffix = "A";
            this.$('#marks').html($._('No points defined!'));
        } else {
            for (var i = 0; i < window.markList.length; ++i)
                this.marks.push(new MarkView({model: window.markList.at(i)}));
            this._sortMarks();
        }
    },

    onSend: function () {
        var alg = this.$('#algorithms').val();
        if (_.isUndefined(alg) || _.isEmpty(alg))  {
            new MessageView({
                title: $._('Error'),
                message: $._('No algorithm selected.')
            }).render();
        } else if (window.markList.length < window.server.get("algorithms")[$('#algorithms')[0].selectedIndex].details.minPoints) {
            new MessageView({
               title: $._('Error'),
               message: $._('Not enough points defined.')
            }).render();
        } else {
            loadingView = new LoadingView($._('Waiting for response from server ...')).render();
            window.api.alg({
                alg: this.$('#algorithms').val(),
                points: window.markList.toJSON(),
{'fraction_non_alphanumeric': 0.17733788395904437, 'fraction_numerical': 0.0021843003412969283, 'mean_word_length': 2.00122900450635, 'pattern_counts': {'":': 6, '<': 11, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2738235', 'n_tokens_mistral': 2173, 'n_tokens_neox': 2113, 'n_words': 395}