<commit_before>// public/js/controllers/LoginCtrl.js


angular.module('LoginCtrl', []).controller('LoginController', function($scope, $location, $http, Login) {
	
	var color = "white";
	$scope.style = function(red) {
          return { "background-color": color };
      };
	
	var redirectAfterLogin = function()
	{
		// Change URL & reload route
		$location.path('/profile');
		
		/*
		$location.update_path('/nerds');
		
		// Reroute to "/nerds"	
		$route.reload();
		*/
	}
	
	var alertToCheck = function() {
					
				Login.get($scope.name, $scope.password)
					.success(function(data) {
						if(data == true)
						{
							console.log("Logged in");
							color = "green";
							setTimeout(redirectAfterLogin, 100);
							
						}
						
						else 
						{
							color = "red";
							console.log("Tried to log in, did not work");
						}

            		});	
						 				
				$scope.showMe = !$scope.showMe;
				return true;
			}
			
			var checked = false;
			$scope.showMe = false;
			$scope.checkIfValid = function() {

				if(($scope.name != undefined) && ($scope.name !== "")){
					if(($scope.password != undefined) && ($scope.password !== "")){
						if(checked == true){
			        		$scope.cancel(alertToCheck());
							checked = false;
		        		}
		        
			        $scope.showMe = !$scope.showMe;
			        checked = setTimeout(alertToCheck, 300);
		        
				}
				}
		        
		    };
 
});<commit_msg>Updated login function<commit_after>// public/js/controllers/LoginCtrl.js


angular.module('LoginCtrl', []).controller('LoginController', function($scope, $location, $http, Login) {
	
	var color = "white";
	$scope.style = function(red) {
          return { "background-color": color };
      };

	// Function that triggers the API call and manages GUI changes
	var alertToCheck = function() {
					
				Login.get($scope.name, $scope.password)
					.success(function(data) {
						if(data == true)
						{
							console.log("Logged in");
							color = "green";
							$location.path('/profile');
							
						}
						
						else 
						{
							color = "red";
							console.log("Tried to log in, did not work");
							
						}

            		});	
						 				
				$scope.showMe = !$scope.showMe;
				return true;
			}

			// Timer
			var timeoutHandle;
			
			// Function gets trigged from GUI on change
			$scope.checkIfValid = function() {
				
				// Resets the timer
				clearTimeout(timeoutHandle);
				
				// Sets the timer to 0.4 sec and then checks againt DB
				timeoutHandle = setTimeout(runCheckIfVaild, 400);

				}
			
			// Function to run username and password againt DB
			var runCheckIfVaild = function() {

				if(($scope.name != undefined) && ($scope.name !== "")){
					if(($scope.password != undefined) && ($scope.password !== "")){
			        alertToCheck();
		        
				}
				}
				
		    };
 
});
{'fraction_non_alphanumeric': 0.15188547486033518, 'fraction_numerical': 0.003840782122905028, 'mean_word_length': 1.9812695109261187, 'pattern_counts': {'":': 2, '<': 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': '5305607', 'n_tokens_mistral': 1238, 'n_tokens_neox': 858, 'n_words': 183}