<commit_before>var caman, filters, updateFilters;

$(document).ready(function() {

	var booleanA, booleanB, gObject = {}.hasOwnProperty;

	original_images_src = [];
	photo_count = 1;
	caman = null;
	filters = {};
	imageFilters = [];
	booleanA = false;
	booleanB = false;

	updateFilters = _.throttle(function(){
		var index = $("#canvas").attr("index");
		imageFilters[index] = filters;
		var filter, value;
		if (booleanA) {
			booleanB = true;
			return;
		} else {
			booleanB = false;
		}
		booleanA = true;
		caman.revert(false);
		for (var filter in filters) {
			if (!gObject.call(filters, filter)) {
				continue;
			}
			value = filters[filter];
			value = parseFloat(value, 10);
			if (value === 0) {
				continue;
			}
			caman[filter](value);
		}
		return caman.render(function () {
			$("#filmstrip img")[index].src = canvas.toDataURL('image/png');
			var filterstring = filtersToString(filters);
			$("#filmstrip img")[index].filterstring = filterstring;
			booleanA = false;
			if (booleanB) {
				return updateFilters();
			}
		});
	}, 300);

	function restoreImageFilter() {
		var index = $("#canvas").attr("index");
		var filter = imageFilters[index];
		for (var type in filter) {
			var value = filter[type];
			value = parseFloat(value, 10);
			if (value === 0) {
				continue;
			}
			caman[type](value);
		}
		caman.render();

	}
	
	// SOCKETS
	// var connection = new WebSocket("ws://athena.dialup.mit.edu:1234", 'control-protocol');
	// connection.onopen = function(event){
	// 	console.log("Connection open...");
	// }
	// connection.onclose = function(event){
	// 	console.log("Connection closed...");
	// }
	// connection.addEventListener("message", function(event) {
	// 	console.log(event.data);
	// 	results = event.data.split(",");
	// 	switch(results[0]){
	// 		case "TakePhoto":
	// 			countdown();
	// 			break;
	// 		case "Back":
	// 			goBack();
	// 			break;
	// 		case "PressEmail":
	// 			break;
	// 		case "SendEmail":
	// 			break;
	// 		case "CancelEmail":
	// 			break;
	// 		case "Facebook":
	// 			break;
	// 		case "Twitter":
	// 			break;
	// 	}
	// });

	$("#camera").css({"border" : "0px"});
	$(".editor").hide();
	$(".setting").show();

	var streaming	= false,
		video		= document.querySelector('#video'),
		canvas		= document.querySelector('#canvas'),
		width		= $("#video").width(),
		height		= $("#video").height(),
		data		= [],
		newdata,
		camal;

	navigator.getMedia = ( navigator.getUserMedia ||
						navigator.webkitGetUserMedia ||
						navigator.mozGetUserMedia ||
						navigator.msGetUserMedia);

	navigator.getMedia(
		{
			video: true,
			audio: false
		},
		function(stream) {
			
			// Create Video Feed
			if (navigator.mozGetUserMedia) {
				video.mozSrcObject = stream;
			} else {
				var vendorURL = window.URL || window.webkitURL;
				video.src = vendorURL.createObjectURL(stream);
			}
			
			// Start Video Feed
			video.play();
			var vendorURL = window.URL || window.webkitURL;
			video.src = vendorURL.createObjectURL(stream);

		},
		function(err) {
			console.log("An error occured! " + err);
		}
	);

	video.addEventListener('canplay', function(ev){
		
		// Other Initial Display Initializers
		$("#start_button").css("display", "inline-block");
		$("#settings_button").css({"display" : "inline-block", "height" : "50px", "width" : "50px"});
		$("#camera").css({"border" : "15px solid black"});
		
		if (!streaming) {
			height = video.videoHeight / (video.videoWidth/width);
			streaming = true;
		}
	}, false);

	function countdown() {
		$(".pre-photo_button").attr("disabled", "disabled");
		var times = parseInt($("input[name='times']").val());
		if ($("input[name='countdown']").is(":checked")){
			$("#count3").fadeIn(500,function(){
				$("#count3").fadeOut(500,function(){
					$("#count2").fadeIn(500,function(){
						$("#count2").fadeOut(500,function(){
							$("#count1").fadeIn(500,function(){
								$("#count1").fadeOut(function(){
									multiplePhotos(times);
								});
							});
							// PLAY 3rd sound
						});
					});
					// PLAY 2nd sound
				});
			});
			// PLAY 1st sound
		} else {
			multiplePhotos(times);
		}
	}

	function multiplePhotos(times) {
		if (times == 0){
			// Animations for last picture
			$(".pre-photo_button").removeAttr("disabled");
			$(".pre-photo_button").css("display", "none");
			$("#settings_button").css({"width" : "110px", "height" : "50px"});
			$(".post-photo_button").css("display", "inline-block");
			$(canvas).attr("index", $("#filmstrip img").length - 1);<commit_msg>Fix width of settings button<commit_after>var caman, filters, updateFilters;

$(document).ready(function() {

	var booleanA, booleanB, gObject = {}.hasOwnProperty;

	original_images_src = [];
	photo_count = 1;
	caman = null;
	filters = {};
	imageFilters = [];
	booleanA = false;
	booleanB = false;

	updateFilters = _.throttle(function(){
		var index = $("#canvas").attr("index");
		imageFilters[index] = filters;
		var filter, value;
		if (booleanA) {
			booleanB = true;
			return;
		} else {
			booleanB = false;
		}
		booleanA = true;
		caman.revert(false);
		for (var filter in filters) {
			if (!gObject.call(filters, filter)) {
				continue;
			}
			value = filters[filter];
			value = parseFloat(value, 10);
			if (value === 0) {
				continue;
			}
			caman[filter](value);
		}
		return caman.render(function () {
			$("#filmstrip img")[index].src = canvas.toDataURL('image/png');
			var filterstring = filtersToString(filters);
			$("#filmstrip img")[index].filterstring = filterstring;
			booleanA = false;
			if (booleanB) {
				return updateFilters();
			}
		});
	}, 300);

	function restoreImageFilter() {
		var index = $("#canvas").attr("index");
		var filter = imageFilters[index];
		for (var type in filter) {
			var value = filter[type];
			value = parseFloat(value, 10);
			if (value === 0) {
				continue;
			}
			caman[type](value);
		}
		caman.render();

	}
	
	// SOCKETS
	// var connection = new WebSocket("ws://athena.dialup.mit.edu:1234", 'control-protocol');
	// connection.onopen = function(event){
	// 	console.log("Connection open...");
	// }
	// connection.onclose = function(event){
	// 	console.log("Connection closed...");
	// }
	// connection.addEventListener("message", function(event) {
	// 	console.log(event.data);
	// 	results = event.data.split(",");
	// 	switch(results[0]){
	// 		case "TakePhoto":
	// 			countdown();
	// 			break;
	// 		case "Back":
	// 			goBack();
	// 			break;
	// 		case "PressEmail":
	// 			break;
	// 		case "SendEmail":
	// 			break;
	// 		case "CancelEmail":
	// 			break;
	// 		case "Facebook":
	// 			break;
	// 		case "Twitter":
	// 			break;
	// 	}
	// });

	$("#camera").css({"border" : "0px"});
	$(".editor").hide();
	$(".setting").show();

	var streaming	= false,
		video		= document.querySelector('#video'),
		canvas		= document.querySelector('#canvas'),
		width		= $("#video").width(),
		height		= $("#video").height(),
		data		= [],
		newdata,
		camal;

	navigator.getMedia = ( navigator.getUserMedia ||
						navigator.webkitGetUserMedia ||
						navigator.mozGetUserMedia ||
						navigator.msGetUserMedia);

	navigator.getMedia(
		{
			video: true,
			audio: false
		},
		function(stream) {
			
			// Create Video Feed
			if (navigator.mozGetUserMedia) {
				video.mozSrcObject = stream;
			} else {
				var vendorURL = window.URL || window.webkitURL;
				video.src = vendorURL.createObjectURL(stream);
			}
			
			// Start Video Feed
			video.play();
			var vendorURL = window.URL || window.webkitURL;
			video.src = vendorURL.createObjectURL(stream);

		},
		function(err) {
			console.log("An error occured! " + err);
		}
	);

	video.addEventListener('canplay', function(ev){
		
		// Other Initial Display Initializers
		$("#start_button").css("display", "inline-block");
		$("#settings_button").css({"display" : "inline-block", "height" : "50px", "width" : "50px"});
		$("#camera").css({"border" : "15px solid black"});
		
		if (!streaming) {
			height = video.videoHeight / (video.videoWidth/width);
			streaming = true;
		}
	}, false);

	function countdown() {
		$(".pre-photo_button").attr("disabled", "disabled");
		var times = parseInt($("input[name='times']").val());
		if ($("input[name='countdown']").is(":checked")){
			$("#count3").fadeIn(500,function(){
				$("#count3").fadeOut(500,function(){
					$("#count2").fadeIn(500,function(){
						$("#count2").fadeOut(500,function(){
							$("#count1").fadeIn(500,function(){
								$("#count1").fadeOut(function(){
									multiplePhotos(times);
								});
							});
							// PLAY 3rd sound
						});
					});
					// PLAY 2nd sound
				});
			});
			// PLAY 1st sound
		} else {
			multiplePhotos(times);
		}
	}

	function multiplePhotos(times) {
		if (times == 0){
			// Animations for last picture
			$(".pre-photo_button").removeAttr("disabled");
			$(".pre-photo_button").css("display", "none");
			$("#settings_button").css({"width" : "50px", "height" : "50px"});
			$(".post-photo_button").css("display", "inline-block");
			$(canvas).attr("index", $("#filmstrip img").length - 1);
{'fraction_non_alphanumeric': 0.20119257950530034, 'fraction_numerical': 0.01159452296819788, 'mean_word_length': 3.1603123564538356, 'pattern_counts': {'":': 16, '<': 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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5056231', 'n_tokens_mistral': 3714, 'n_tokens_neox': 3094, 'n_words': 563}