<commit_before>app.controller('configUser', function($scope, asyncServices, $attrs, $filter, $window, configService, $http) {
	
	$scope.init = function(){
		//console.log(configService.a);
		$scope.colorMap = {
			red : "#c12e2a",
			orange : "#eb9316",
			yellow : "#f7fe2e",
			blue : "#265a88",
			purple : "#cc2efa"
		};
		
		$scope.colPrin= "#265a88";
		$scope.colSec= "#eb9316";
		$scope.contrast = 1;
		$scope.fontSize = 12;
		$scope.reconocimientoVoz = 0;
		$scope.respuestaPorVoz = 0;
		$scope.vibracion = 0;
		Gama1 = false;
		Gama2 = false;
		$scope.difCrom = false;
		$scope.sistemaBarrido = 0;
		$scope.tiempoBarrido = 4;
		MostcolSec=false;
		$scope.requestStatus = 0;
		
		$scope.idUsuario = $attrs.idUsuario;
		var devicesData = angular.fromJson($attrs.devicesData);
		var devicesNames = angular.fromJson(window.atob($attrs.names));
		$scope.devices = [];
		for(i in devicesData){
			var newDevice = angular.fromJson(devicesData[i])[0];
			newDevice.name = devicesNames[i];
			newDevice.config = {
				layout :{
					horizontal : [3,3],
					vertical : [4,2],
					verticalAllowed : false
				}
			}
			$scope.devices.push(newDevice); //En esta variable ya quedan todos los datos del dispositivo: id, mac, nombre, usuario por defecto
		}
		$scope.selectedDevice = 0;
		$scope.selectedView = "horizontal";
		console.log($scope.random_int(0,1));
	}
	
	$scope.isSelected = function(index){
		if(index==$scope.selectedDevice){
			return true;
		}
		else{
			return false;
		}
	}
	
	$scope.setContrast = function(value){
		$scope.contrast = value;
	}
	
	$scope.setDataToSend = function(){
		//datos de la configuración
		var data = {
			"dificultadCromatica" : $scope.difCrom,
			"color1" : $scope.colPrin,
			"color2" : $scope.colSec,
			"sistemaBarrido" : $scope.sistemaBarrido,
			"tiempoBarrido" : $scope.tiempoBarrido,
			"contraste" : $scope.contrast,
			"tamLetra" : $scope.fontSize,
			"reconocimientoVoz" : $scope.reconocimientoVoz,
			"respuestaPorVoz" : $scope.respuestaPorVoz,			
			"vibracion" : $scope.vibracion,						
		}
		
		//Cada dispositivo tendra su propia layout definida
		var layouts = [];
		
		for(i in $scope.devices){
			var device = $scope.devices[i];
			//datos del layout
			var configLayout = {
				"id_dispositivo" : device["id_dispositivo"],
				"id_usuario" : $scope.idUsuario,
				"rotacion" : 0,
				"filas_vertical" : null,
				"columnas_vertical" : null,
				"filas_horizontal" : device.config.layout.horizontal[1],
				"columnas_horizontal" : device.config.layout.horizontal[0]
			}
			
			if(device.config.layout.verticalAllowed){
				configLayout["rotacion"] = 1;
				configLayout["columnas_vertical"] = device.config.layout.vertical[1];
				configLayout["filas_vertical"] = device.config.layout.vertical[0];
			}
			layouts.push(configLayout);
		}
		
		//console.log(data, layouts, $scope.idUsuario);
		var dataEncoded = window.btoa(angular.toJson(data));
		var layoutsEncoded = window.btoa(angular.toJson(layouts));
				
		dataToSend = window.btoa(angular.toJson({
			data: dataEncoded,
			layoutsData : layoutsEncoded,
			id : $scope.idUsuario,
			action : "insertConfig"
		}));
		
		//console.log(dataToSend);
		
		$http.post("/H4A2/H4A/web/index_dev.php/../../src/Controllers/configController.php", dataToSend).
		then(function(data, status, headers, config) {
			var requestData = data.data;
			var requestStatus = requestData.status;
			//console.log(data);
			if(requestStatus == 1){
				var configData = requestData.data;
				$scope.requestStatus = 1;
				console.log(window.atob(configData));
			}
			else{
				$scope.requestStatus = -1;<commit_msg>bugfix raspberry<commit_after>app.controller('configUser', function($scope, asyncServices, $attrs, $filter, $window, configService, $http) {
	
	$scope.init = function(){
		//console.log(configService.a);
		$scope.colorMap = {
			red : "#c12e2a",
			orange : "#eb9316",
			yellow : "#f7fe2e",
			blue : "#265a88",
			purple : "#cc2efa"
		};
		
		$scope.colPrin= "#265a88";
		$scope.colSec= "#eb9316";
		$scope.contrast = 1;
		$scope.fontSize = 12;
		$scope.reconocimientoVoz = 0;
		$scope.respuestaPorVoz = 0;
		$scope.vibracion = 0;
		Gama1 = false;
		Gama2 = false;
		$scope.difCrom = false;
		$scope.sistemaBarrido = 0;
		$scope.tiempoBarrido = 4;
		MostcolSec=false;
		$scope.requestStatus = 0;
		
		$scope.idUsuario = $attrs.idUsuario;
		var devicesData = angular.fromJson($attrs.devicesData);
		var devicesNames = angular.fromJson(window.atob($attrs.names));
		$scope.devices = [];
		for(i in devicesData){
			var newDevice = angular.fromJson(devicesData[i])[0];
			newDevice.name = devicesNames[i];
			newDevice.config = {
				layout :{
					horizontal : [3,3],
					vertical : [4,2],
					verticalAllowed : false
				}
			}
			$scope.devices.push(newDevice); //En esta variable ya quedan todos los datos del dispositivo: id, mac, nombre, usuario por defecto
		}
		$scope.selectedDevice = 0;
		$scope.selectedView = "horizontal";
		console.log($scope.random_int(0,1));
	}
	
	$scope.isSelected = function(index){
		if(index==$scope.selectedDevice){
			return true;
		}
		else{
			return false;
		}
	}
	
	$scope.setContrast = function(value){
		$scope.contrast = value;
	}
	
	$scope.setDataToSend = function(){
		//datos de la configuración
		var data = {
			"dificultadCromatica" : $scope.difCrom,
			"color1" : $scope.colPrin,
			"color2" : $scope.colSec,
			"sistemaBarrido" : $scope.sistemaBarrido,
			"tiempoBarrido" : $scope.tiempoBarrido,
			"contraste" : $scope.contrast,
			"tamLetra" : $scope.fontSize,
			"reconocimientoVoz" : $scope.reconocimientoVoz,
			"respuestaPorVoz" : $scope.respuestaPorVoz,			
			"vibracion" : $scope.vibracion,						
		}
		
		//Cada dispositivo tendra su propia layout definida
		var layouts = [];
		
		for(i in $scope.devices){
			var device = $scope.devices[i];
			//datos del layout
			var configLayout = {
				"id_dispositivo" : device["id_dispositivo"],
				"id_usuario" : $scope.idUsuario,
				"rotacion" : 0,
				"filas_vertical" : null,
				"columnas_vertical" : null,
				"filas_horizontal" : device.config.layout.horizontal[1],
				"columnas_horizontal" : device.config.layout.horizontal[0]
			}
			
			if(device.config.layout.verticalAllowed){
				configLayout["rotacion"] = 1;
				configLayout["columnas_vertical"] = device.config.layout.vertical[1];
				configLayout["filas_vertical"] = device.config.layout.vertical[0];
			}
			layouts.push(configLayout);
		}
		
		//console.log(data, layouts, $scope.idUsuario);
		var dataEncoded = window.btoa(angular.toJson(data));
		var layoutsEncoded = window.btoa(angular.toJson(layouts));
				
		dataToSend = window.btoa(angular.toJson({
			data: dataEncoded,
			layoutsData : layoutsEncoded,
			id : $scope.idUsuario,
			action : "insertConfig"
		}));
		
		//console.log(dataToSend);
		
		$http.post("/H4A2/H4A/src/Controllers/configController.php", dataToSend).
		then(function(data, status, headers, config) {
			var requestData = data.data;
			var requestStatus = requestData.status;
			//console.log(data);
			if(requestStatus == 1){
				var configData = requestData.data;
				$scope.requestStatus = 1;
				console.log(window.atob(configData));
			}
			else{
				$scope.requestStatus = -1;
{'fraction_non_alphanumeric': 0.1501180391612276, 'fraction_numerical': 0.0158311345646438, 'mean_word_length': 3.6614886731391585, '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': '7421226', 'n_tokens_mistral': 3156, 'n_tokens_neox': 2629, 'n_words': 444}