<commit_before>var ResourceEditor = Backbone.View.extend({
  events: {
    'change .image-file': 'upload',
    'keydown .resource-url': 'update'
  },
  
  resourceExists: function(url, callback) {
    var img = new Image();
    img.onload = function() { callback(null); }
    img.onerror = function() { callback('not found'); }
    img.src = url;
  },
  
  update: function() {
    var that = this;
    
    function perform() {
      var url = that.$('.resource-url').val();
      that.resourceExists(url, function(err) {
        if (!err) {
          that.$('img').attr('src', url);
          that.$('.status').replaceWith('<div class="status image">Image</div>');
          app.document.updateSelectedNode({
            url: url
          });
        } else {
          that.$('.status').replaceWith('<div class="status">Invalid URL</div>');
        }
      });      
    }
    
    setTimeout(perform, 500);
  },
  
  initialize: function() {
    var that = this;
    
    this.pendingCheck = false;
    this.$caption = this.$('.caption');
    editor.activate(this.$caption, {
      placeholder: 'Enter Caption',
      multiline: false,
      markup: false
    });
    
    editor.bind('changed', function() {
      app.document.updateSelectedNode({
        caption: editor.content()
      });
    });
  },
  
  render: function() {
    
  }
});<commit_msg>Fixed a layout bug that occurred when changing the URL of a Resource node.<commit_after>var ResourceEditor = Backbone.View.extend({
  events: {
    'change .image-file': 'upload',
    'keydown .resource-url': 'update'
  },
  
  resourceExists: function(url, callback) {
    var img = new Image();
    img.onload = function() { callback(null); }
    img.onerror = function() { callback('not found'); }
    img.src = url;
  },
  
  update: function() {
    var that = this;
    
    function perform() {
      var url = that.$('.resource-url').val();
      that.resourceExists(url, function(err) {
        if (!err) {
          that.$('.resource-content img').attr('src', url);
          that.$('.status').replaceWith('<div class="status image">Image</div>');
          app.document.updateSelectedNode({
            url: url
          });
        } else {
          that.$('.status').replaceWith('<div class="status">Invalid URL</div>');
        }
      });      
    }
    
    setTimeout(perform, 500);
  },
  
  initialize: function() {
    var that = this;
    
    this.pendingCheck = false;
    this.$caption = this.$('.caption');
    editor.activate(this.$caption, {
      placeholder: 'Enter Caption',
      multiline: false,
      markup: false
    });
    
    editor.bind('changed', function() {
      app.document.updateSelectedNode({
        caption: editor.content()
      });
    });
  },
  
  render: function() {
    
  }
});
{'fraction_non_alphanumeric': 0.1702963227418779, 'fraction_numerical': 0.0021420921099607284, 'mean_word_length': 2.228110599078341, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3302015', 'n_tokens_mistral': 837, 'n_tokens_neox': 828, 'n_words': 170}