<commit_before>function useACE(yes) {
  console.log("ACE: %s", yes);
  if (yes) {
    $('#body').hide();
    $('#editor').show();
    $('#editor_toggle_value').value=true;
  } else {
    $('#body').show();
    $('#editor').hide();
    $('#editor_toggle_value').value=false;
  }
}

$(document).ready(function() {
  console.log($('#editor_toggle_value'));
  $('#editor_toggle_value').change(function() {
    useACE($('#editor_toggle_value')[0].checked);
  });
  if (ace) {
    $('#editor_toggle').show();
    var editor = ace.edit("editor");
    editor.setTheme("ace/theme/monokai");
    editor.getSession().setMode("ace/mode/markdown");
    editor.getSession().on('change', function(e) {
      $('#body').val(editor.getValue());
    });
    $('#body').changed(function() {
      editor.setValue($('#body').val());
    });
    useACE(true);
  }
});<commit_msg>modulize editor, clean up ace/textarea selector<commit_after>(function() {
  var editor;

  function useACE(yes) {
    console.log("ACE: %s", yes);
    if (yes) {
      $('#body').hide();
      $('#editor').show();
      $('#editor_toggle_value')[0].checked = true;
    } else {
      $('#body').show();
      $('#editor').hide();
      $('#editor_toggle_value')[0].checked = false;
    }
  }

  function syncBodyToEditor() {
    editor.setValue($('#body').val());

  }

  function syncEditorToBody() {
    $('#body').val(editor.getValue());
  }

  $(document).ready(function() {
    console.log($('#editor_toggle_value'));
    if (ace) {
      $('#editor_toggle').show();
      editor = ace.edit("editor");
      editor.setTheme("ace/theme/monokai");
      editor.getSession().setMode("ace/mode/markdown");
      editor.getSession().on('change', syncEditorToBody);
      $('#body').change(syncBodyToEditor);
      useACE(true);
    }
    syncBodyToEditor();
    $('#editor_toggle_value').change(function() {
      useACE($('#editor_toggle_value')[0].checked);
    });
  });
})();
{'fraction_non_alphanumeric': 0.24097007223942207, 'fraction_numerical': 0.0020639834881320948, 'mean_word_length': 3.6166666666666667, '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': '3261942', 'n_tokens_mistral': 626, 'n_tokens_neox': 639, 'n_words': 78}