<commit_before>jQuery(function($) {
  var editor = $('textarea.wiki-edit');
  var preview = $('div#preview');
  var preview_link = $('input[name=commit]').next();

  var disable_side_by_side_mode = function() {
    editor.add(preview).removeClass('side_by_side');

    editor.off('scroll');
    $('#content').append(preview);
  };

  var enable_side_by_side_mode = function() {
    editor.add(preview).addClass('side_by_side');

    editor.before(preview);
    preview.height(editor.height() + 5);

    editor.scroll(preview, scroll_preview);
    editor.scroll();

    if($('fieldset.preview').length === 0) {
      preview_link.click();
    }
  };

  var scroll_preview = function(event) {
    var source_position = this.scrollTop / (this.scrollHeight - $(this).innerHeight());
    var target = $(event.data);

    target.scrollTop(source_position * (target[0].scrollHeight - target.innerHeight()));
  };

  var toggle_side_by_side_mode = function() {
    if(this.checked) {
      enable_side_by_side_mode();
    } else {
      disable_side_by_side_mode();
    }
  };

  preview_link.after($('<label for="side_by_side_mode">Show editor and preview side-by-side</label>'))
              .after($('<input id="side_by_side_mode" type="checkbox" />'));
  $('#side_by_side_mode').click(toggle_side_by_side_mode);
});<commit_msg>Resizing the editor area resizes the preview<commit_after>jQuery(function($) {
  var editor = $('textarea.wiki-edit');
  var preview = $('div#preview');
  var preview_link = $('input[name=commit]').next();

  var disable_side_by_side_mode = function() {
    editor.add(preview).removeClass('side_by_side');

    editor.off('scroll');
    editor.off('mouseup');

    $('#content').append(preview);
  };

  var enable_side_by_side_mode = function() {
    editor.add(preview).addClass('side_by_side');

    editor.before(preview);
    resize_preview_to_editor_height();

    editor.scroll(preview, scroll_preview);
    editor.mouseup(resize_preview_if_required);
    editor.scroll();

    if($('fieldset.preview').length === 0) {
      preview_link.click();
    }
  };

  var resize_preview_if_required = function() {
    var newEditorHeight = editor.outerHeight();

    if(newEditorHeight != editor.data('height')) {
      editor.data('height', newEditorHeight);
      resize_preview_to_editor_height();
    }
  }

  var resize_preview_to_editor_height = function() {
    preview.height(editor.height() + 6);
  }

  var scroll_preview = function(event) {
    var source_position = this.scrollTop / (this.scrollHeight - $(this).innerHeight());
    var target = $(event.data);

    target.scrollTop(source_position * (target[0].scrollHeight - target.innerHeight()));
  };

  var toggle_side_by_side_mode = function() {
    if(this.checked) {
      enable_side_by_side_mode();
    } else {
      disable_side_by_side_mode();
    }
  };

  preview_link.after($('<label for="side_by_side_mode">Show editor and preview side-by-side</label>'))
              .after($('<input id="side_by_side_mode" type="checkbox" />'));
  $('#side_by_side_mode').click(toggle_side_by_side_mode);

  editor.data('height', editor.outerHeight());
});
{'fraction_non_alphanumeric': 0.1656071201525747, 'fraction_numerical': 0.0019071837253655435, 'mean_word_length': 4.159016393442623, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6801114', 'n_tokens_mistral': 1027, 'n_tokens_neox': 991, 'n_words': 145}