<commit_before>// Lobby controller
sma.controller('LobbyController', function($rootScope, $state, socket) {
	socket.emit('Server, please add me to lobby');
	socket.on('People, I updated the number of people in rooms', function(number) {
		$rootScope.numberOfPeopleInRooms = number;
	});
});

// Waiting room controller
sma.controller('WaitingController', function($rootScope, $state, socket) {
	socket.emit('Server, please I want to share');

	socket.on('People, here\'s the state of your room', function(stateOfRoom) {
		if (stateOfRoom == 1) {
			$state.transitionTo('room');
		}
	});

	// TODO : Only emit role when room is full
	// So it will avoid this duplicated code below
	socket.on('People, this is your role', function(role) {
		if (role == 'sender') {
			$rootScope.sender   = true;
			$rootScope.receiver = false;
		} else if (role == 'receiver') {
			$rootScope.sender   = false;
			$rootScope.receiver = true;
		}
	});
});

// Room controller
sma.controller('RoomController', function($rootScope, $state, socket) {

	$rootScope.shared  = false;
	$rootScope.wait    = true;
	$rootScope.history = false;

	socket.emit('Server, please I want to share');

	socket.on('People, here\'s the state of your room', function(stateOfRoom) {
		if (stateOfRoom == 0) {
			$state.transitionTo('waiting');
		}
	});

	socket.on('People, this is your role', function(role) {
		$rootScope.shared = false;
		$rootScope.wait   = true;

		if (role == 'sender') {
			$rootScope.sender   = true;
			$rootScope.receiver = false;
		} else if (role == 'receiver') {
			$rootScope.sender   = false;
			$rootScope.receiver = true;
		}

		putLastShareInHistory();
	});

	socket.on('People, this image was sent for you', function(image) {
		if ($rootScope.wait) {
			$('#receivedShare').append('<img src="' + image + '"/>');
		}
		$rootScope.wait = false;
	})

	socket.on('People, sorry but this is the end...', function(msg) {
		$state.transitionTo('end');
	});

	$rootScope.voteFun = function() {
		socket.emit('Server, the share was fun !');
	};

	$rootScope.voteBad = function() {
		socket.emit('Server, the share was bad...');
	};

	var putLastShareInHistory = function() {
		$("#sentShare").children().appendTo("#history");
		$("#receivedShare").children().appendTo("#history");
	};
});

// Camera controller
sma.controller('CameraController', function($scope, $rootScope, $state, socket) {
	$scope.patOpts = {x: 0, y: 0, w: 25, h: 25};
	$scope.snap    = false;

	$scope.onError = function (err) {
	};

	$scope.onSuccess = function(videoElem) {
		video = videoElem;
		$scope.$apply(function() {
			$scope.patOpts.w = video.width;
			$scope.patOpts.h = video.height;
		});
	};

	$scope.onStream = function (stream, videoElem) {
	};

	$scope.takePhoto = function() {
		$scope.snap = true;
		if (video) {
			var takenPhoto = $('#takenPhoto')[0];
			if (!takenPhoto) return;

			takenPhoto.width  = video.width;
			takenPhoto.height = video.height;
			var ctx = takenPhoto.getContext('2d');

			var idata = getVideoData($scope.patOpts.x, $scope.patOpts.y,
				                     $scope.patOpts.w, $scope.patOpts.h);

			ctx.putImageData(idata, 0, 0);
		}
	};

	$scope.sharePhoto = function() {
		var photo = $('#takenPhoto')[0].toDataURL('image/webp');
		socket.emit('Server, here\'s a photo from my camera', photo);

		$rootScope.shared = true;
		$('#sentShare').append('<img src="' + photo + '"/>');
	};

	var getVideoData = function(x, y, w, h) {
		var canvas        = document.createElement('canvas');
		    canvas.width  = video.width;
		    canvas.height = video.height;

		var ctx = canvas.getContext('2d');
		    ctx.drawImage(video, 0, 0, video.width, video.height);

		return ctx.getImageData(x, y, w, h);
	};
});
<commit_msg>Remove useless variable<commit_after>// Lobby controller
sma.controller('LobbyController', function($rootScope, $state, socket) {
	socket.emit('Server, please add me to lobby');
	socket.on('People, I updated the number of people in rooms', function(number) {
		$rootScope.numberOfPeopleInRooms = number;
	});
});

