<commit_before>if (Meteor.isClient) {

  // update title and navigation when visiting a space
  Deps.autorun(function () {
    var space = Spaces.findOne(Session.get("currentSpace"));
    if (space) {
      document.title = space.name;
      Router.navigate(space._id + '/' + slugify(space.name))
    } else
      document.title = "smallspace";
  });


  Deps.autorun(function() {
    var spaceId = Session.get('currentSpace');
    if (spaceId) {
      Meteor.subscribe('messages', spaceId);
      Meteor.subscribe('links', spaceId);
      Meteor.subscribe('space-invites', spaceId);
      Meteor.subscribe('space-memberships', spaceId);
      Meteor.subscribe('calendarEvents', spaceId);
    }
  });

  Deps.autorun(function() {
    var ms = Memberships.find().fetch();
    var is = Invites.find().fetch();
    var spaceIds = _.pluck(ms.concat(is), 'spaceId');
    Meteor.subscribe('spaces', spaceIds);
  });

  Deps.autorun(function() {
    var inviteId = Session.get('currentInviteId');
    if (inviteId) {
      var userId = Meteor.userId();
      // make sure this current invite is set to this user
      Invites.update(inviteId, { $set: { userId: Meteor.userId() } });
    }
  });

  Meteor.subscribe('my-memberships');
  Meteor.subscribe('my-invites');

  // XXX this is BAD
  Meteor.subscribe('allUserData');

  Accounts.ui.config({
    passwordSignupFields: 'USERNAME_AND_EMAIL'
  });

  Template.header.helpers({
    currentSpace: function() {
      var space = Spaces.findOne({_id: Session.get('currentSpace')})
      return space && space.name;
    }
  });

  Template.header.events = {
    'click .title': function(e) {
      Router.setSpace(null);
      return false;
    }
  }

  Template.space.isMember = function() {
    return Memberships.findOne({spaceId: Session.get('currentSpace'), userId: Meteor.userId()});
  }

  Template.myInvitiationItem.events = {
    'click a.accept': function(e) {
      var invitation = this;
      Meteor.call('acceptInvite', invitation, function(err, result) {
        Router.setSpace(invitation.spaceId);
      });
      return false;
    }
  }

  Template.spaceList.helpers({
    memberSpaces: function() {
      var spaceIds = _.pluck(Memberships.find().fetch(), 'spaceId');
      return Spaces.find({_id: {$in: spaceIds}});
    },

    invitations: function() {
      return Invites.find({ $or: [ { email: Meteor.user().emails[0].address },
                                   { userId: Meteor.userId() } ]
                          });
    }
  });

  Template.spaceList.events = {
    'click .new': function(e) {
      var name = prompt('new space name:');
      Meteor.call('createSpace', {name: name}, function(err, result) {
        console.log(err, result);
        Router.setSpace(result);
      });
      return false;
    }
  }
  Template.spaceListItem.helpers({
    image: function() {
      return this.image || 'http://www.gravatar.com/avatar/'+md5(this._id)+'.jpg?d=monsterid&s=200'
    }
  });

  Template.spaceListItem.events = {
    'click': function(e) {
      Router.setSpace(this._id);
      return false;
    }
  }

  Template.chatWindow.helpers({
    messages: function() {
      return Messages.find({spaceId: Session.get('currentSpace')});
    }
  });
  Template.chatWindow.events = {
    "submit form": function(e) {
      var $input = $(e.target).find('input');
      $input.attr('disabled', true);
      Meteor.call('post', {text: $input.val(), spaceId: Session.get('currentSpace')},
                  function(err, result) {
                    if (!err) {
                      $input.attr('disabled', false).val('');
                    }
      });
      return false;
    }
  }
  Template.chatWindow.rendered = function() {
    resizeChat();
    scrollChat();
  }

  Template.rightSideNav.rendered = function() {
    resizeChat();
  }

  Template.rightSideNav.events = {
    // XXX hack to render calendar which is initally setup when the tab is hidden: http://arshaw.com/fullcalendar/docs/display/render/
    'click a[href=#calendarTab]': function() {
      Meteor.setTimeout(function() { $('.calendar').fullCalendar('render'); }, 0);
    }
  }

  Template.message.when = function() {
    return moment(this.created).format("HH:mm");
  }<commit_msg>clear input after submitting chat<commit_after>if (Meteor.isClient) {

  // update title and navigation when visiting a space
  Deps.autorun(function () {
    var space = Spaces.findOne(Session.get("currentSpace"));
    if (space) {
      document.title = space.name;
      Router.navigate(space._id + '/' + slugify(space.name))
    } else
      document.title = "smallspace";
  });


  Deps.autorun(function() {
    var spaceId = Session.get('currentSpace');
    if (spaceId) {
      Meteor.subscribe('messages', spaceId);
      Meteor.subscribe('links', spaceId);
      Meteor.subscribe('space-invites', spaceId);
      Meteor.subscribe('space-memberships', spaceId);
      Meteor.subscribe('calendarEvents', spaceId);
    }
  });

  Deps.autorun(function() {
    var ms = Memberships.find().fetch();
    var is = Invites.find().fetch();
    var spaceIds = _.pluck(ms.concat(is), 'spaceId');
    Meteor.subscribe('spaces', spaceIds);
  });

  Deps.autorun(function() {
    var inviteId = Session.get('currentInviteId');
    if (inviteId) {
      var userId = Meteor.userId();
      // make sure this current invite is set to this user
      Invites.update(inviteId, { $set: { userId: Meteor.userId() } });
    }
  });

  Meteor.subscribe('my-memberships');
  Meteor.subscribe('my-invites');

  // XXX this is BAD
  Meteor.subscribe('allUserData');

  Accounts.ui.config({
    passwordSignupFields: 'USERNAME_AND_EMAIL'
  });

  Template.header.helpers({
    currentSpace: function() {
      var space = Spaces.findOne({_id: Session.get('currentSpace')})
      return space && space.name;
    }
  });

  Template.header.events = {
    'click .title': function(e) {
      Router.setSpace(null);
      return false;
    }
  }

  Template.space.isMember = function() {
    return Memberships.findOne({spaceId: Session.get('currentSpace'), userId: Meteor.userId()});
  }

  Template.myInvitiationItem.events = {
    'click a.accept': function(e) {
      var invitation = this;
      Meteor.call('acceptInvite', invitation, function(err, result) {
        Router.setSpace(invitation.spaceId);
      });
      return false;
    }
  }

  Template.spaceList.helpers({
    memberSpaces: function() {
      var spaceIds = _.pluck(Memberships.find().fetch(), 'spaceId');
      return Spaces.find({_id: {$in: spaceIds}});
    },

    invitations: function() {
      return Invites.find({ $or: [ { email: Meteor.user().emails[0].address },
                                   { userId: Meteor.userId() } ]
                          });
    }
  });

  Template.spaceList.events = {
    'click .new': function(e) {
      var name = prompt('new space name:');
      Meteor.call('createSpace', {name: name}, function(err, result) {
        console.log(err, result);
        Router.setSpace(result);
      });
      return false;
    }
  }
  Template.spaceListItem.helpers({
    image: function() {
      return this.image || 'http://www.gravatar.com/avatar/'+md5(this._id)+'.jpg?d=monsterid&s=200'
    }
  });

  Template.spaceListItem.events = {
    'click': function(e) {
      Router.setSpace(this._id);
      return false;
    }
  }

  Template.chatWindow.helpers({
    messages: function() {
      return Messages.find({spaceId: Session.get('currentSpace')});
    }
  });
  Template.chatWindow.events = {
    "submit form": function(e) {
      var $input = $(e.target).find('input');
      Meteor.call('post', {text: $input.val(), spaceId: Session.get('currentSpace')},
                  function(err, result) {
                  });
      $input.val('');
      return false;
    }
  }
  Template.chatWindow.rendered = function() {
    resizeChat();
    scrollChat();
  }

  Template.rightSideNav.rendered = function() {
    resizeChat();
  }

  Template.rightSideNav.events = {
    // XXX hack to render calendar which is initally setup when the tab is hidden: http://arshaw.com/fullcalendar/docs/display/render/
    'click a[href=#calendarTab]': function() {
      Meteor.setTimeout(function() { $('.calendar').fullCalendar('render'); }, 0);
    }
  }

  Template.message.when = function() {
    return moment(this.created).format("HH:mm");
  }
{'fraction_non_alphanumeric': 0.1621847735149994, 'fraction_numerical': 0.0014342058085335247, 'mean_word_length': 2.755834829443447, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '292698', 'n_tokens_mistral': 2717, 'n_tokens_neox': 2618, 'n_words': 469}