<commit_before>Template.region_sel.helpers({
	regions: function(){
	  return Regions.find();
	},

	region: function(){
		var region = Regions.findOne(Session.get('region'))
		return region
	}
});

Template.region_sel.events({
	'click a.regionselect': function(e){
		var region_id = this._id ? this._id : 'all';
		var changed = Session.get('region') !== region_id;

		localStorage.setItem("region", region_id); // to survive page reload
		Session.set('region', region_id)

		// Go to the homepage when the region is changed
		if (changed) Router.go('/');

		e.preventDefault();
	}
})<commit_msg>preserve calendar route when switching region<commit_after>Template.region_sel.helpers({
	regions: function(){
	  return Regions.find();
	},

	region: function(){
		var region = Regions.findOne(Session.get('region'))
		return region
	}
});

Template.region_sel.events({
	'click a.regionselect': function(e){
		var region_id = this._id ? this._id : 'all';
		var changed = Session.get('region') !== region_id;

		localStorage.setItem("region", region_id); // to survive page reload
		Session.set('region', region_id)

		// When the region changes, we want the content of the page to update
		// Many pages do not change when the region changed, so we go to
		// the homepage for those
		if (changed) {
			var routeName = Router.current().route.getName();
			var routesToKeep = ['home', 'find', 'locations', 'calendar'];
			console.log(routeName);
			if (routesToKeep.indexOf(routeName) < 0) Router.go('/');
		}
		e.preventDefault();
	}
})
{'fraction_non_alphanumeric': 0.15294117647058825, 'fraction_numerical': 0.00065359477124183, 'mean_word_length': 4.225255972696246, 'pattern_counts': {'":': 0, '<': 4, '<?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': '4981766', 'n_tokens_mistral': 521, 'n_tokens_neox': 478, 'n_words': 131}