// Waiting room controller
sma.controller('WaitingController', function($rootScope, $state, socket) {
	socket.emit('Server, please I want to share');

	socket.on('People, here\'s the state of your room', function(stateOfRoom) {
		if (stateOfRoom == 1) {
			$state.transitionTo('room');
		}
	});

	// TODO : Only emit role when room is full
	// So it will avoid this duplicated code below
	socket.on('People, this is your role', function(role) {
		if (role == 'sender') {
			$rootScope.sender   = true;
			$rootScope.receiver = false;
		} else if (role == 'receiver') {
			$rootScope.sender   = false;
			$rootScope.receiver = true;
		}
	});
});

// Room controller
sma.controller('RoomController', function($rootScope, $state, socket) {

	$rootScope.shared  = false;
	$rootScope.wait    = true;

	socket.emit('Server, please I want to share');

	socket.on('People, here\'s the state of your room', function(stateOfRoom) {
		if (stateOfRoom == 0) {
			$state.transitionTo('waiting');
		}
	});

	socket.on('People, this is your role', function(role) {
		$rootScope.shared = false;
		$rootScope.wait   = true;

		if (role == 'sender') {
			$rootScope.sender   = true;
			$rootScope.receiver = false;
		} else if (role == 'receiver') {
			$rootScope.sender   = false;
			$rootScope.receiver = true;
		}

		putLastShareInHistory();
	});

	socket.on('People, this image was sent for you', function(image) {
		if ($rootScope.wait) {
			$('#receivedShare').append('<img src="' + image + '"/>');
		}
		$rootScope.wait = false;
	})

	socket.on('People, sorry but this is the end...', function(msg) {
		$state.transitionTo('end');
	});

	$rootScope.voteFun = function() {
		socket.emit('Server, the share was fun !');
	};

	$rootScope.voteBad = function() {
		socket.emit('Server, the share was bad...');
	};

	var putLastShareInHistory = function() {
		$("#sentShare").children().appendTo("#history");
		$("#receivedShare").children().appendTo("#history");
	};
});

// Camera controller
sma.controller('CameraController', function($scope, $rootScope, $state, socket) {
	$scope.patOpts = {x: 0, y: 0, w: 25, h: 25};
	$scope.snap    = false;

	$scope.onError = function (err) {
	};

	$scope.onSuccess = function(videoElem) {
		video = videoElem;
		$scope.$apply(function() {
			$scope.patOpts.w = video.width;
			$scope.patOpts.h = video.height;
		});
	};

	$scope.onStream = function (stream, videoElem) {
	};

	$scope.takePhoto = function() {
		$scope.snap = true;
		if (video) {
			var takenPhoto = $('#takenPhoto')[0];
			if (!takenPhoto) return;

			takenPhoto.width  = video.width;
			takenPhoto.height = video.height;
			var ctx = takenPhoto.getContext('2d');

			var idata = getVideoData($scope.patOpts.x, $scope.patOpts.y,
				                     $scope.patOpts.w, $scope.patOpts.h);

			ctx.putImageData(idata, 0, 0);
		}
	};

	$scope.sharePhoto = function() {
		var photo = $('#takenPhoto')[0].toDataURL('image/webp');
		socket.emit('Server, here\'s a photo from my camera', photo);

		$rootScope.shared = true;
		$('#sentShare').append('<img src="' + photo + '"/>');
	};

	var getVideoData = function(x, y, w, h) {
		var canvas        = document.createElement('canvas');
		    canvas.width  = video.width;
		    canvas.height = video.height;

		var ctx = canvas.getContext('2d');
		    ctx.drawImage(video, 0, 0, video.width, video.height);

		return ctx.getImageData(x, y, w, h);
	};
});

{'fraction_non_alphanumeric': 0.17746061666891072, 'fraction_numerical': 0.0043086037430995015, 'mean_word_length': 3.719186785260483, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5736993', 'n_tokens_mistral': 2737, 'n_tokens_neox': 2496, 'n_words': 584}