<commit_before>var $select;

Template.bookmarkSubmit.events({
    'submit form': function(events) {
        events.preventDefault();
        var user = Meteor.user();
        if (user !== null) {
            var tags = ParsedTags($(events.target).find('[name=tags]').val());
            var tabGroup = [];
            if ($select) {
                for (var i = 0; i < $select[0].selectize.items.length; i++) {
                    tabGroup.push($select[0].selectize.getItem($select[0].selectize.items[i]).text());
                };
            }
            var groups = ParsedGroups(tabGroup);
            var bookmark = {
                url: $(events.target).find('[name=url]').val(),
                title: $(events.target).find('[name=title]').val(),
                description: $(events.target).find('[name=description]').val(),
                tags: tags,
                groups: groups,
                userId: user._id
            };
            if (bookmark.url.indexOf("://") == -1) bookmark.url = "http://" + bookmark.url;
            CreatedTags(tags);
            Meteor.call('bookmarkInsert', bookmark, function(error, result) {
                if (error) return alert(error.reason);
                if (!result.success) {
                    DisplayErrorSubmit(result.message);
                    return;
                }
                Router.go('/home');
            });
        } else DisplayErrorSubmit("You need to be connected.");
    }
});

Template.bookmarkSubmit.helpers({
    'allGroups': function() {
        return Groups.find();
    }
});

Template.bookmarkSubmit.rendered = function() {

    $select = $('#groups').selectize({
        maxItems: null,
        valueField: 'id',
        labelField: 'title',
        searchField: 'title',
        options: [],
        create: false
    });

    var control = $select[0].selectize;

    var groups = Groups.find().fetch();

    for (var x = 0; x < groups.length; x++) {
        control.addOption({
            id: x,
            title: "@" + groups[x].name
        });
        if (this.data.groups.indexOf(groups[x]._id) != -1) {
            control.addItem(x);
        }
    }
};<commit_msg>format code && set focus to url when entering page<commit_after>var $select;

Template.bookmarkSubmit.events({
  'submit form': function(events) {
    events.preventDefault();
    var user = Meteor.user();
    if (user !== null) {
      var tags = ParsedTags($(events.target).find('[name=tags]').val());
      var tabGroup = [];
      if ($select) {
        for (var i = 0; i < $select[0].selectize.items.length; i++) {
          tabGroup.push($select[0].selectize.getItem($select[0].selectize.items[i]).text());
        };
      }
      var groups = ParsedGroups(tabGroup);
      var bookmark = {
        url: $(events.target).find('[name=url]').val(),
        title: $(events.target).find('[name=title]').val(),
        description: $(events.target).find('[name=description]').val(),
        tags: tags,
        groups: groups,
        userId: user._id
      };
      if (bookmark.url.indexOf("://") == -1) bookmark.url = "http://" + bookmark.url;
      CreatedTags(tags);
      Meteor.call('bookmarkInsert', bookmark, function(error, result) {
        if (error) return alert(error.reason);
        if (!result.success) {
          DisplayErrorSubmit(result.message);
          return;
        }
        Router.go('/home');
      });
    } else DisplayErrorSubmit("You need to be connected.");
  }
});

Template.bookmarkSubmit.helpers({
  'allGroups': function() {
    return Groups.find();
  }
});

Template.bookmarkSubmit.rendered = function() {
  $('input[name="url"]').focus();
  
  $select = $('#groups').selectize({
    maxItems: null,
    valueField: 'id',
    labelField: 'title',
    searchField: 'title',
    options: [],
    create: false
  });

  var control = $select[0].selectize;

  var groups = Groups.find().fetch();

  for (var x = 0; x < groups.length; x++) {
    control.addOption({
      id: x,
      title: "@" + groups[x].name
    });
    if (this.data.groups.indexOf(groups[x]._id) != -1) {
      control.addItem(x);
    }
  }
};
{'fraction_non_alphanumeric': 0.17582949866795836, 'fraction_numerical': 0.003875030273674013, 'mean_word_length': 2.082089552238806, 'pattern_counts': {'":': 2, '<': 7, '<?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': '1074553', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1222, 'n_words': 235}