<commit_before>AutoForm.hooks({
  submitPostForm: {

    before: {
      submitPost: function(doc, template) {
        // automatically check the 'all' checkbox
        var allCategory = $('label:contains("All")').children().attr('value'),
          tempTitle;

        if (!doc.categories) {
          doc.categories = [];
        }

        if (!_.contains(doc.categories, allCategory)) {
          doc.categories.push(allCategory);
        }

        tempTitle = doc.title.toLowerCase();

        if (tempTitle.indexOf('non alcoholic') > -1 || tempTitle.indexOf('non-alcoholic') > -1 || tempTitle.indexOf('nonalcoholic') > -1){
          alert('WHAT IS WRONG WITH YOU? NO! -- ACCESS DENIED');
          return false;
        }

        template.$('button[type=submit]').addClass('loading');

        var post = doc;

        // ------------------------------ Checks ------------------------------ //

        if (!Meteor.user()) {
          flashMessage(i18n.t('you_must_be_logged_in'), 'error');
          return false;
        }

        // ------------------------------ Callbacks ------------------------------ //

        // run all post submit client callbacks on properties object successively
        post = postSubmitClientCallbacks.reduce(function(result, currentFunction) {
            return currentFunction(result);
        }, post);

        return post;
      }
    },

    onSuccess: function(operation, post, template) {
      template.$('button[type=submit]').removeClass('loading');
      trackEvent("new post", {'postId': post._id});
      Router.go('post_page', {_id: post._id});
      if (post.status === STATUS_PENDING) {
        flashMessage(i18n.t('thanks_your_post_is_awaiting_approval'), 'success');
      }
    },

    onError: function(operation, error, template) {
      template.$('button[type=submit]').removeClass('loading');
      flashMessage(error.message.split('|')[0], 'error'); // workaround because error.details returns undefined
      clearSeenMessages();
      // $(e.target).removeClass('disabled');
      if (error.error == 603) {
        var dupePostId = error.reason.split('|')[1];
        Router.go('post_page', {_id: dupePostId});
      }
    }

  }
});
<commit_msg>Fix a JS error<commit_after>AutoForm.hooks({
  submitPostForm: {

    before: {
      submitPost: function(doc, template) {
        // automatically check the 'all' checkbox
        var allCategory = $('label:contains("All")').children().attr('value'),
          tempTitle;

        if (!doc.categories) {
          doc.categories = [];
        }

        if (!_.contains(doc.categories, allCategory)) {
          doc.categories.push(allCategory);
        }

        tempTitle = doc.title ? doc.title.toLowerCase() : '';

        if (tempTitle.indexOf('non alcoholic') > -1 || tempTitle.indexOf('non-alcoholic') > -1 || tempTitle.indexOf('nonalcoholic') > -1){
          alert('WHAT IS WRONG WITH YOU? NO! -- ACCESS DENIED');
          return false;
        }

        template.$('button[type=submit]').addClass('loading');

        var post = doc;

        // ------------------------------ Checks ------------------------------ //

        if (!Meteor.user()) {
          flashMessage(i18n.t('you_must_be_logged_in'), 'error');
          return false;
        }

        // ------------------------------ Callbacks ------------------------------ //

        // run all post submit client callbacks on properties object successively
        post = postSubmitClientCallbacks.reduce(function(result, currentFunction) {
            return currentFunction(result);
        }, post);

        return post;
      }
    },

    onSuccess: function(operation, post, template) {
      template.$('button[type=submit]').removeClass('loading');
      trackEvent("new post", {'postId': post._id});
      Router.go('post_page', {_id: post._id});
      if (post.status === STATUS_PENDING) {
        flashMessage(i18n.t('thanks_your_post_is_awaiting_approval'), 'success');
      }
    },

    onError: function(operation, error, template) {
      template.$('button[type=submit]').removeClass('loading');
      flashMessage(error.message.split('|')[0], 'error'); // workaround because error.details returns undefined
      clearSeenMessages();
      // $(e.target).removeClass('disabled');
      if (error.error == 603) {
        var dupePostId = error.reason.split('|')[1];
        Router.go('post_page', {_id: dupePostId});
      }
    }

  }
});

{'fraction_non_alphanumeric': 0.20273911091154018, 'fraction_numerical': 0.005388414907947912, 'mean_word_length': 2.0702963473466576, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3931190', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1213, 'n_words': 228}