<commit_before>Template.addMangaForUserStep2.onRendered(function() {
	Session.set("toggle", 0);
});

Template.addMangaForUserStep2.helpers({
	manga: function() {
		var manga = MangasData.findOne({
			'_id': Router.current().params._id
		});
		var tomes = Mangas.find({
			'user': Meteor.userId(),
			'name': manga.names.fr
		}, {
			sort: {
				number: 1
			}
		}).fetch();
		for (var i = 0; i < manga.tomes.length; i++) {
			if (tomes[i].number === manga.tomes[i].number) {
				manga.tomes[i].owned = tomes[i].owned
			}
		}
		return manga;
	}
});

Template.addMangaForUserStep2.events({
	"click .grid-item": function(e, t) {
		e.preventDefault();
		return $(e.target).parents(".grid-item").find("button").toggleClass("btn-default btn-success");
	},
	"click .ownThemAll": function(e, t) {
		e.preventDefault();
		if (Session.get("toggle") === 0) {
			$(".addToCollection").removeClass("btn-default").addClass("btn-success");
			Session.set("toggle", 1);
		} else {
			$(".addToCollection").removeClass("btn-success").addClass("btn-default");
			Session.set("toggle", 0);
		}
		return $(".ownThemAll").toggleClass("btn-primary btn-warning");
	},
	"click .addTomes": function(e, t) {
		var manga = this;
		e.preventDefault();
		$('.mangas').each(function(index, element) {
			if (index + 1 === manga.tomes[index].number) {
				var tomeData = manga.tomes[index];
				var tome = {
					title: tomeData.title || "",
					user: Meteor.userId(),<commit_msg>Add tomes only if length !== 0<commit_after>Template.addMangaForUserStep2.onRendered(function() {
	Session.set("toggle", 0);
});

Template.addMangaForUserStep2.helpers({
	manga: function() {
		var manga = MangasData.findOne({
			'_id': Router.current().params._id
		});
		var tomes = Mangas.find({
			'user': Meteor.userId(),
			'name': manga.names.fr
		}, {
			sort: {
				number: 1
			}
		}).fetch();
		if (tomes.length !== 0) {
			for (var i = 0; i < manga.tomes.length; i++) {
				if (tomes[i].number === manga.tomes[i].number) {
					manga.tomes[i].owned = tomes[i].owned;
				}
			}
		}
		return manga;
	}
});

Template.addMangaForUserStep2.events({
	"click .grid-item": function(e, t) {
		e.preventDefault();
		return $(e.target).parents(".grid-item").find("button").toggleClass("btn-default btn-success");
	},
	"click .ownThemAll": function(e, t) {
		e.preventDefault();
		if (Session.get("toggle") === 0) {
			$(".addToCollection").removeClass("btn-default").addClass("btn-success");
			Session.set("toggle", 1);
		} else {
			$(".addToCollection").removeClass("btn-success").addClass("btn-default");
			Session.set("toggle", 0);
		}
		return $(".ownThemAll").toggleClass("btn-primary btn-warning");
	},
	"click .addTomes": function(e, t) {
		var manga = this;
		e.preventDefault();
		$('.mangas').each(function(index, element) {
			if (index + 1 === manga.tomes[index].number) {
				var tomeData = manga.tomes[index];
				var tome = {
					title: tomeData.title || "",
					user: Meteor.userId(),
{'fraction_non_alphanumeric': 0.20899560365235034, 'fraction_numerical': 0.0074399729455529254, 'mean_word_length': 3.8097560975609754, 'pattern_counts': {'":': 6, '<': 5, '<?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': '4230781', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1071, 'n_words': 179}