<commit_before>window.OwnChannelItemView = Backbone.View.extend({
  tagName: "li",
  tmpl: $('#own_channel_li').html(),
  
  events: {
    "change input" : "change"
  },
  
  initialize: function() {
    this.model.bind('change', this.render, this);
    this.model.bind('destroy', this.remove, this);
    this.model.bind('remove', this.remove, this);
  },
  
  render: function() {
    $( this.el )
      .html( Mustache.to_html(this.tmpl, this.model.toJSON() ));
    
    $( this.el ).find('input').prop('checked', this.model.checked === true ? true : false);
    
    return this;
  },

  remove: function() {
    $( this.el ).remove();
  },
  
  disable: function() {
    $( this.el ).find('input').prop('disabled',true);
  },
  
  enable: function() {
    $( this.el ).find('input').prop('disabled',false);
  },
  
  change: function( e ) {
    var self = this;
    var checked = e.target.checked;
    var action = checked ? "add" : "remove";
    
    self.disable();
    
    $.ajax({
      url: this.model.url() + '/subchannels/' + action + '/' + currentChannel.id + '.json',
      type: "post",
      success: function(data) {
        if ( checked ) {
          currentChannel.get('containing_channels').push(self.model.id);
        } else {
          var indexOf = currentChannel.get('containing_channels').indexOf(self.model.id);
          if ( indexOf ) {
            currentChannel.get('containing_channels').splice(indexOf, 1);
          }
        }
        
        self.enable();
      },
      error: function() {
        e.target.checked = newValue;
        
        self.enable();
      }
    });
  }
});<commit_msg>Made the change url case specific and renamed the ids<commit_after>window.OwnChannelItemView = Backbone.View.extend({
  tagName: "li",
  tmpl: $('#own_channel_li').html(),
  
  events: {
    "change input" : "change"
  },
  
  initialize: function(opts) {
    this.model.bind('change', this.render, this);
    this.model.bind('destroy', this.remove, this);
    this.model.bind('remove', this.remove, this);
    
    this.forFact = opts.forFact;
    this.forChannel = opts.forChannel;
  },
  
  render: function() {
    $( this.el )
      .html( Mustache.to_html(this.tmpl, this.model.toJSON() ));
    
    $( this.el ).find('input').prop('checked', this.model.checked === true ? true : false);
    
    return this;
  },

  remove: function() {
    $( this.el ).remove();
  },
  
  disable: function() {
    $( this.el ).find('input').prop('disabled',true);
  },
  
  enable: function() {
    $( this.el ).find('input').prop('disabled',false);
  },
  
  change: function( e ) {
    var self = this;
    var checked = e.target.checked;
    var action = checked ? "add" : "remove";
    
    self.disable();
    
    var changeUrl;
    
    if ( self.forChannel ) {
      changeUrl = this.model.url() + '/subchannels/' + action + '/' + self.forChannel.id + '.json';
    } else if ( self.forFact ) {
      changeUrl = this.model.url() + '/' + action + '/' + self.forFact.id + '.json';
    }
    
    $.ajax({
      url: changeUrl,
      type: "post",
      success: function(data) {
        var model = self.forFact || self.forChannel;
        
        if ( checked ) {
          model.get('containing_channel_ids').push(self.model.id);
        } else {
          var indexOf = model.get('containing_channel_ids').indexOf(self.model.id);
          if ( indexOf ) {
            model.get('containing_channel_ids').splice(indexOf, 1);
          }
        }
        
        self.enable();
      },
      error: function() {
        e.target.checked = !checked;
        
        self.enable();
      }
    });
  }
});
{'fraction_non_alphanumeric': 0.17814987647543234, 'fraction_numerical': 0.0005489980785067252, 'mean_word_length': 2.221927497789567, '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': '14717', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1170, 'n_words': 211}