<commit_before>/*
 * The GeoTag-X project helper.
 */
(function(geotagx, $, undefined){
	"use strict";

	var api_ = {}; // The project API.
	var shortName_; // The project's short name.

	/**
	 * Begins the project.
	 * @param shortName the project's short name.
	 * @param getNextQuestion a user-defined function that returns the id of the next question to present to the user.
	 */
	api_.start = function(shortName, getNextQuestion){
		if ($.type(shortName) !== "string"){
	        console.log("[geotagx::project::start] Error! Invalid project slug.");
	        return;
	    }
		shortName_ = shortName;

		geotagx.questionnaire.onGetNextQuestion(getNextQuestion);

		pybossa.taskLoaded(onTaskLoaded);
		pybossa.presentTask(onTaskPresented);
		pybossa.run(shortName_);

		geotagx.analytics.start(shortName_);
	};
	/**
	 * Returns the project's short name.
	 */
	api_.getShortName = function(){
		return shortName_;
	};
	/**
	 * Handles PyBossa's taskLoaded event.
	 */
	function onTaskLoaded(task, deferred){
		if (!$.isEmptyObject(task))
			$("<img/>").load(function(){ deferred.resolve(task); }).attr("src", task.info.image_url);
		else
			deferred.resolve(task);
	}
	/**
	 * Handles PyBossa's presentTask event.
	 */
	function onTaskPresented(task, deferred){
		if (!$.isEmptyObject(task)){
			// Show/hide respective elements.
			$(".show-on-task-loaded").removeClass("show-on-task-loaded").hide().fadeIn(200);
			$(".hide-on-task-loaded").hide();

			// Initialize the image to analyze.
			var $image = $("#image");
			if ($image.length > 0){
				$image.attr("src", task.info.image_url);

				$("#image-source").attr("href", task.info.source_uri);
			}
			else
				console.log("[pybossa::presentTask] Error! Could not find image to analyze.");

			// Set the submission button's handler. Note that off().on() removes the previous handler
			// and sets a new one, every time a new task is loaded. This prevents a chain of events
			// being called when a button is pushed once.
			$("#questionnaire-submit").off("click.task").on("click.task", function(){
				var $button = $(this);
				$button.prop("disabled", true);

				// Append the image URL to the questionnaire results.
				var taskRun_ = geotagx.questionnaire.getAnswers();
				taskRun_.img = task.info.image_url;

				pybossa.saveTask(task.id, taskRun_).done(function(){
					geotagx.questionnaire.showFullSummary(false);

					$button.prop("disabled", false);
					deferred.resolve();
				});
			});

			geotagx.questionnaire.start(1);
			geotagx.analytics.onTaskChanged(task.id);
		}
	}
	// Expose the API.
	geotagx.project = api_;
})(window.geotagx = window.geotagx || {}, jQuery);<commit_msg>Improved formatting and error messages.<commit_after>/*
 * The GeoTag-X project helper.
 */
(function(geotagx, $, undefined){
	"use strict";

	var api_ = {}; // The project API.
	var shortName_; // The project's short name.

	/**
	 * Begins the project.
	 * @param shortName the project's short name.
	 * @param getNextQuestion a user-defined function that returns the id of the next question to present to the user.
	 */
	api_.start = function(shortName, getNextQuestion){
		if ($.type(shortName) !== "string"){
			console.log("[geotagx::project::start] Error! Invalid project slug.");
			return;
		}
		shortName_ = shortName;

		geotagx.questionnaire.onGetNextQuestion(getNextQuestion);

		pybossa.taskLoaded(onTaskLoaded);
		pybossa.presentTask(onTaskPresented);
		pybossa.run(shortName_);

		geotagx.analytics.start(shortName_);
	};
	/**
	 * Returns the project's short name.
	 */
	api_.getShortName = function(){
		return shortName_;
	};
	/**
	 * Handles PyBossa's taskLoaded event.
	 */
	function onTaskLoaded(task, deferred){
		if (!$.isEmptyObject(task))
			$("<img/>").load(function(){ deferred.resolve(task); }).attr("src", task.info.image_url);
		else
			deferred.resolve(task);
	}
	/**
	 * Handles PyBossa's presentTask event.
	 */
	function onTaskPresented(task, deferred){
		if (!$.isEmptyObject(task)){
			// Show/hide respective elements.
			$(".show-on-task-loaded").removeClass("show-on-task-loaded").hide().fadeIn(200);
			$(".hide-on-task-loaded").hide();

			// Initialize the image to analyze.
			var $image = $("#image");
			if ($image.length > 0){
				$image.attr("src", task.info.image_url);

				$("#image-source").attr("href", task.info.source_uri);
			}
			else
				console.log("[geotagx::project::onTaskPresented] Error! Could not find image to analyze.");

			// Set the submission button's handler. Note that off().on() removes the previous handler
			// and sets a new one, every time a new task is loaded. This prevents a chain of events
			// being called when a button is pushed once.
			$("#questionnaire-submit").off("click.task").on("click.task", function(){
				var $button = $(this);
				$button.prop("disabled", true);

				// Append the image URL to the questionnaire results.
				var taskRun_ = geotagx.questionnaire.getAnswers();
				taskRun_.img = task.info.image_url;

				pybossa.saveTask(task.id, taskRun_).done(function(){
					geotagx.questionnaire.showFullSummary(false);

					$button.prop("disabled", false);
					deferred.resolve();
				});
			});

			geotagx.analytics.onTaskChanged(task.id);
			geotagx.questionnaire.start(1);
		}
	}
	// Expose the API.
	geotagx.project = api_;
})(window.geotagx = window.geotagx || {}, jQuery);
{'fraction_non_alphanumeric': 0.15918443696221474, 'fraction_numerical': 0.0018705574261129816, 'mean_word_length': 3.6862401402278704, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3850289', 'n_tokens_mistral': 1962, 'n_tokens_neox': 1690, 'n_words': 407}