<commit_before>/*
 */
(function(window, navigator) {
	'use strict';
	var document = window.document;
	/*
	 * getUserMedia
	 */
	navigator.getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
	/*
	 * Funky
	 */
	var funky = function() {
		/*
		 * Events
		 */
		this.events = {};
		/*
		 * Container
		 */
		this.container = null;
		/*
		 * Compatibility
		 */
		if(!navigator.getUserMedia) {
			return this.emit('error', { code: funky.ERR_COMPATIBILITY });
		}
		/*
		 * Options
		 */
		if(arguments.length === 0) {
			return this.emit('error', { code: funky.ERR_CONTAINER });
		}
		if(arguments.length === 1) {
			if(typeof arguments[0] === 'string') {
				this.options = {
					container: arguments[0]
				}
			} else {
				this.options = arguments[0] || {};
			}
		} else {
			this.options = {
				container: arguments[0]
			};
			for(var k in arguments[1]) {
				this.options[k] = arguments[1][k];
			}
		}
		if(!this.options.container || document.getElementById(this.options.container) === null) {
			return this.emit('error', { code: funky.ERR_CONTAINER });
		}
		this.container = document.getElementById(this.options.container);
		this.init();
	};

	/*
	 * Errors
	 */
	funky.ERR_OK = 0;
	funky.ERR_COMPATIBILITY = 1;
	funky.ERR_CONTAINER = 2;
	funky.ERR_PERMISSION = 3;

	/*
	 * Initialise
	 */
	funky.prototype.init = function() {
		var self = this;
		/*
		 * Setup the video and canvas elements
		 */
		this.videoBound = {
			width: 0,
			height: 0
		};
		this.video = document.createElement('video');
		this.video.setAttribute('autoplay', true);
		this.frontCanvas = document.createElement('canvas');
		this.frontCanvas.style.width = '100%';
		this.frontCanvas.style.height = '100%';
		this.frontCanvas.style.display = 'none';
		this.backCanvas = document.createElement('canvas');
		this.backCanvas.style.display = 'none';
		this.back = this.backCanvas.getContext('2d');
		this.front = this.frontCanvas.getContext('2d');
		this.container.appendChild(this.video);
		this.container.appendChild(this.frontCanvas);
		/*
		 * Listen for the video to begin playing
		 */
		this.video.addEventListener('play', function() {
			self.videoBound.width = self.video.clientWidth;
			self.videoBound.height = self.video.clientHeight;
			self.video.style.display = 'none';
			self.frontCanvas.style.display = 'block';
			self.frontCanvas.width = self.videoBound.width;
			self.frontCanvas.height = self.videoBound.height;
			self.backCanvas.width = self.videoBound.width;
			self.backCanvas.height = self.videoBound.height;
			clearTimeout(self.ticker);
			self.ticker = setTimeout(function() {
				self.draw.call(self);
			}, 25);
		}, false);
		/*
		 * Request the user media
		 */
		navigator.getUserMedia(
			{ video: true, audio: false },
			function(stream) {
				if(navigator.mozGetUserMedia) {
					self.video.mozSrcObject = stream;
				} else {
					var url = window.URL || window.webkitURL;
					self.video.src = url.createObjectURL(stream);
				}
				self.video.play();
			},
			function(e) {
				self.emit('error', { code: funky.ERR_PERMISSION });
			}
		);
	};
	
	/*
	 * Negative
	 */
	funky.prototype.effectNegative = function(enabled) {
		if(enabled) {
			if('-webkit-filter' in this.frontCanvas.style) {
				this.frontCanvas.style['-webkit-filter'] += ' invert(100%)';
			} else {
				this.frontCanvas.style['-webkit-filter'] = 'invert(100%)';
			}
		} else {
			if('-webkit-filter' in this.frontCanvas.style) {
				this.frontCanvas.style['-webkit-filter'] = this.frontCanvas.style['-webkit-filter'].replace(/ ?invert\(\d+%\)/, '');<commit_msg>Fix to work on modern browser and locally<commit_after>/*
 */
(function(window, navigator) {
	'use strict';
	var document = window.document;
	/*
	 * getUserMedia
	 */
	navigator.getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
	/*
	 * Funky
	 */
	var funky = function() {
		/*
		 * Events
		 */
		this.events = {};
		/*
		 * Container
		 */
		this.container = null;
		/*
		 * Compatibility
		 */
		if(!navigator.getUserMedia) {
			return this.emit('error', { code: funky.ERR_COMPATIBILITY });
		}
		/*
		 * Options
		 */
		if(arguments.length === 0) {
			return this.emit('error', { code: funky.ERR_CONTAINER });
		}
		if(arguments.length === 1) {
			if(typeof arguments[0] === 'string') {
				this.options = {
					container: arguments[0]
				}
			} else {
				this.options = arguments[0] || {};
			}
		} else {
			this.options = {
				container: arguments[0]
			};
			for(var k in arguments[1]) {
				this.options[k] = arguments[1][k];
			}
		}
		if(!this.options.container || document.getElementById(this.options.container) === null) {
			return this.emit('error', { code: funky.ERR_CONTAINER });
		}
		this.container = document.getElementById(this.options.container);
		this.init();
	};

	/*
	 * Errors
	 */
	funky.ERR_OK = 0;
	funky.ERR_COMPATIBILITY = 1;
	funky.ERR_CONTAINER = 2;
	funky.ERR_PERMISSION = 3;

	/*
	 * Initialise
	 */
	funky.prototype.init = function() {
		var self = this;
		/*
		 * Setup the video and canvas elements
		 */
		this.videoBound = {
			width: 0,
			height: 0
		};
		this.video = document.createElement('video');
		this.video.setAttribute('autoplay', true);
		this.frontCanvas = document.createElement('canvas');
		this.frontCanvas.style.width = '100%';
		this.frontCanvas.style.height = '100%';
		this.frontCanvas.style.display = 'none';
		this.backCanvas = document.createElement('canvas');
		this.backCanvas.style.display = 'none';
		this.back = this.backCanvas.getContext('2d');
		this.front = this.frontCanvas.getContext('2d');
		this.container.appendChild(this.video);
		this.container.appendChild(this.frontCanvas);
		/*
		 * Listen for the video to begin playing
		 */
		this.video.addEventListener('play', function() {
			self.videoBound.width = self.video.clientWidth;
			self.videoBound.height = self.video.clientHeight;
			self.video.style.display = 'none';
			self.frontCanvas.style.display = 'block';
			self.frontCanvas.width = self.videoBound.width;
			self.frontCanvas.height = self.videoBound.height;
			self.backCanvas.width = self.videoBound.width;
			self.backCanvas.height = self.videoBound.height;
			clearTimeout(self.ticker);
			self.ticker = setTimeout(function() {
				self.draw.call(self);
			}, 25);
		}, false);
		/*
		 * Request the user media
		 */
		navigator.getUserMedia(
			{ video: true, audio: false },
			function(stream) {
				if(navigator.mozGetUserMedia) {
					self.video.mozSrcObject = stream;
				} else if (typeof self.video.srcObject === "object") {
					self.video.srcObject = stream;
				} else {
					var url = window.URL || window.webkitURL;
					self.video.srcObject = stream;
				}
				self.video.play();
			},
			function(e) {
				self.emit('error', { code: funky.ERR_PERMISSION });
			}
		);
	};
	
	/*
	 * Negative
	 */
	funky.prototype.effectNegative = function(enabled) {
		if(enabled) {
			if('-webkit-filter' in this.frontCanvas.style) {
				this.frontCanvas.style['-webkit-filter'] += ' invert(100%)';
			} else {
				this.frontCanvas.style['-webkit-filter'] = 'invert(100%)';
			}
		} else {
			if('-webkit-filter' in this.frontCanvas.style) {
				this.frontCanvas.style['-webkit-filter'] = this.frontCanvas.style['-webkit-filter'].replace(/ ?invert\(\d+%\)/, '');
{'fraction_non_alphanumeric': 0.16571738540819095, 'fraction_numerical': 0.008136696501220505, 'mean_word_length': 3.2312105565117615, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5164702', 'n_tokens_mistral': 2939, 'n_tokens_neox': 2457, 'n_words': 394}