<commit_before>/*global jQuery,cyberDojo*/

var cyberDojo = (function(cd, $) {
  "use strict";

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  const hashOf = function(content) {
    let hash = 0;
    for (let i = 0; i < content.length; ++i) {
      hash = (hash << 5) - hash + content.charCodeAt(i);
      hash &= hash;
    }
    return hash;
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  const outgoingHashContainer = function() {
    return $('#file_hashes_outgoing_container');
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  const incomingHashContainer = function() {
    return $('#file_hashes_incoming_container');
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  const storeOutgoingFileHash = function(filename) {
    const node = cd.fileContentFor(filename);
    const hash = hashOf(node.val());
    $('input[data-filename="'+filename+'"]', outgoingHashContainer()).remove();
    outgoingHashContainer().append(
      $('<input>', {
        'type': 'hidden',
        'data-filename': filename,
        'name': "file_hashes_outgoing[" + filename + "]",
        'value': hash
      })
    );
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  cd.storeOutgoingFileHashes = function() {
    outgoingHashContainer().empty();
    $.each(cd.filenames(), function(_,filename) {
      storeOutgoingFileHash(filename);
    });
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  cd.storeIncomingFileHashes = function() {
    incomingHashContainer().empty();
    $.each(cd.filenames(), function(_,filename) {
      const node = cd.fileContentFor(filename);
      const content = node.val();
      const hash = hashOf(content);
      incomingHashContainer().append(
        $('<input>', {
          'type': 'hidden',
          'data-filename': filename,
          'name': "file_hashes_incoming[" + filename + "]",
          'value': hash
        })
      );
    });
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  return cd;

})(cyberDojo || {}, jQuery);<commit_msg>refactoring; javascript tidying<commit_after>/*global jQuery,cyberDojo*/

var cyberDojo = (function(cd, $) {
  "use strict";

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  cd.storeOutgoingFileHashes = function() {
    outgoingHashContainer().empty();
    $.each(cd.filenames(), function(_,filename) {
      storeOutgoingFileHash(filename);
    });
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  cd.storeIncomingFileHashes = function() {
    incomingHashContainer().empty();
    $.each(cd.filenames(), function(_,filename) {
      const node = cd.fileContentFor(filename);
      const content = node.val();
      const hash = hashOf(content);
      incomingHashContainer().append(
        $('<input>', {
          'type': 'hidden',
          'data-filename': filename,
          'name': "file_hashes_incoming[" + filename + "]",
          'value': hash
        })
      );
    });
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  const hashOf = function(content) {
    let hash = 0;
    for (let i = 0; i < content.length; ++i) {
      hash = (hash << 5) - hash + content.charCodeAt(i);
      hash &= hash;
    }
    return hash;
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  const outgoingHashContainer = function() {
    return $('#file_hashes_outgoing_container');
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  const incomingHashContainer = function() {
    return $('#file_hashes_incoming_container');
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  const storeOutgoingFileHash = function(filename) {
    const node = cd.fileContentFor(filename);
    const hash = hashOf(node.val());
    $('input[data-filename="'+filename+'"]', outgoingHashContainer()).remove();
    outgoingHashContainer().append(
      $('<input>', {
        'type': 'hidden',
        'data-filename': filename,
        'name': "file_hashes_outgoing[" + filename + "]",
        'value': hash
      })
    );
  };

  //- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  return cd;

})(cyberDojo || {}, jQuery);
{'fraction_non_alphanumeric': 0.23644507307873644, 'fraction_numerical': 0.0014144271570014145, 'mean_word_length': 1.4455331412103747, 'pattern_counts': {'":': 0, '<': 13, '<?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': 56, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4031491', 'n_tokens_mistral': 1507, 'n_tokens_neox': 1474, 'n_words': 193}