<commit_before>;var CookiesCnilBanner;

(function(navigator, window, document){
	CookiesCnilBanner = function(launchFunction){
		if(!(this instanceof CookiesCnilBanner)){
	        return new CookiesCnilBanner(launchFunction);
		}

		this.cookieTimeout = 33696000000; // 13 months in milliseconds
		this.bots = /bot|googlebot|crawler|spider|robot|crawling/i;
		this.trackingCookiesNames = ["__utma","__utmb","__utmc","__utmt","__utmv","__utmz","_ga","_gat"];
		this.launchFunction = launchFunction;
		this.init();
	};

	CookiesCnilBanner.prototype = {
		init: function(){
			// Do nothing if it is a bot
			// If DoNotTrack is activated, do nothing too
			if(this.isBot() || !this.isToTrack() || this.hasConsent() === false){
				return false;
			}

			// User has already consent to use cookies to tracking
			if(this.hasConsent() === true){
				// Launch user custom function
				this.launchFunction();
				return true;
			}

			// If it's not a bot, no DoNotTrack and not already accept : show banner
			this.showBanner();

			// By default, accept cookies for the next if user do nothing
			this.setCookie('hasConsent', true);
		},

		/*
		 * Check if user already consent
		 */
		hasConsent: function(){
			if(document.cookie.indexOf("hasConsent=true") > -1){
				return true;
			} else if(document.cookie.indexOf("hasConsent=false") > -1){
				return false;
			}
			return null;
		},

		/*
		 * Detect if the visitor is a bot or not
		 * Prevent for search engine take the cookie
		 * alert message as main content of the page
		 */
		isBot: function(){
			return this.bots.test(navigator.userAgent);
		},

		/*
		 * Check if DoNotTrack is activated
		 */
	    isToTrack: function() {
	    	var dnt = navigator.doNotTrack || navigator.msDoNotTrack || window.doNotTrack;
	        return (dnt !== undefined) ? (dnt && dnt !== 'yes' && dnt !== 1 && dnt !== "1") : true;
	    },

	    /*
	     * Delete existants tracking cookies
	     */
	    deleteTrackingCookies: function(){
	    	var name;
	    	for(name in this.trackingCookiesNames){
	    		this.deleteCookie(name);
	    	}
	    },

	    setCookie: function(name, value){
		    var date = new Date();
		    date.setTime(date.getTime() + this.cookieTimeout);

	    	document.cookie = name + "=" + hasconsent + "; expires=" + date.toGMTString() + "; path=/";
	    },

	    deleteCookie: function(name){
	        var hostname = document.location.hostname;
	        if(hostname.indexOf("www.") === 0){
	            hostname = hostname.substring(4);
	        }     
	        document.cookie = name + "=;path=/;domain=." + hostname + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	    }
	};
})(navigator, window, document);<commit_msg>Clean code<commit_after>;var CookiesCnilBanner;

(function(navigator, window, document){
	CookiesCnilBanner = function(launchFunction){
		if(!(this instanceof CookiesCnilBanner)){
	        return new CookiesCnilBanner(launchFunction);
		}

		this.cookieTimeout = 33696000000; // 13 months in milliseconds
		this.bots = /bot|googlebot|crawler|spider|robot|crawling/i;
		this.trackingCookiesNames = ["__utma","__utmb","__utmc","__utmt","__utmv","__utmz","_ga","_gat"];
		this.launchFunction = launchFunction;
		this.init();
	};

	CookiesCnilBanner.prototype = {
		init: function(){
			// Do nothing if it is a bot
			// If DoNotTrack is activated, do nothing too
			if(this.isBot() || !this.isToTrack() || this.hasConsent() === false){
				return false;
			}

			// User has already consent to use cookies to tracking
			if(this.hasConsent() === true){
				// Launch user custom function
				this.launchFunction();
				return true;
			}

			// If it's not a bot, no DoNotTrack and not already accept : show banner
			this.showBanner();

			// By default, accept cookies for the next if user do nothing
			this.setCookie('hasConsent', true);
		},

		/*
		 * Check if user already consent
		 */
		hasConsent: function(){
			if(document.cookie.indexOf("hasConsent=true") > -1){
				return true;
			} else if(document.cookie.indexOf("hasConsent=false") > -1){
				return false;
			}
			return undefined;
		},

		/*
		 * Detect if the visitor is a bot or not
		 * Prevent for search engine take the cookie
		 * alert message as main content of the page
		 */
		isBot: function(){
			return this.bots.test(navigator.userAgent);
		},

		/*
		 * Check if DoNotTrack is activated
		 */
	    isToTrack: function() {
	    	var dnt = navigator.doNotTrack || navigator.msDoNotTrack || window.doNotTrack;
	        return (dnt !== undefined) ? (dnt && dnt !== 'yes' && dnt !== 1 && dnt !== "1") : true;
	    },

	    /*
	     * Delete existants tracking cookies
	     */
	    deleteTrackingCookies: function(){
	    	var name;
	    	for(name in this.trackingCookiesNames){
	    		this.deleteCookie(name);
	    	}
	    },

	    /*
	     * Create/update cookie
	     */
	    setCookie: function(name, value){
		    var date = new Date();
		    date.setTime(date.getTime() + this.cookieTimeout);

	    	document.cookie = name + "=" + value + ";expires=" + date.toGMTString() + ";path=/";
	    },

	    /*
	     * Delete cookie by changing expire
	     */
	    deleteCookie: function(name){
	        var hostname = document.location.hostname;
	        if(hostname.indexOf("www.") === 0){
	            hostname = hostname.substring(4);
	        }     
	        document.cookie = name + "=;path=/;domain=." + hostname + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	    }
	};
})(navigator, window, document);
{'fraction_non_alphanumeric': 0.14217749313815187, 'fraction_numerical': 0.011344922232387923, 'mean_word_length': 2.8656294200848658, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7020614', 'n_tokens_mistral': 2032, 'n_tokens_neox': 1691, 'n_words': 427}