<commit_before>$(window).ready(function(){
  formEl = $('form.navigate-away-warning');

  if(formEl[0]){
    var confirmOnPageExit = function (e) {
      // If we haven't been passed the event get the window.event
      e = e || window.event;

      var message = CONSTANTS.i18n.navigateAwayWarning;

      // For IE6-8 and Firefox prior to version 4
      if (e) {
        e.returnValue = message;
      }

      // For Chrome, Safari, IE8+ and Opera 12+
      return message;
    };

    window.onbeforeunload = confirmOnPageExit;

    formEl.submit(function(){
      window.onbeforeunload = null;
    });
  }
});
<commit_msg>Only add navigate away warning if form edited<commit_after>$(window).ready(function(){
  formEl = $('form.navigate-away-warning');

  formEl.find(':input').each(function() {
      $(this).data('initialValue', $(this).val());
  });

  if(formEl[0]){
    var confirmOnPageExit = function (e) {
      var isClean = true;

      formEl.find(':input').each(function () {
        if($(this).data('initialValue') !== $(this).val()){
          isClean = false;
        }
      });
      if (isClean) {
        return
      }

      // If we haven't been passed the event get the window.event
      e = e || window.event;

      var message = CONSTANTS.i18n.navigateAwayWarning;

      // For IE6-8 and Firefox prior to version 4
      if (e) {
        e.returnValue = message;
      }

      // For Chrome, Safari, IE8+ and Opera 12+
      return message;
    };

    window.onbeforeunload = confirmOnPageExit;

    formEl.submit(function(){
      window.onbeforeunload = null;
    });
  }
});

{'fraction_non_alphanumeric': 0.14436183395291202, 'fraction_numerical': 0.011152416356877323, 'mean_word_length': 2.3645833333333335, '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': '126498', 'n_tokens_mistral': 537, 'n_tokens_neox': 505, 'n_words': 121}