<commit_before>// Create the module and name it app
var app = angular.module('DockerWebUI', ['ngCookies','ngRoute','ngClipboard']);

/*
 *This config command configures all $http requests to be send with 'X-Requested-With' header 
 * which is required by docker-registry flask server
 */ 
app.config(['ngClipProvider', function(ngClipProvider) { ngClipProvider.setPath("includes/bower_components/zeroclipboard/dist/ZeroClipboard.swf"); }]);
     
app.config(function($httpProvider){
	delete $httpProvider.defaults.headers.common['X-Requested-With'];
});

// configure our routes.
/*
 *Using routes we create a single page application(SPA), with index.html as the base template and then loading
 *various views using ng-view, and anchor tags. 
 */ 
app.config(function($routeProvider) {
	$routeProvider

		// route for the home page
		.when('/', {
			templateUrl : 'pages/home.html',
			controller  : 'MainController'
		})

		// route for the showNamespaces page
		.when('/showNamespaces', {
			templateUrl : 'pages/showNamespaces.html',
			controller  : 'NamespacesController'
		})
		
		// route for the showNamespacesRepos page
		.when('/showNamespacesRepos', {
			templateUrl : 'pages/showNamespacesRepos.html',
			controller  : 'NamespacesReposController'
		})

		// route for the showRepositories page
		.when('/showRepositories', {
			templateUrl : 'pages/showRepositories.html',
			controller  : 'RepositoriesController'
		})
		
		// route for the showImages page
		.when('/showImages', {
			templateUrl : 'pages/showImages.html',
			controller  : 'ImagesController'
		});
});


// create the Main controller (for index.html) and inject Angular's $scope
app.controller('MainController', ['$scope','$route','$window','$cookies',function($scope,$route,$window,$cookies,$location) {
	$scope.inputIP='';
	$scope.getIP=function()
	{
		$scope.inputIP=$cookies.IP;
		console.log('the current IP has been to '+$cookies.IP);
	}
	$scope.setIP=function()
	{
		$cookies.IP=$scope.inputIP;
		console.log('the IP has been changed to '+$cookies.IP);
		$window.location.href = "#showNamespaces";
		$route.reload();
	}
	
	//alert("$window.location is " + $window.location);
	
	//$scope.IP=$scope.inputIP;
	
	if($cookies.IP!==undefined)
	{
		if($window.location == "http://localhost:8000/#/")
		{
			$window.location.href="#showNamespaces";
			$route.reload();
		}
	}
}]);

//Show Namespaces controller, all JS code for showNamespaces page is here
app.controller('NamespacesController', function($rootScope,$scope,$http,$route,$cookies,$window,$location) {
	
	//alert("location is " + $location.path());
	$scope.IP=$cookies.IP;
	if($scope.IP===undefined)
	{
		$window.location.href="#";
		$route.reload();<commit_msg>fixed:Issue#53<commit_after>// Create the module and name it app
var app = angular.module('DockerWebUI', ['ngCookies','ngRoute','ngClipboard']);

/*
 *This config command configures all $http requests to be send with 'X-Requested-With' header 
 * which is required by docker-registry flask server
 */ 
app.config(['ngClipProvider', function(ngClipProvider) { ngClipProvider.setPath("includes/bower_components/zeroclipboard/dist/ZeroClipboard.swf"); }]);
     
app.config(function($httpProvider){
	delete $httpProvider.defaults.headers.common['X-Requested-With'];
});

// configure our routes.
/*
 *Using routes we create a single page application(SPA), with index.html as the base template and then loading
 *various views using ng-view, and anchor tags. 
 */ 
app.config(function($routeProvider) {
	$routeProvider

		// route for the home page
		.when('/', {
			templateUrl : 'pages/home.html',
			controller  : 'MainController'
		})

		// route for the showNamespaces page
		.when('/showNamespaces', {
			templateUrl : 'pages/showNamespaces.html',
			controller  : 'NamespacesController'
		})
		
		// route for the showNamespacesRepos page
		.when('/showNamespacesRepos', {
			templateUrl : 'pages/showNamespacesRepos.html',
			controller  : 'NamespacesReposController'
		})

		// route for the showRepositories page
		.when('/showRepositories', {
			templateUrl : 'pages/showRepositories.html',
			controller  : 'RepositoriesController'
		})
		
		// route for the showImages page
		.when('/showImages', {
			templateUrl : 'pages/showImages.html',
			controller  : 'ImagesController'
		});
});


// create the Main controller (for index.html) and inject Angular's $scope
app.controller('MainController', ['$scope','$route','$window','$cookies',function($scope,$route,$window,$cookies,$location) {
	$scope.inputIP='';
	$scope.getIP=function()
	{
		$scope.inputIP=$cookies.IP;
		console.log('the current IP has been to '+$cookies.IP);
	}
	$scope.setIP=function()
	{
		$cookies.IP=$scope.inputIP;
		console.log('the IP has been changed to '+$cookies.IP);
		$window.location.href = "#showNamespaces";
		$route.reload();
	}
	
	/*This function is used to solve issue #53.
	 * It checks if the current page is home and ip is set, it redirects to all namespaces.
	 * Otherwise nothing happens.
	 * NOTE: this code does get executed each time page is refreshed.
	 */ 
	if($cookies.IP!==undefined)
	{
		if($window.location == "http://localhost:8000/#/")
		{
			$window.location.href="#showNamespaces";
			$route.reload();
		}
	}
}]);

//Show Namespaces controller, all JS code for showNamespaces page is here
app.controller('NamespacesController', function($rootScope,$scope,$http,$route,$cookies,$window,$location) {
	
	//alert("location is " + $location.path());
	$scope.IP=$cookies.IP;
	if($scope.IP===undefined)
	{
		$window.location.href="#";
		$route.reload();
{'fraction_non_alphanumeric': 0.15603091856911738, 'fraction_numerical': 0.0021571094733057704, 'mean_word_length': 4.444227005870841, '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': '1236811', 'n_tokens_mistral': 1887, 'n_tokens_neox': 1720, 'n_words': 394}