<commit_before>'use strict';

// Projects controller
angular.module('projects').controller('ProjectsController', ['$scope', '$stateParams', '$location', 'Authentication', 'Projects', '$upload', 'ngAudio', 'ngAudioGlobals', '$http', '$modal', '$rootScope', 'Socket', '$cookies', '$window', 
	function($scope, $stateParams, $location, Authentication, Projects, $upload, ngAudio, ngAudioGlobals, $http, $modal, $rootScope, Socket, $cookies, $window ) {
		$scope.authentication = Authentication;

		$scope.project = {};
		$scope.discussion = '';
		// rating
		$scope.hide = 0;
		$scope.max = 5;
		$scope.isReadonly = false;
		$scope.ratings = [];
		$scope.ratingsAvg = [];
		// static project options
		ngAudioGlobals.unlock = false;
		$scope.auditions = [];
		$scope.projProgress = [];
		$scope.selCheckVal = 0;
		$scope.client = [];
		$scope.talent = [];
		$scope.showRename = 0;
		$scope.statusOpts = ['In Progress', 'On Hold', 'Booked', 'Canceled', 'ReAuditioned', 'Dead', 'Closed - Pending Client Decision', 'Complete'];
		$scope.priorityOpts = ['None', 'Very low', 'Low', 'Medium', 'High', 'Very high'];
		$scope.phaseStatusOpts = ['in progress','open','complete','suspended'];
		$scope.soundersOpts = ['Sounders', 'No Sounders - Approved By William'];
		$scope.talentStatus = ['Cast', 'Emailed', 'Scheduled', 'Message left', 'Out', 'Received needs to be posted', 'Posted', 'Not Posted (Bad Read)'];
		$scope.loadAudio = 0;
		$scope.audio = '';
		$scope.lastAudioID = 0;
		$scope.audioStatus = 0;
		$scope.newLead = {};
		$scope.referenceFiles = [];
		$scope.scripts = [];
		$scope.newProject = {
			title: '',
			estimatedCompletionDate: '',
			notifyClient: true
		};
		$scope.parts = [];
		$scope.toggleRefs = false;
		$scope.selectedMainClients = [];
		$scope.rejFiles = [];
		$scope.talentStatus = [];
		$scope.talentBooked = [];
		// projects client portal
		$scope.selectedAuditions = [];
		$scope.hideList = [];
		// filter vars
		$scope.predicate = '';
		$scope.reverse = '';
		$scope.searchText = {};

		// on close check
		$scope.$on('$locationChangeStart', function( event ) {

			// nothing for the moment

		});

		$scope.updatePred = function(pred){
			$scope.predicate = pred;
		};

		// used for paginator
		$scope.Math = window.Math;
		$scope.currentPage = 0;
		$scope.filtered = [];
		$scope.limit = 0;
		$scope.range = function(min, max, step){
		    step = step || 1;
		    var input = [];
		    for (var i = min; i <= max; i += step) input.push(i);
		    return input;
		};
	    $scope.setPage = function () {
	        $scope.currentPage = this.n;
	    };
	    $scope.changePage = function(page){
	    	var curSel = page * $scope.limit;

	    	if(curSel < $scope.filtered.length && curSel >= 0){
	    		$scope.currentPage = page;
	    	}
	    };
	    $scope.$watch('filtered', function(val){
	    	$scope.currentPage = 0;
	    }, true);

		$scope.hoveringOver = function(value,key,object) {
	        $scope.overStar = value;
	        $scope.percent = 100 * (value / $scope.max);
	        $scope.selCheckVal = value;
      	};

      	// book clients modal
      	$scope.bookSelectedAuditions = function(){
      		var modalInstance = $modal.open({
		      animation: true,
		      templateUrl: 'modules/projects/views/book-auditon-modal.client.view.html',
		      controller: 'ProjectsModalController',
		      resolve: {
		      	data: function () {
			        return {
			        	project: $scope.project._id,
			        	auditions: $scope.selectedAuditions
			        };
				}
		      }
		    });

		    modalInstance.result.then(function (selectedItem) {
		      //$scope.selected = selectedItem;
		    }, function () {
		      //$log.info('Modal dismissed at: ' + new Date());

		    });
      	};

      	// create user modals
      	$scope.createClient = function (owner) {

		    var modalInstance = $modal.open({
		      animation: true,
		      templateUrl: 'modules/users/views/modal-create.client.view.html',
		      controller: 'UsersModalController',
		      resolve: {
		      	owner: function () {
			      	if(owner === 'client'){
				        return 'client';
				    } else {
				        return 'client-client';
				    }
				}
		      }
		    });

		    // modalInstance.result.then(function (selectedItem) {
		    //   //$scope.selected = selectedItem;
		    // }, function () {
		    //   //$log.info('Modal dismissed at: ' + new Date());

		    // });
		};
		// create talent modal
		$scope.createTalent = function(){
			var modalInstance = $modal.open({
		      animation: true,
		      templateUrl: 'modules/talents/views/create-talent-modal.client.view.html',
		      controller: 'TalentsModalController'
		    });

		    modalInstance.result.then(function (selectedItem) {
		      //$scope.selected = selectedItem;
		    }, function () {
		      //$log.info('Modal dismissed at: ' + new Date());
		    });
		};

      	// client portal specific methods
      	$scope.selAudition = function(key){
			var idx = $scope.selectedAuditions.indexOf(key);
			if (idx > -1){
			    $scope.selectedAuditions.splice(idx, 1);
			}else{
			    $scope.selectedAuditions.push(key);
			}
      	};
      	$scope.selCheck = function(filename){
			for(var i = 0; i < $scope.selectedAuditions.length; ++i){
      			if($scope.selectedAuditions[i] === filename){
      				return true;
      			}
      		}
      	};
      	$scope.hideSelected = true;
      	$scope.hideSelectedAuditions = function(){
      		$scope.hideSelected = !$scope.hideSelected;
      	};
      	$scope.hideAudition = function(filename){
      		// $scope.hideList.push(filename);
      		// get audition id
      		for(var i = 0; i < $scope.project.auditions.length; ++i){
      			if($scope.project.auditions[i].file.path === filename){
      				$scope.project.auditions[i].hidden = true;
      				$scope.updateNoRefresh();
      			}
      		}
      	};
      	$scope.showAudition = function(filename){
			// var idx = $scope.hideList.indexOf(filename);
			// if (idx > -1){
			//     $scope.hideList.splice(idx, 1);
			// }
			// get audition id
			for(var i = 0; i < $scope.project.auditions.length; ++i){
      			if($scope.project.auditions[i].file.path === filename){
      				$scope.project.auditions[i].hidden = false;
      				$scope.updateNoRefresh();
      			}
      		}
      	};
      	$scope.isHidden = function(filename){

      		for(var i = 0; i < $scope.project.auditions.length; ++i){
      			if($scope.project.auditions[i].file.path === filename){
      				return true;
      			}
      		}

      		return false;
      	};
      	$scope.isDisplayed = function(filename){
      		for(var i = 0; i < $scope.project.auditions.length; ++i){
      			if($scope.project.auditions[i].file.path === filename){
      				if($scope.project.auditions[i].hidden === true && $scope.hideSelected === true){
      					return false;
      				} else {
      					return true;
      				}
      			}
      		}

      		return false;
      	};
      	$scope.hiddenAudsCnt = function(){
      		var hidCnt = 0;

      		for(var i = 0; i < $scope.project.auditions.length; ++i){
  				if($scope.project.auditions[i].hidden === true){
  					hidCnt += 1;
  				}
      		}

      		return hidCnt;
      	};
      	$scope.downloadAllAuditions = function(){

			$http.post('/projects/downloadallauditions', {
		        project: $scope.project
		    }).
			success(function(data, status, headers, config) {
				// send data to users browser
				// wait one second for archive processing on server
				setTimeout(
					function(){
						window.open('res/archives/' + encodeURIComponent(data.zip), '_blank', ''); 
					},
				    1000
				);
			});
      	};
      	$scope.bookSelectedShow = function(){
      		var hiddenMatchCnt = 0, idx;<commit_msg>download all media link adjust<commit_after>'use strict';

// Projects controller
angular.module('projects').controller('ProjectsController', ['$scope', '$stateParams', '$location', 'Authentication', 'Projects', '$upload', 'ngAudio', 'ngAudioGlobals', '$http', '$modal', '$rootScope', 'Socket', '$cookies', '$window', 
	function($scope, $stateParams, $location, Authentication, Projects, $upload, ngAudio, ngAudioGlobals, $http, $modal, $rootScope, Socket, $cookies, $window ) {
		$scope.authentication = Authentication;

		$scope.project = {};
		$scope.discussion = '';
		// rating
		$scope.hide = 0;
		$scope.max = 5;
		$scope.isReadonly = false;
		$scope.ratings = [];
		$scope.ratingsAvg = [];
		// static project options
		ngAudioGlobals.unlock = false;
		$scope.auditions = [];
		$scope.projProgress = [];
		$scope.selCheckVal = 0;
		$scope.client = [];
		$scope.talent = [];
		$scope.showRename = 0;
		$scope.statusOpts = ['In Progress', 'On Hold', 'Booked', 'Canceled', 'ReAuditioned', 'Dead', 'Closed - Pending Client Decision', 'Complete'];
		$scope.priorityOpts = ['None', 'Very low', 'Low', 'Medium', 'High', 'Very high'];
		$scope.phaseStatusOpts = ['in progress','open','complete','suspended'];
		$scope.soundersOpts = ['Sounders', 'No Sounders - Approved By William'];
		$scope.talentStatus = ['Cast', 'Emailed', 'Scheduled', 'Message left', 'Out', 'Received needs to be posted', 'Posted', 'Not Posted (Bad Read)'];
		$scope.loadAudio = 0;
		$scope.audio = '';
		$scope.lastAudioID = 0;
		$scope.audioStatus = 0;
		$scope.newLead = {};
		$scope.referenceFiles = [];
		$scope.scripts = [];
		$scope.newProject = {
			title: '',
			estimatedCompletionDate: '',
			notifyClient: true
		};
		$scope.parts = [];
		$scope.toggleRefs = false;
		$scope.selectedMainClients = [];
		$scope.rejFiles = [];
		$scope.talentStatus = [];
		$scope.talentBooked = [];
		// projects client portal
		$scope.selectedAuditions = [];
		$scope.hideList = [];
		// filter vars
		$scope.predicate = '';
		$scope.reverse = '';
		$scope.searchText = {};

		// on close check
		$scope.$on('$locationChangeStart', function( event ) {

			// nothing for the moment

		});

		$scope.updatePred = function(pred){
			$scope.predicate = pred;
		};

		// used for paginator
		$scope.Math = window.Math;
		$scope.currentPage = 0;
		$scope.filtered = [];
		$scope.limit = 0;
		$scope.range = function(min, max, step){
		    step = step || 1;
		    var input = [];
		    for (var i = min; i <= max; i += step) input.push(i);
		    return input;
		};
	    $scope.setPage = function () {
	        $scope.currentPage = this.n;
	    };
	    $scope.changePage = function(page){
	    	var curSel = page * $scope.limit;

	    	if(curSel < $scope.filtered.length && curSel >= 0){
	    		$scope.currentPage = page;
	    	}
	    };
	    $scope.$watch('filtered', function(val){
	    	$scope.currentPage = 0;
	    }, true);

		$scope.hoveringOver = function(value,key,object) {
	        $scope.overStar = value;
	        $scope.percent = 100 * (value / $scope.max);
	        $scope.selCheckVal = value;
      	};

      	// book clients modal
      	$scope.bookSelectedAuditions = function(){
      		var modalInstance = $modal.open({
		      animation: true,
		      templateUrl: 'modules/projects/views/book-auditon-modal.client.view.html',
		      controller: 'ProjectsModalController',
		      resolve: {
		      	data: function () {
			        return {
			        	project: $scope.project._id,
			        	auditions: $scope.selectedAuditions
			        };
				}
		      }
		    });

		    modalInstance.result.then(function (selectedItem) {
		      //$scope.selected = selectedItem;
		    }, function () {
		      //$log.info('Modal dismissed at: ' + new Date());

		    });
      	};

      	// create user modals
      	$scope.createClient = function (owner) {

		    var modalInstance = $modal.open({
		      animation: true,
		      templateUrl: 'modules/users/views/modal-create.client.view.html',
		      controller: 'UsersModalController',
		      resolve: {
		      	owner: function () {
			      	if(owner === 'client'){
				        return 'client';
				    } else {
				        return 'client-client';
				    }
				}
		      }
		    });

		    // modalInstance.result.then(function (selectedItem) {
		    //   //$scope.selected = selectedItem;
		    // }, function () {
		    //   //$log.info('Modal dismissed at: ' + new Date());

		    // });
		};
		// create talent modal
		$scope.createTalent = function(){
			var modalInstance = $modal.open({
		      animation: true,
		      templateUrl: 'modules/talents/views/create-talent-modal.client.view.html',
		      controller: 'TalentsModalController'
		    });

		    modalInstance.result.then(function (selectedItem) {
		      //$scope.selected = selectedItem;
		    }, function () {
		      //$log.info('Modal dismissed at: ' + new Date());
		    });
		};

      	// client portal specific methods
      	$scope.selAudition = function(key){
			var idx = $scope.selectedAuditions.indexOf(key);
			if (idx > -1){
			    $scope.selectedAuditions.splice(idx, 1);
			}else{
			    $scope.selectedAuditions.push(key);
			}
      	};
      	$scope.selCheck = function(filename){
			for(var i = 0; i < $scope.selectedAuditions.length; ++i){
      			if($scope.selectedAuditions[i] === filename){
      				return true;
      			}
      		}
      	};
      	$scope.hideSelected = true;
      	$scope.hideSelectedAuditions = function(){
      		$scope.hideSelected = !$scope.hideSelected;
      	};
      	$scope.hideAudition = function(filename){
      		// $scope.hideList.push(filename);
      		// get audition id
      		for(var i = 0; i < $scope.project.auditions.length; ++i){
      			if($scope.project.auditions[i].file.path === filename){
      				$scope.project.auditions[i].hidden = true;
      				$scope.updateNoRefresh();
      			}
      		}
      	};
      	$scope.showAudition = function(filename){
			// var idx = $scope.hideList.indexOf(filename);
			// if (idx > -1){
			//     $scope.hideList.splice(idx, 1);
			// }
			// get audition id
			for(var i = 0; i < $scope.project.auditions.length; ++i){
      			if($scope.project.auditions[i].file.path === filename){
      				$scope.project.auditions[i].hidden = false;
      				$scope.updateNoRefresh();
      			}
      		}
      	};
      	$scope.isHidden = function(filename){

      		for(var i = 0; i < $scope.project.auditions.length; ++i){
      			if($scope.project.auditions[i].file.path === filename){
      				return true;
      			}
      		}

      		return false;
      	};
      	$scope.isDisplayed = function(filename){
      		for(var i = 0; i < $scope.project.auditions.length; ++i){
      			if($scope.project.auditions[i].file.path === filename){
      				if($scope.project.auditions[i].hidden === true && $scope.hideSelected === true){
      					return false;
      				} else {
      					return true;
      				}
      			}
      		}

      		return false;
      	};
      	$scope.hiddenAudsCnt = function(){
      		var hidCnt = 0;

      		for(var i = 0; i < $scope.project.auditions.length; ++i){
  				if($scope.project.auditions[i].hidden === true){
  					hidCnt += 1;
  				}
      		}

      		return hidCnt;
      	};
      	$scope.downloadAllAuditions = function(){

			$http.post('/projects/downloadallauditions', {
		        project: $scope.project
		    }).
			success(function(data, status, headers, config) {
				// send data to users browser
				// wait one second for archive processing on server
				setTimeout(
					function(){
						window.location.href = 'res/archives/' + encodeURIComponent(data.zip);
					},
				    1000
				);
			});
      	};
      	$scope.bookSelectedShow = function(){
      		var hiddenMatchCnt = 0, idx;
{'fraction_non_alphanumeric': 0.16400617919670443, 'fraction_numerical': 0.004119464469618949, 'mean_word_length': 2.350657752857451, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2369770', 'n_tokens_mistral': 5696, 'n_tokens_neox': 4948, 'n_words': 939}