<commit_before>(function() {
  "use strict";
  window.GOVUK = window.GOVUK || {}

  var enhanceUnpublishingForm = {
    init: function(params) {
      this.$form = $(params.selector);
      this.$submit_button = $('input[type="submit"]', this.$form);
      this.$explanation = $('.js_explanation');
      this.$alt_url = $('.js_alt_url');
      this.$redirect = $('.js_redirect');
      this.$auto_redirect = $('.auto_redirect');

      this.refreshFormFields();
      $("input[name='unpublishing[unpublishing_reason_id]']", this.$form).change(this.refreshFormFields);
    },

    refreshFormFields: function() {
      var selectedReason =  $("input[name='unpublishing[unpublishing_reason_id]']:checked").val();

      switch(selectedReason) {
        case '<%= UnpublishingReason::Archived.id %>':
          enhanceUnpublishingForm.$explanation.show();
          enhanceUnpublishingForm.$alt_url.hide();
          enhanceUnpublishingForm.$redirect.hide();
          enhanceUnpublishingForm.$auto_redirect.hide();
          enhanceUnpublishingForm.$submit_button.val('Archive');
          break;
        case '<%= UnpublishingReason::PublishedInError.id %>':
          enhanceUnpublishingForm.$explanation.show();
          enhanceUnpublishingForm.$alt_url.show();
          enhanceUnpublishingForm.$redirect.show();
          enhanceUnpublishingForm.$auto_redirect.hide();
          enhanceUnpublishingForm.$submit_button.val('Unpublish');
          break;
        case '<%= UnpublishingReason::Consolidated.id %>':
          enhanceUnpublishingForm.$explanation.hide();
          enhanceUnpublishingForm.$alt_url.show();
          enhanceUnpublishingForm.$redirect.hide();
          enhanceUnpublishingForm.$auto_redirect.show();
          enhanceUnpublishingForm.$submit_button.val('Unpublish');
          break;
      }
    }
  };

  window.GOVUK.enhanceUnpublishingForm = enhanceUnpublishingForm;
}());<commit_msg>Reset unpublishing fields when hidden<commit_after>(function() {
  "use strict";
  window.GOVUK = window.GOVUK || {}

  var enhanceUnpublishingForm = {
    init: function(params) {
      this.$form = $(params.selector);
      this.$submit_button = $('input[type="submit"]', this.$form);
      this.$explanation = $('.js_explanation');
      this.$alt_url = $('.js_alt_url');
      this.$redirect = $('.js_redirect');
      this.$auto_redirect = $('.auto_redirect');

      this.refreshFormFields();
      $("input[name='unpublishing[unpublishing_reason_id]']", this.$form).change(this.refreshFormFields);
    },

    refreshFormFields: function() {
      var selectedReason =  $("input[name='unpublishing[unpublishing_reason_id]']:checked").val();

      switch(selectedReason) {
        case '<%= UnpublishingReason::Archived.id %>':
          enhanceUnpublishingForm.$explanation.show();
          enhanceUnpublishingForm.$alt_url.hide().find('input').val('');
          enhanceUnpublishingForm.$redirect.hide().find('input').prop('checked', false);
          enhanceUnpublishingForm.$auto_redirect.hide().find('input').val('');
          enhanceUnpublishingForm.$submit_button.val('Archive');
          break;
        case '<%= UnpublishingReason::PublishedInError.id %>':
          enhanceUnpublishingForm.$explanation.show();
          enhanceUnpublishingForm.$alt_url.show();
          enhanceUnpublishingForm.$redirect.show();
          enhanceUnpublishingForm.$auto_redirect.hide().find('input').prop('checked', false);
          enhanceUnpublishingForm.$submit_button.val('Unpublish');
          break;
        case '<%= UnpublishingReason::Consolidated.id %>':
          enhanceUnpublishingForm.$explanation.hide().find('textarea').val('');
          enhanceUnpublishingForm.$alt_url.show();
          enhanceUnpublishingForm.$redirect.hide().find('input').prop('checked', false);
          enhanceUnpublishingForm.$auto_redirect.show();
          enhanceUnpublishingForm.$submit_button.val('Unpublish');
          break;
      }
    }
  };

  window.GOVUK.enhanceUnpublishingForm = enhanceUnpublishingForm;
}());
{'fraction_non_alphanumeric': 0.1561108362196932, 'fraction_numerical': 0.0, 'mean_word_length': 3.4922222222222223, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5832253', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1145, 'n_words': 121}