<commit_before>angular.module('portal_theme',[]).
	factory('pages', function($http){
		return {
			getPage: function(slug){
				var promise = $http.get(rda_service_url+'getThemePage/'+slug).then(function(response){
					return response.data;
				});
				return promise;
			}
		}
	}).
	factory('searches', function($http){
		return{
			search: function(filters){
				var promise = $http.post(base_url+'search/filter', {'filters':filters}).then(function(response){
					return response.data;
				});
				return promise;
			},
			getByList: function(list_ro){
				return $http.post(rda_service_url+'getByList/', {'list_ro': list_ro}).then(function(response){
					return response.data;
				});
			},
			getConnections: function(key){
				return $http.get(rda_service_url+'getConnections/?registry_object_key='+encodeURIComponent(key)).then(function(response){
					return response.data;
				});
			}
		}
	}).
	directive('colorbox', function(){
		return {
			restrict: 'AC',
			link: function(scope, element, attrs){
				$(element).colorbox({
					maxWidth:'100%',
					maxHeight:'100%'
				});
			}
		}
	}).
	directive('carousel', function(){
		return {
			restrict: 'A',
			link: function(scope, element, attrs){
				$(element).flexslider({
				    animation: "slide",
				    animationLoop:true,
				    slideshowSpeed: 2500,
				    pauseOnHover:true,
				    directionNav:false,
				    itemWidth: 260,
				    itemMargin: 40,
				  });
			}
		}
	}).
	directive('filmstrip', function(){
		return {
			restrict : 'A',
			link: function(scope, element, attrs){
				$(element).flexslider({
					animation:'slide',
					controlNav: false,
					directionNav: true,
					animationLoop: false,
					itemWidth: 260,
					itemMargin: 2,
					move:1
				});
			}
		}
	}).
	filter('class_name', function(){
		return function(text){
			switch(text){
				case 'collection': return 'Collections';break;
				case 'activity': return 'Activities';break;
				case 'party': return 'Parties';break;
				case 'party_one': return 'People';break;
				case 'party_multi': return 'Organisations & Groups';break;
				case 'service': return 'Services';break;
				default: return text;break;
			}
		}
	}).
	controller('init', function($scope, pages, searches, $filter){
		$scope.search_results = {}; 
		$scope.slug = $('#slug').val();
		// pages.getPage($scope.slug).then(function(data){
		// 	$scope.page = data;
		// });
		// 
		
		/**
		 * Iteration for search and facets
		 * @return {[type]} [description]
		 */
		$('.theme_search').each(function(){
			var filter = {};
			filter['q'] = decodeURIComponent($('.theme_search_query', this).val());
			filter['limit'] = $('.theme_search_limit', this).val();
			filter['random'] = $('.theme_search_random', this).val();
			if($.trim(filter['q'])=='') delete filter['q'];
			// filter['id'] = $(this).attr('id');

			var view_search_text = $('.theme_search_view_search_text', this).val();
			if(view_search_text==''){
				view_search_text = 'View All Search';
			}
			
			var search_id = $(this).attr('id');
			$('.theme_search_fq', this).each(function(){
				if(filter[$(this).attr('fq-type')]){
					if(filter[$(this).attr('fq-type')] instanceof Array){
						filter[$(this).attr('fq-type')].push($(this).val());
					}else{
						var prev = filter[$(this).attr('fq-type')];
						filter[$(this).attr('fq-type')] = [];
						filter[$(this).attr('fq-type')].push(prev);
						filter[$(this).attr('fq-type')].push($(this).val());
					}
				}else filter[$(this).attr('fq-type')] = $(this).val();
			});

			searches.search(filter).then(function(data){
				$scope.search_results[search_id] = data;

				// console.log(filter);
				var filter_query = '';<commit_msg>Theme Page Fix -initial value issue<commit_after>angular.module('portal_theme',[]).
	factory('pages', function($http){
		return {
			getPage: function(slug){
				var promise = $http.get(rda_service_url+'getThemePage/'+slug).then(function(response){
					return response.data;
				});
				return promise;
			}
		}
	}).
	factory('searches', function($http){
		return{
			search: function(filters){
				var promise = $http.post(base_url+'search/filter', {'filters':filters}).then(function(response){
					return response.data;
				});
				return promise;
			},
			getByList: function(list_ro){
				return $http.post(rda_service_url+'getByList/', {'list_ro': list_ro}).then(function(response){
					return response.data;
				});
			},
			getConnections: function(key){
				return $http.get(rda_service_url+'getConnections/?registry_object_key='+encodeURIComponent(key)).then(function(response){
					return response.data;
				});
			}
		}
	}).
	directive('colorbox', function(){
		return {
			restrict: 'AC',
			link: function(scope, element, attrs){
				$(element).colorbox({
					maxWidth:'100%',
					maxHeight:'100%'
				});
			}
		}
	}).
	directive('carousel', function(){
		return {
			restrict: 'A',
			link: function(scope, element, attrs){
				$(element).flexslider({
				    animation: "slide",
				    animationLoop:true,
				    slideshowSpeed: 2500,
				    pauseOnHover:true,
				    directionNav:false,
				    itemWidth: 260,
				    itemMargin: 40,
				  });
			}
		}
	}).
	directive('filmstrip', function(){
		return {
			restrict : 'A',
			link: function(scope, element, attrs){
				$(element).flexslider({
					animation:'slide',
					controlNav: false,
					directionNav: true,
					animationLoop: false,
					itemWidth: 260,
					itemMargin: 2,
					move:1
				});
			}
		}
	}).
	filter('class_name', function(){
		return function(text){
			switch(text){
				case 'collection': return 'Collections';break;
				case 'activity': return 'Activities';break;
				case 'party': return 'Parties';break;
				case 'party_one': return 'People';break;
				case 'party_multi': return 'Organisations & Groups';break;
				case 'service': return 'Services';break;
				default: return text;break;
			}
		}
	}).
	controller('init', function($scope, pages, searches, $filter){
		$scope.search_results = {}; 
		$scope.slug = $('#slug').val();
		// pages.getPage($scope.slug).then(function(data){
		// 	$scope.page = data;
		// });
		// 
		
		/**
		 * Iteration for search and facets
		 * @return {[type]} [description]
		 */
		$('.theme_search').each(function(){
			var filter = {};
			filter['q'] = decodeURIComponent($('.theme_search_query', this).val());
			filter['limit'] = $('.theme_search_limit', this).val();
			filter['random'] = $('.theme_search_random', this).val();
			if($.trim(filter['q'])=='') delete filter['q'];
			if(filter['limit']=='') filter['limit'] = 10;
			if(filter['limit']=='') delete filter['random'];
			// filter['id'] = $(this).attr('id');

			var view_search_text = $('.theme_search_view_search_text', this).val();
			if(view_search_text==''){
				view_search_text = 'View All Search';
			}
			
			var search_id = $(this).attr('id');
			$('.theme_search_fq', this).each(function(){
				if(filter[$(this).attr('fq-type')]){
					if(filter[$(this).attr('fq-type')] instanceof Array){
						filter[$(this).attr('fq-type')].push($(this).val());
					}else{
						var prev = filter[$(this).attr('fq-type')];
						filter[$(this).attr('fq-type')] = [];
						filter[$(this).attr('fq-type')].push(prev);
						filter[$(this).attr('fq-type')].push($(this).val());
					}
				}else filter[$(this).attr('fq-type')] = $(this).val();
			});

			searches.search(filter).then(function(data){
				$scope.search_results[search_id] = data;

				// console.log(filter);
				var filter_query = '';
{'fraction_non_alphanumeric': 0.199866577718479, 'fraction_numerical': 0.005603735823882588, 'mean_word_length': 3.5651644336175394, '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': '976960', 'n_tokens_mistral': 3119, 'n_tokens_neox': 2486, 'n_words': 409}