<commit_before>// are we on an edit page for entry, category, global??
var $idInput = $('form[data-saveshortcut-redirect^="entries/"] input[type="hidden"][name="entryId"], form[data-saveshortcut-redirect^="categories/"] input[type="hidden"][name="categoryId"], form input[type="hidden"][name="setId"]');
var currentWarnings = {};

var warn = function(selector, collisions, message) {
  var msg = message.split('{user}');
  // get the old warnings
  var oldWarnings = currentWarnings[selector];

  if (!oldWarnings) { oldWarnings = {}; }
  // each person in new warnings:
  for (var i=0; i < collisions.length; i++) {
    var email = collisions[i].email;
  //   if in old warnings already, ignore
    if (!oldWarnings[email]) {
  //   otherwise add to old warnings, value = true
  //   and add to container
      oldWarnings[email] = true;
      $(selector).append('<div>'+msg[0]+'<a href="mailto:'+email+'">'+collisions[i].name+'</a>'+msg[1]+' <span>X</span></div>');
    }
  }
  // update current warnings
  currentWarnings[selector] = oldWarnings;
};

var globalPollInterval = null;

var lookForCollisions = function(elementId, warnSelector, pollInterval) {
  var actuallyLook = function () {
    var $warnContainer = $(warnSelector);
    var isModal = warnSelector !== '#mnsnitch';
    if (isModal && ! $warnContainer.closest('div.hud[style*="display: block;"]').length) {
      // our modal is 'gone'
      if (pollInterval) { window.clearInterval(pollInterval); }
    } else {
      Craft.postActionRequest(
        'mnSnitch/ajaxEnter',
        {elementId: elementId},
        function(response) {
          if (response['collisions'].length) {
            warn(warnSelector, response['collisions'], response['message']);
          }
          // look again every pollInterval seconds
          if (!pollInterval) {
            pollInterval = window.setInterval(actuallyLook, response['serverPollInterval'] * 1000);
          }
        }
      );
    }
  };
  actuallyLook();
};

$('body').on('dblclick', 'div.element.small', function() {
  window.setTimeout(function(event) {
    // get our container (there may be several, only one is displayed)
    var $modalContainer = $('div.hud[style*="display: block;"]');
    if ($modalContainer.length) {
      var $idInput = $modalContainer.find('input[type="hidden"][name="elementId"]');
      var namespace = $modalContainer.find('input[type="hidden"][name="namespace"]').val();
      var elementId = $modalContainer.find('input[type="hidden"][name="elementId"]').val();
      var pollInterval = null;
      $modalContainer.prepend('<div class="mnsnitch mnsnitch--modal" id="mnsnitch-'+namespace+'"></div>');
      lookForCollisions(elementId, '#mnsnitch-'+namespace, pollInterval);
    }
  }, 1000);
});

$('body').on('click', '.mnsnitch span', function() {
  var $div = $(this).closest('div');
  // remove it from the dom
  $div.remove();
});


if ($idInput.length) {
  // we have landed on an entry form page for an existing entry
  // add our message div
  $('body').prepend('<div class="mnsnitch mnsnitch--main" id="mnsnitch"></div');
  // check for collisions
  lookForCollisions($idInput.val(), '#mnsnitch', globalPollInterval);
}<commit_msg>Remove fancily.<commit_after>// are we on an edit page for entry, category, global??
var $idInput = $('form[data-saveshortcut-redirect^="entries/"] input[type="hidden"][name="entryId"], form[data-saveshortcut-redirect^="categories/"] input[type="hidden"][name="categoryId"], form input[type="hidden"][name="setId"]');
var currentWarnings = {};

var warn = function(selector, collisions, message) {
  var msg = message.split('{user}');
  // get the old warnings
  var oldWarnings = currentWarnings[selector];

  if (!oldWarnings) { oldWarnings = {}; }
  // each person in new warnings:
  for (var i=0; i < collisions.length; i++) {
    var email = collisions[i].email;
  //   if in old warnings already, ignore
    if (!oldWarnings[email]) {
  //   otherwise add to old warnings, value = true
  //   and add to container
      oldWarnings[email] = true;
      $(selector).append('<div>'+msg[0]+'<a href="mailto:'+email+'">'+collisions[i].name+'</a>'+msg[1]+' <span>X</span></div>');
    }
  }
  // update current warnings
  currentWarnings[selector] = oldWarnings;
};

var globalPollInterval = null;

var lookForCollisions = function(elementId, warnSelector, pollInterval) {
  var actuallyLook = function () {
    var $warnContainer = $(warnSelector);
    var isModal = warnSelector !== '#mnsnitch';
    if (isModal && ! $warnContainer.closest('div.hud[style*="display: block;"]').length) {
      // our modal is 'gone'
      if (pollInterval) { window.clearInterval(pollInterval); }
    } else {
      Craft.postActionRequest(
        'mnSnitch/ajaxEnter',
        {elementId: elementId},
        function(response) {
          if (response['collisions'].length) {
            warn(warnSelector, response['collisions'], response['message']);
          }
          // look again every pollInterval seconds
          if (!pollInterval) {
            pollInterval = window.setInterval(actuallyLook, response['serverPollInterval'] * 1000);
          }
        }
      );
    }
  };
  actuallyLook();
};

$('body').on('dblclick', 'div.element.small', function() {
  window.setTimeout(function(event) {
    // get our container (there may be several, only one is displayed)
    var $modalContainer = $('div.hud[style*="display: block;"]');
    if ($modalContainer.length) {
      var $idInput = $modalContainer.find('input[type="hidden"][name="elementId"]');
      var namespace = $modalContainer.find('input[type="hidden"][name="namespace"]').val();
      var elementId = $modalContainer.find('input[type="hidden"][name="elementId"]').val();
      var pollInterval = null;
      $modalContainer.prepend('<div class="mnsnitch mnsnitch--modal" id="mnsnitch-'+namespace+'"></div>');
      lookForCollisions(elementId, '#mnsnitch-'+namespace, pollInterval);
    }
  }, 1000);
});

$('body').on('click', '.mnsnitch span', function() {
  var $div = $(this).closest('div');
  // remove it from the dom
  $div.slideUp('fast', function(){ $(this).remove() });
});


if ($idInput.length) {
  // we have landed on an entry form page for an existing entry
  // add our message div
  $('body').prepend('<div class="mnsnitch mnsnitch--main" id="mnsnitch"></div');
  // check for collisions
  lookForCollisions($idInput.val(), '#mnsnitch', globalPollInterval);
}
{'fraction_non_alphanumeric': 0.17786745304982152, 'fraction_numerical': 0.0034145584355114076, 'mean_word_length': 3.856066314996232, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 21, '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': '7038007', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1976, 'n_words': 435}