{"size": 1863, "ext": "js", "max_stars_repo_path": "client/views/projects/projectView/projectView.js", "max_stars_repo_name": "GAWKmdk/Kickstarter-Template", "max_stars_repo_stars_event_min_datetime": "2015-06-04T07:45:42.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-11T15:58:11.000Z", "max_issues_repo_path": "client/views/projects/projectView/projectView.js", "max_issues_repo_name": "GAWKmdk/Kickstarter-Template", "max_issues_repo_issues_event_min_datetime": "2015-06-12T11:07:54.000Z", "max_issues_repo_issues_event_max_datetime": "2016-09-13T18:55:07.000Z", "max_forks_repo_path": "client/views/projects/projectView/projectView.js", "max_forks_repo_name": "GAWKmdk/Kickstarter-Template", "max_forks_repo_forks_event_min_datetime": "2016-02-04T20:37:12.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-26T21:24:08.000Z"}
{"max_stars_count": 29, "max_issues_count": 2, "max_forks_count": 8, "avg_line_length": 26.6142857143, "max_line_length": 69, "alphanum_fraction": 0.5480407944}
Template.projectView.events({
  "click .edit": function () {
    var path = '/projects/' + this.slug + '/edit';
    Router.go(path);
  },
  "click .delete": function () {
    if (confirm("Are you sure you want to delete this?")){
      Meteor.call("deleteProject", this._id);
    }
  },
  'click #submit-comment': function () {
    var text = document.getElementById('comment-box').value;
    Meteor.call('addProjectComment', this._id, 0, text);
  },
  'click #fund': function () {
    bootbox.dialog({
      title: this.title,
      message: '<div class="row">  ' +
      '<div class="col-md-12"> ' +
      '<h3>Let\'s choose your reward!</h3>' + 
      '</div> </div>',
      buttons: {
        success: {
          label: "Continue",
          className: "btn-success",
          callback: function () {
            var name = $('#name').val();
            var answer = $("input[name='awesomeness']:checked").val()
          }
        }
      }
    }
    );
  }
});

Template.projectView.helpers({
  isOwner: function () {
    return this.ownerId === Meteor.userId();
  },
  projectComments: function () {
    return Comments.find({projectId:this._id});
  },
  submittedAgo: function () {
    return moment(this.createTimeActual, moment.ISO_8601).fromNow();
  },
  numComments: function () {
    var numComments = Comments.find({projectId: this._id}).count();
    if (numComments === 1) {
      return '1 comment';
    }
    else
      return numComments + ' comments';
  },
  processedTags: function () {
    var oldTags = this.tags;
    var newTags = [oldTags.length];
    var processedTags = '';

    for (var i = 0; i < oldTags.length; i++) {
      newTags[i] = '<a href="#">#' + oldTags[i] + '</a> ';
    }

    for (var k = 0; k < oldTags.length; k++) {
      processedTags = processedTags + newTags[k] + ' ';
    }
    
    return processedTags;
  }
});