<commit_before>/*
	Issue: Pybossa always mark tutorial as seen on serverside after first load 
	no matter user click skip tutorial or user complete the tutorial or not.

	Solution : store tutorial state like "skipped", "complete" in another cookie.

	Other system like 
	- the tutorial template, 
	- login modal 
	can use that cookie to decide to open the tutorial again or not.
*/
(function(){
	//create our own namespace
	var tutorial = window.pybossaTutorial = {};

	//
	tutorial.setStage = setStage;
	tutorial.getStage = getStage;
	tutorial.isSkippedOrComplete = isSkippedOrComplete;
	tutorial.setSkipped = setSkipped;
	tutorial.setComplete = setComplete;

	function setStage(stage) {
		createCookie('decode-darfurtutorial-stage', stage, 120);
	}

	function getStage() {
		return readCookie('decode-darfurtutorial-stage');	
	}

	function isSkippedOrComplete() {
		var state = getStage() ;
		if (state == 'skipped' || state == 'complete') {
			return true;
		}
		return false;
	}

	function setSkipped() {
		setStage('skipped');
	}

	function setComplete() {
		setStage('complete');
	}

	//cookie method
	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}

	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}

	function eraseCookie(name) {
		createCookie(name,"",-1);
	}

})();

(function(){
	// when should we open tutorial 
	// ----------------------------

	//we are in tutorial
	if(window.isInTutorial){
		return;
	}

	//we are in page tutorial
	if (window.location.href.endsWith("/project/decode-darfur/tutorial")) {
		return;
	}

	//use already click skip or complete tutorial
	if (window.pybossaTutorial.isSkippedOrComplete()) {
		return;
	}
	window.location.href = "/project/decode-darfur/tutorial";
	//
})();<commit_msg>not open tutorial when we are in login, register modal<commit_after>/*
	Issue: Pybossa always mark tutorial as seen on serverside after first load 
	no matter user click skip tutorial or user complete the tutorial or not.

	Solution : store tutorial state like "skipped", "complete" in another cookie.

	Other system like 
	- the tutorial template, 
	- login modal 
	can use that cookie to decide to open the tutorial again or not.
*/
(function(){
	//create our own namespace
	var tutorial = window.pybossaTutorial = {};

	//
	tutorial.setStage = setStage;
	tutorial.getStage = getStage;
	tutorial.isSkippedOrComplete = isSkippedOrComplete;
	tutorial.setSkipped = setSkipped;
	tutorial.setComplete = setComplete;

	function setStage(stage) {
		createCookie('decode-darfurtutorial-stage', stage, 120);
	}

	function getStage() {
		return readCookie('decode-darfurtutorial-stage');	
	}

	function isSkippedOrComplete() {
		var state = getStage() ;
		if (state == 'skipped' || state == 'complete') {
			return true;
		}
		return false;
	}

	function setSkipped() {
		setStage('skipped');
	}

	function setComplete() {
		setStage('complete');
	}

	//cookie method
	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}

	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}

	function eraseCookie(name) {
		createCookie(name,"",-1);
	}

})();

(function(){
	// when should we open tutorial 
	// ----------------------------

	//we are in tutorial
	if(window.isInTutorial){
		return;
	}

	//we are in page tutorial
	if (window.location.href.indexOf("/project/decode-darfur/tutorial") !== -1) {
		return;
	}

	//we are in login/register modal
	if (window.location.href.indexOf("?modal=all") !== -1 
		|| window.location.href.indexOf("?modal=login") !== -1 
		|| window.location.href.indexOf("?modal=register") !== -1 
		) {
		return;
	}

	//use already click skip or complete tutorial
	if (window.pybossaTutorial.isSkippedOrComplete()) {
		return;
	}
	window.location.href = "/project/decode-darfur/tutorial";
	//
})();
{'fraction_non_alphanumeric': 0.15976078598889362, 'fraction_numerical': 0.00854335753951303, 'mean_word_length': 3.6183431952662723, 'pattern_counts': {'":': 0, '<': 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': '4202278', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1560, 'n_words': 391}