<commit_before>(function() {
	if( typeof window.addEventListener === 'function' ) {
		var galleryTimer;

		var galleryStep = function (items, iterations) {
			var length = items.length,
				ptr = 0,
				loops = 0;

			return function () {
				if (loops === iterations) {
					return;
				}
				items[ptr].className = "inactive";
				if (ptr === length - 1) {
					loops++;
					if (loops < iterations) {
						ptr = 0;
					}
				} else {
					ptr++;
				}
				items[ptr].className = "active";
			};
		};

		var startupGallery = function (slide) {
			var galleryNode = slide.querySelector('.gallery');
			if (!galleryNode) return; // early exit if no gallery
			console.log("Startup gallery with node", galleryNode);

			var items = Array.prototype.slice.apply(galleryNode.querySelectorAll("li"));
			items.forEach(function (item, index) {
				if (index === 0) {
					item.className = "active";
				} else {
					item.className = "inactive";
				}
				var label = item.querySelector("label");
				if (!label) {
					var img = item.querySelector("img");
					label = document.createElement("label");
					label.innerHTML = img.attributes.alt.value;
					item.appendChild(label);
				}
			});

			galleryTimer = setInterval(galleryStep(items, 1), (galleryNode.dataset.interval || 1) * 1000);
		};

		Reveal.addEventListener("slidechanged", function (event) {
			var galleryNode = event.previousSlide.querySelector('.gallery');

			if (galleryNode) {
				console.log("Gallery on last slide, cleaning up");
				// cleanup
				clearInterval(galleryTimer);
			}

			startupGallery(event.currentSlide);
		});

		if (Reveal.getCurrentSlide()) {
			startupGallery(Reveal.getCurrentSlide());
		}
	}
})();<commit_msg>Fix iterations and cleanup<commit_after>(function() {
	if( typeof window.addEventListener === 'function' ) {
		var galleryTimer;

		var galleryStep = function (items, iterations) {
			var length = items.length,
				ptr = 0,
				loops = 0;

			return function () {
				if (iterations > 0 && loops === iterations) {
					return;
				}
				items[ptr].className = "inactive";
				if (ptr === length - 1) {
					loops++;
					if (iterations === 0 || loops < iterations) {
						ptr = 0;
					}
				} else {
					ptr++;
				}
				items[ptr].className = "active";
			};
		};

		var startupGallery = function (slide) {
			var galleryNode = slide.querySelector('.gallery');
			if (!galleryNode) return; // early exit if no gallery

			var items = Array.prototype.slice.apply(galleryNode.querySelectorAll("li"));
			items.forEach(function (item, index) {
				if (index === 0) {
					item.className = "active";
				} else {
					item.className = "inactive";
				}
				var label = item.querySelector("label");
				if (!label) {
					var img = item.querySelector("img");
					label = document.createElement("label");
					label.innerHTML = img.attributes.alt.value;
					item.appendChild(label);
				}
			});

			var iterations = galleryNode.dataset.iterations ? +galleryNode.dataset.iterations : 1;
			console.log("Iterations is", iterations);
			var interval = (galleryNode.dataset.interval || 1) * 1000;
			galleryTimer = setInterval(galleryStep(items, iterations), interval);
		};

		Reveal.addEventListener("slidechanged", function (event) {
			if (event.previousSlide.querySelector('.gallery')) {
				// cleanup
				clearInterval(galleryTimer);
			}

			startupGallery(event.currentSlide);
		});

		if (Reveal.getCurrentSlide()) {
			startupGallery(Reveal.getCurrentSlide());
		}
	}
})();
{'fraction_non_alphanumeric': 0.15084599942644106, 'fraction_numerical': 0.0068827071981646115, 'mean_word_length': 3.0987074030552293, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '4953591', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1049, 'n_words': 232}