<commit_before>Template.calendar.helpers({
  events: function() {
    var fc = $('.fc');
    return function(start, end, tz, callback) {
      Meteor.subscribe('reservations', start.toDate(), end.toDate(), 'America/Los_Angeles', function() {
        fc.fullCalendar('refetchEvents');
      });
      let type = Session.get("type");
      var events = Reservations.find({type: type}).fetch().map(function(it) {
        var color = function () {
          if(it.userId === Meteor.userId()) return "#446CB3";
          else return "#67809F";
        }
        return {
          title: getName(it.userId),
          start: it.date,
          allDay: true,
          id: it._id,
          color: color()
        };
      });
      callback(events);
    }
  },
  onEventClicked: function() {
    return function(calEvent, jsEvent, view) {
      var resId = calEvent.id;
      Session.set("selectedRes", resId);
    }
  },
  onDayClicked: function() {
    return function(date, jsEvent, view) {
      let dateClicked = date.toDate();
      dateClicked.setHours(24);
      if(Reservations.findOne({date: dateClicked})) {
        return false;
      }
      Session.set("showCreate", true);
      let year = date.get("year");
      let month = date.get("month") + 1;
      let day = date.get("date");
      if(day < 10) {
        day = "0"+day;
      }
      $('#date').val(year + "-" + month + "-" + day);
    }
  }
});

function getName(userId) {
  if(userId === Meteor.userId()) return "You";
  else return Meteor.users.findOne({
    _id: userId
  }).profile.firstName || userId;
}

Template.calendar.rendered = function() {
  var fc = this.$('.fc');
  var type = Session.get("type");
  this.autorun(function() {
    var res = Reservations.find({type: type}).fetch();
    fc.fullCalendar('refetchEvents');
  });
}<commit_msg>fixed bug with selecting date from calendar<commit_after>Template.calendar.helpers({
  events: function() {
    var fc = $('.fc');
    return function(start, end, tz, callback) {
      Meteor.subscribe('reservations', start.toDate(), end.toDate(), 'America/Los_Angeles', function() {
        fc.fullCalendar('refetchEvents');
      });
      let type = Session.get("type");
      var events = Reservations.find({type: type}).fetch().map(function(it) {
        var color = function () {
          if(it.userId === Meteor.userId()) return "#446CB3";
          else return "#67809F";
        }
        return {
          title: getName(it.userId),
          start: it.date,
          allDay: true,
          id: it._id,
          color: color()
        };
      });
      callback(events);
    }
  },
  onEventClicked: function() {
    return function(calEvent, jsEvent, view) {
      var resId = calEvent.id;
      Session.set("selectedRes", resId);
    }
  },
  onDayClicked: function() {
    return function(date, jsEvent, view) {
      let dateClicked = date.toDate();
      dateClicked.setHours(24);
      if(Reservations.findOne({date: dateClicked})) {
        return false;
      }
      Session.set("showCreate", true);
      let year = date.get("year");
      let month = date.get("month") + 1;
      let day = date.get("date");
      if(day < 10) {
        day = "0"+day;
      }
      if(month < 10) {
        month = "0"+month;
      }
      $('#date').val(year + "-" + month + "-" + day);
    }
  }
});

function getName(userId) {
  if(userId === Meteor.userId()) return "You";
  else return Meteor.users.findOne({
    _id: userId
  }).profile.firstName || userId;
}

Template.calendar.rendered = function() {
  var fc = this.$('.fc');
  var type = Session.get("type");
  this.autorun(function() {
    var res = Reservations.find({type: type}).fetch();
    fc.fullCalendar('refetchEvents');
  });
}
{'fraction_non_alphanumeric': 0.17221030042918456, 'fraction_numerical': 0.008851931330472103, 'mean_word_length': 2.443213296398892, 'pattern_counts': {'":': 0, '<': 6, '<?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': '5252114', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1202, 'n_words': 244}