<commit_before>"use strict";
// routing is in /routing.js

Template.event.onCreated(function() {
	this.editing = new ReactiveVar(!this.data._id);
});


Template.eventDisplay.onCreated(function() {
	this.locationTracker = LocationTracker();
	this.replicating = new ReactiveVar(false);
});


Template.eventDisplay.onRendered(function() {
	this.locationTracker.setRegion(this.data.region);
	this.locationTracker.setLocation(this.data.location);
});


Template.eventPage.helpers({
	course: function() {
		var courseId = this.course_id;
		if (courseId) {
			// Very bad?
			Template.instance().subscribe('courseDetails', courseId);

			return Courses.findOne({_id: courseId});
		}
	},
});


Template.event.helpers({
	editing: function() {
		return this.new || Template.instance().editing.get();
	},
});


Template.eventDisplay.helpers({
	mayEdit: function() {
		return mayEditEvent(Meteor.user(), this);
	},
	eventMarkers: function() {
		return Template.instance().locationTracker.markers;
	},
	haveLocation: function() {
		return this.location && this.location.loc
	},

	replicating: function() {
		return Template.instance().replicating.get();
	}
});

Template.event.events({
	'click button.eventDelete': function () {
		if (pleaseLogin()) return;
		if (confirm('Delete event "'+this.title+'"?')) {
			var title = this.title;
			var course = this.course_id;
			Meteor.call('removeEvent', this._id, function (error, eventRemoved){
				if (eventRemoved) {
					addMessage(mf('event.removed', { TITLE: title }, 'Successfully removed event "{TITLE}".'), 'success');
					if (course) Router.go('showCourse', { _id: course });
				} else {
					addMessage(mf('event.remove.error', { TITLE: title }, 'Error during removal of event "{TITLE}".'), 'danger');
				}
			});
			Template.instance().editing.set(false);
		}
	},

	'click button.eventEdit': function (event, instance) {
		if (pleaseLogin()) return;<commit_msg>go home after deleting event<commit_after>"use strict";
// routing is in /routing.js

Template.event.onCreated(function() {
	this.editing = new ReactiveVar(!this.data._id);
});


Template.eventDisplay.onCreated(function() {
	this.locationTracker = LocationTracker();
	this.replicating = new ReactiveVar(false);
});


Template.eventDisplay.onRendered(function() {
	this.locationTracker.setRegion(this.data.region);
	this.locationTracker.setLocation(this.data.location);
});


Template.eventPage.helpers({
	course: function() {
		var courseId = this.course_id;
		if (courseId) {
			// Very bad?
			Template.instance().subscribe('courseDetails', courseId);

			return Courses.findOne({_id: courseId});
		}
	},
});


Template.event.helpers({
	editing: function() {
		return this.new || Template.instance().editing.get();
	},
});


Template.eventDisplay.helpers({
	mayEdit: function() {
		return mayEditEvent(Meteor.user(), this);
	},
	eventMarkers: function() {
		return Template.instance().locationTracker.markers;
	},
	haveLocation: function() {
		return this.location && this.location.loc
	},

	replicating: function() {
		return Template.instance().replicating.get();
	}
});

Template.event.events({
	'click button.eventDelete': function () {
		if (pleaseLogin()) return;
		if (confirm('Delete event "'+this.title+'"?')) {
			var title = this.title;
			var course = this.course_id;
			Meteor.call('removeEvent', this._id, function (error, eventRemoved){
				if (eventRemoved) {
					addMessage(mf('event.removed', { TITLE: title }, 'Successfully removed event "{TITLE}".'), 'success');
					if (course) {
						Router.go('showCourse', { _id: course });
					} else {
						Router.go('/');
					}
				} else {
					addMessage(mf('event.remove.error', { TITLE: title }, 'Error during removal of event "{TITLE}".'), 'danger');
				}
			});
			Template.instance().editing.set(false);
		}
	},

	'click button.eventEdit': function (event, instance) {
		if (pleaseLogin()) return;
{'fraction_non_alphanumeric': 0.17242268041237113, 'fraction_numerical': 0.0, 'mean_word_length': 4.397774687065368, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6421427', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1236, 'n_words': 237}