<commit_before>define(['vie', 'logger', 'underscore', 'jquery', 'backbone', 'voc','data/episode/EpisodeData', 'utils/SystemMessages', 'userParams'], function(VIE, Logger, _, $, Backbone, Voc, EpisodeData, SystemMessages, UserParams){
    return Backbone.View.extend({
        LOG: Logger.get('EpisodeView'),
        tagName: 'li',
        className: 'episode',
        events: {
            //'click li.version' : 'changeCurrentVersion',
            'click a' : 'changeCurrentEpisode',
            'click button.deleteEpisode' : 'deleteEpisode'
        },
        initialize: function() {
            var that = this;

            this.$el.append('<a href="#"></a>');

            this.model.on('change:'+this.model.vie.namespaces.uri(Voc.hasVersion), this.render, this);
            this.model.on('change:'+this.model.vie.namespaces.uri(Voc.label), this.renderLabel, this);
            this.model.on('destroy', function(model, collection, options) {
                this.remove();
            }, this);

            if( this.model.isNew() ) {
                this.model.once('change:'+model.idAttribute,
                    function(model, value) {
                        that.$el.attr('about', value);
                });
            }
        },
        renderLabel: function(model, value, options) {
            this.$el.find('span.episodeLabel').html(value);
            return this;
        },
        render: function() {
            this.$el.find('a').attr('about', this.model.getSubject());
            this.$el.find('a').html('<button class="btn btn-danger deleteEpisode" title="Disconnect yourself from the Episode."><i class="fa fa-chain-broken bnp-navbar-icon"></i></button> <span class="episodeLabel">' + this.model.get(Voc.label) + '</span>');
            return this;
        },
        changeCurrentVersion: function(event) {
            if( !event || !event.currentTarget ) return;
            var id = $(event.currentTarget).attr('about');
            this.LOG.debug('EpisodeView changeCurrentVersion ' + id);
            if( !id ) return;
            this.__getCurrentUserEntity().save( Voc.currentVersion, id);
        },
        changeCurrentEpisode: function(event) {
            event.preventDefault();
            if( !event || !event.currentTarget ) return;
            var id = EpisodeData.getFirstVersion(this.model);
            if( !id ) return;
            this.LOG.debug('EpisodeView changeCurrentEpisode, version = ' + id.getSubject());
            this.__getCurrentUserEntity().save( Voc.currentVersion, id.getSubject());
        },<commit_msg>LL-1312 Fixed a small bug.<commit_after>define(['vie', 'logger', 'underscore', 'jquery', 'backbone', 'voc','data/episode/EpisodeData', 'utils/SystemMessages', 'userParams'], function(VIE, Logger, _, $, Backbone, Voc, EpisodeData, SystemMessages, UserParams){
    return Backbone.View.extend({
        LOG: Logger.get('EpisodeView'),
        tagName: 'li',
        className: 'episode',
        events: {
            //'click li.version' : 'changeCurrentVersion',
            'click a' : 'changeCurrentEpisode',
            'click button.deleteEpisode' : 'deleteEpisode'
        },
        initialize: function() {
            var that = this;

            this.$el.append('<a href="#"></a>');

            this.model.on('change:'+this.model.vie.namespaces.uri(Voc.hasVersion), this.render, this);
            this.model.on('change:'+this.model.vie.namespaces.uri(Voc.label), this.renderLabel, this);
            this.model.on('destroy', function(model, collection, options) {
                this.remove();
            }, this);

            if( this.model.isNew() ) {
                this.model.once('change:'+this.model.idAttribute,
                    function(model, value) {
                        that.$el.attr('about', value);
                });
            }
        },
        renderLabel: function(model, value, options) {
            this.$el.find('span.episodeLabel').html(value);
            return this;
        },
        render: function() {
            this.$el.find('a').attr('about', this.model.getSubject());
            this.$el.find('a').html('<button class="btn btn-danger deleteEpisode" title="Disconnect yourself from the Episode."><i class="fa fa-chain-broken bnp-navbar-icon"></i></button> <span class="episodeLabel">' + this.model.get(Voc.label) + '</span>');
            return this;
        },
        changeCurrentVersion: function(event) {
            if( !event || !event.currentTarget ) return;
            var id = $(event.currentTarget).attr('about');
            this.LOG.debug('EpisodeView changeCurrentVersion ' + id);
            if( !id ) return;
            this.__getCurrentUserEntity().save( Voc.currentVersion, id);
        },
        changeCurrentEpisode: function(event) {
            event.preventDefault();
            if( !event || !event.currentTarget ) return;
            var id = EpisodeData.getFirstVersion(this.model);
            if( !id ) return;
            this.LOG.debug('EpisodeView changeCurrentEpisode, version = ' + id.getSubject());
            this.__getCurrentUserEntity().save( Voc.currentVersion, id.getSubject());
        },
{'fraction_non_alphanumeric': 0.15784389489953632, 'fraction_numerical': 0.0007727975270479134, 'mean_word_length': 2.2600755667506296, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '792992', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1415, 'n_words': 256}