<commit_before>(function (Shreds) {
  var name = 'subscription';

  var $subscribeInput = $('#subscribeInput');
  var $subscribeForm = $('#subscribe_form');
  var $feedUrl = $('#feed_url');
  var $categoryName = $('#category_name');
  var spinner = null;

  Shreds.components.push(name);
  Shreds[name] = {
    activate: function () {
      if ($subscribeInput.is(':hidden')) {
        $subscribeInput.slideDown();
        $feedUrl.focus();
      } else {
        spinner = Ladda.create(this);
        spinner.start();
        $.ajax('/i/feeds.json', {
          method: 'POST',
          data: {
            'feed[url]': $feedUrl.val(),
            'category[name]': $categoryName.val()
          }
        }).done(function (data) {
          if (data && data.watch) {
            Shreds.watch.add(data.watch);
          }
        });
        $feedUrl.val('');
        $categoryName.val('');
        $subscribeInput.slideUp();
      }
    },
    stopSpinner: function () {
      try {
        spinner.stop();
      } catch (e) { }
    },
    init: function () {
      setupDOMEvents();
    }
  };

  function setupDOMEvents() {
    var $doc = $(document);
    var amOut = true;

    $doc.on('mousedown', function (e) {
      if (!$subscribeInput.is(':hidden') && amOut) {
        $subscribeInput.slideUp();
      }
    });<commit_msg>Use form.serialize.<commit_after>(function (Shreds) {
  var name = 'subscription';

  var $subscribeInput = $('#subscribeInput');
  var $subscribeForm = $('#subscribe_form');
  var $feedUrl = $('#feed_url');
  var $categoryName = $('#category_name');
  var spinner = null;

  Shreds.components.push(name);
  Shreds[name] = {
    activate: function () {
      if ($subscribeInput.is(':hidden')) {
        $subscribeInput.slideDown();
        $feedUrl.focus();
      } else {
        spinner = Ladda.create(this);
        spinner.start();
        $.ajax('/i/feeds.json', {
          method: 'POST',
          data: $subscribeForm.find('form').serialize()
        }).done(function (data) {
          if (data && data.watch) {
            Shreds.watch.add(data.watch);
          }
        }).fail(function () {
          spinner.stop();
          Shreds.notification.error('<strong>Can not</strong> add feed at the moment.');
        });
        $feedUrl.val('');
        $categoryName.val('');
        $subscribeInput.slideUp();
      }
    },
    stopSpinner: function () {
      try {
        spinner.stop();
      } catch (e) { }
    },
    init: function () {
      setupDOMEvents();
    }
  };

  function setupDOMEvents() {
    var $doc = $(document);
    var amOut = true;

    $doc.on('mousedown', function (e) {
      if (!$subscribeInput.is(':hidden') && amOut) {
        $subscribeInput.slideUp();
      }
    });
{'fraction_non_alphanumeric': 0.1806966618287373, 'fraction_numerical': 0.0, 'mean_word_length': 2.1329545454545453, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4610839', 'n_tokens_mistral': 870, 'n_tokens_neox': 854, 'n_words': 153}