<commit_before>
<script language="javascript" type="text/javascript"><!--

$j(document).ready(function() {

  $cd.buildDiffFilenameHandlers(<%= @diffs.to_json.html_safe %>);
  
  $j.fn.onOff = function() {
    var setTo = this.val() === 'none' ? 'block' : 'none';
    this.val(setTo);
    return setTo;
  };

  var allLineCountButtons = $j('.diff-deleted-line-count, .diff-added-line-count');
  var off = { 'disabled':true, 'title':'' }; 
  
  var disableAllLineCountButtons = function() {
    allLineCountButtons.attr(off);
  };

  $j('.filename').click(function() {
    var tr = $j(this).parent().parent();
    var del = tr.find('.diff-deleted-line-count');
    var add = tr.find('.diff-added-line-count');
    disableAllLineCountButtons();
    del.attr('disabled', false)
       .attr('title', 'click to toggle deleted lines on/off');
    add.attr('disabled', false)
       .attr('title', 'click to toggle added lines on/off');
  });

  $j('.diff-deleted-line-count').click(function() {
    if ($j(this).attr('disabled') !== 'disabled') {
      var deleted = $j('deleted');
      deleted.css('display', deleted.onOff());
    }
  });
  
  $j('.diff-added-line-count').click(function() {
    if ($j(this).attr('disabled') !== 'disabled') {
      var added = $j('added');
      added.css('display', added.onOff());
    }
  });
  <commit_msg>diff line-count button javascript refactoring<commit_after>
<script language="javascript" type="text/javascript"><!--

$j(document).ready(function() {

  $cd.buildDiffFilenameHandlers(<%= @diffs.to_json.html_safe %>);
  
  var display = function(node,name,value) {
    if ($j(node).attr('disabled') !== 'disabled') {
      $j(name).css('display', value);
    }
  };
  var allLineCountButtons = $j('.diff-deleted-line-count, .diff-added-line-count');
  var off = { 'disabled':true, 'title':'' }; 
  var disableAllLineCountButtons = function() {
    allLineCountButtons.attr(off);
  };

  $j('.filename').click(function() {
    var tr = $j(this).parent().parent();
    var del = tr.find('.diff-deleted-line-count');
    var add = tr.find('.diff-added-line-count');
    disableAllLineCountButtons();
    del.attr('disabled', false)
       .attr('title', 'click to toggle deleted lines on/off');
    add.attr('disabled', false)
       .attr('title', 'click to toggle added lines on/off');
  });

  $j('.diff-deleted-line-count').toggle(
    function() { display(this,'deleted','none' ); },
    function() { display(this,'deleted','block'); }
  );
  $j('.diff-added-line-count').toggle(
    function() { display(this,'added','none' ); },
    function() { display(this,'added','block'); }
  );
  
{'fraction_non_alphanumeric': 0.21436716077537057, 'fraction_numerical': 0.0, 'mean_word_length': 3.674955595026643, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '4420592', 'n_tokens_mistral': 871, 'n_tokens_neox': 871, 'n_words': 147}