<commit_before>angular.module('radar')
.controller('MenuController', [
	'$scope',
	'$ionicSideMenuDelegate',
	'$ionicNavBarDelegate',
	'$timeout',
	'$ionicModal',
	'MapFactory', 
	'MarkerFactory', 
	'HttpHandler', 
	'$scope', 
	function($scope, $ionicSideMenuDelegate, $ionicNavBarDelegate, $timeout, $ionicModal, Map, Marker, Http) {


	$scope.showSearch = false;

// FILTER MENU
	$scope.toggleFilter = false;
	$scope.partyCheck = true;
	$scope.concertCheck = true;
	$scope.happyHourCheck = true;

// This is an ugly hack -- Figure out real angular/ionic ready function
	$timeout(function() {
		$ionicNavBarDelegate.handle = 'navBar';
		$ionicNavBarDelegate.title('Ephemeral');
	}, 150);

	// $scope.test = function() {
	// 	console.log("seearchtext")
	// }
	$scope.loggedIn = false;

/* MODALS */

	$scope.test = "HELLO";

  $scope.openModal = function() {
    $scope.modal.show();
  };
  $scope.closeModal = function() {
    $scope.modal.hide();
  };

	$scope.toggleRight = function() {
	  $ionicSideMenuDelegate.toggleRight();
	};
	
	$scope.login = function() {
		$ionicModal.fromTemplateUrl('../templates/login.html', {
	    scope: $scope,
	  }).then(function(modal) {
	    $scope.modal = modal;
			$scope.toggleRight();
			$scope.openModal();
	  });
	};

	$scope.handleLogin = function(email, pwd) {
		if (!userData.email) {
			// logic for handling user errors goes here 
		  return console.log('no email');
		}
		Http.postLogin({
			email: email,
			pwd: <PASSWORD>
		}).success(function(data, status) {
			console.log('welcome back in');
			$scope.loggedInEmail = email;
			$scope.loggedIn = true;
			$scope.closeModal();
		}).error(function() {
			console.log('invalid username or password');
		});
	};

	$scope.register = function() {
		$ionicModal.fromTemplateUrl('../templates/register.html', {
	    scope: $scope,
	  }).then(function(modal) {
	    $scope.modal = modal;
			$scope.toggleRight();
			$scope.openModal();
	  });
	};

	$scope.handleSignup = function(userEmail, userPassword, confirmPassword) {
		if (!(userEmail && userPassword && (userPassword === confirmPassword))) {
			// logic for handling user errors goes here 
			return console.log('either (invalid email or password) or (passwords don\'t match)');
		}
		Http.postSignup({
			email: userEmail,
			pwd: <PASSWORD>
		}).success(function(data, status) {
			console.log('welcome to the cluuub');
			$scope.loggedInEmail = userEmail;
			$scope.loggedIn = true;
			$scope.closeModal();
		}).error(function(data, status) {
			console.log('user already exists');
		});
	};

	$scope.newSearch = function() {
		$scope.search = '';
		$scope.showSearch = !$scope.showSearch;
	};

	/* NEW EVENT MODAL */

	

	$scope.getCurrentAddress = function() {
		console.log("getting address");
		Map.findCurrentLocation(function(coords) {	
			var address = Http.getAddressForCoords(coords.lat, coords.lng, function(address) {
				console.log(address);
				$scope.newPostData.streetAddress1 = address.streetAddress1;
				$scope.newPostData.city = address.city;
				$scope.newPostData.state = address.state;
				$scope.newPostData.zipCode = address.zipCode;
			});
		}); // TODO: Promisify
	};

	$scope.postNewEvent = function() {
		// TODO: Check for authentication. If authenticated, proceed. Else "Please Login or register to post events"
		$scope.newPostData = {
				title: '',
				info: '',
				streetAddress1: '',
				streetAddress2: '',
				city: '',
				state: '',
				zipCode: '',
				startDateTime: new Date(),
				endDateTime: '',
				category: '',
				coords: {lat: undefined, lng: undefined}
			};
		$ionicModal.fromTemplateUrl('../templates/newEventModal.html', {
	    scope: $scope,
	  }).then(function(modal) {
	    $scope.modal = modal;
			$scope.toggleRight();
			$scope.openModal();
	  });
	};

	$scope.saveNewEvent = function() {
		// TODO: Get userId from Auth, pass it into http call below
		var userId = 1;
		// DUMMY INFO BELOW
		var address = ($scope.newPostData.streetAddress1+'+'+$scope.newPostData.streetAddress2+'+'+$scope.newPostData.city+'+'+$scope.newPostData.state+'+'+$scope.newPostData.zipCode).split(' ').join('+');
		Http.getCoordsForAddress(address, function(coords) {
			$scope.newPostData.coords = coords;
			Http.saveNewEvent($scope.newPostData);
		});
	};

	$scope.startDateTime = new Date();
	$scope.endDateTime;

}]);

// angular.module('radar').controller('ModalCtrl', function ($scope, $modalInstance) {

//   $scope.ok = function () {
//     $modalInstance.close();
//   };

//   $scope.cancel = function () {
//     $modalInstance.dismiss('cancel');
//   };

// });<commit_msg>parses current date/time<commit_after>angular.module('radar')
.controller('MenuController', [
	'$scope',
	'$ionicSideMenuDelegate',
	'$ionicNavBarDelegate',
	'$timeout',
	'$ionicModal',
	'MapFactory', 
	'MarkerFactory', 
	'HttpHandler', 
	'$scope', 
	function($scope, $ionicSideMenuDelegate, $ionicNavBarDelegate, $timeout, $ionicModal, Map, Marker, Http) {


	$scope.showSearch = false;

// FILTER MENU
	$scope.toggleFilter = false;
	$scope.partyCheck = true;
	$scope.concertCheck = true;
	$scope.happyHourCheck = true;

// This is an ugly hack -- Figure out real angular/ionic ready function
	$timeout(function() {
		$ionicNavBarDelegate.handle = 'navBar';
		$ionicNavBarDelegate.title('Ephemeral');
	}, 150);

	// $scope.test = function() {
	// 	console.log("seearchtext")
	// }
	$scope.loggedIn = false;

/* MODALS */

  $scope.openModal = function() {
    $scope.modal.show();
  };
  $scope.closeModal = function() {
    $scope.modal.hide();
  };

	$scope.toggleRight = function() {
	  $ionicSideMenuDelegate.toggleRight();
	};
	
	$scope.login = function() {
		$ionicModal.fromTemplateUrl('../templates/login.html', {
	    scope: $scope,
	  }).then(function(modal) {
	    $scope.modal = modal;
			$scope.toggleRight();
			$scope.openModal();
	  });
	};

	$scope.handleLogin = function(email, pwd) {
		if (!userData.email) {
			// logic for handling user errors goes here 
		  return console.log('no email');
		}
		Http.postLogin({
			email: email,
			pwd: <PASSWORD>
		}).success(function(data, status) {
			console.log('welcome back in');
			$scope.loggedInEmail = email;
			$scope.loggedIn = true;
			$scope.closeModal();
		}).error(function() {
			console.log('invalid username or password');
		});
	};

	$scope.register = function() {
		$ionicModal.fromTemplateUrl('../templates/register.html', {
	    scope: $scope,
	  }).then(function(modal) {
	    $scope.modal = modal;
			$scope.toggleRight();
			$scope.openModal();
	  });
	};

	$scope.handleSignup = function(userEmail, userPassword, confirmPassword) {
		if (!(userEmail && userPassword && (userPassword === confirmPassword))) {
			// logic for handling user errors goes here 
			return console.log('either (invalid email or password) or (passwords don\'t match)');
		}
		Http.postSignup({
			email: userEmail,
			pwd: <PASSWORD>
		}).success(function(data, status) {
			console.log('welcome to the cluuub');
			$scope.loggedInEmail = userEmail;
			$scope.loggedIn = true;
			$scope.closeModal();
		}).error(function(data, status) {
			console.log('user already exists');
		});
	};

	$scope.newSearch = function() {
		$scope.search = '';
		$scope.showSearch = !$scope.showSearch;
	};

	/* NEW EVENT MODAL */

	function getDateTime() {
		var dateString = (new Date()).toString.split(' ');
		datString[4] = dateString[4].split(':');
		var dateTime = {
			month: dateString[1],
			day: dateString[2],
			year: dateString[3],
			hours: dateString[4][0],
			minutes: dateString[4][1]
		}
		return dateTime;
	}
	

	$scope.getCurrentAddress = function() {
		console.log("getting address");
		Map.findCurrentLocation(function(coords) {	
			var address = Http.getAddressForCoords(coords.lat, coords.lng, function(address) {
				console.log(address);
				$scope.newPostData.streetAddress1 = address.streetAddress1;
				$scope.newPostData.city = address.city;
				$scope.newPostData.state = address.state;
				$scope.newPostData.zipCode = address.zipCode;
			});
		}); // TODO: Promisify
	};

	$scope.postNewEvent = function() {
		// TODO: Check for authentication. If authenticated, proceed. Else "Please Login or register to post events"
		var dateTime = getDateTime();

		$scope.newPostData = {
				title: '',
				info: '',
				streetAddress1: '',
				streetAddress2: '',
				city: '',
				state: '',
				zipCode: '',
				startDateTime: new Date(),
				endDateTime: '',
				category: '',
				coords: {lat: undefined, lng: undefined}
			};
		$ionicModal.fromTemplateUrl('../templates/newEventModal.html', {
	    scope: $scope,
	  }).then(function(modal) {
	    $scope.modal = modal;
			$scope.toggleRight();
			$scope.openModal();
	  });
	};

	$scope.saveNewEvent = function() {
		// TODO: Get userId from Auth, pass it into http call below
		var userId = 1;
		// DUMMY INFO BELOW
		var address = ($scope.newPostData.streetAddress1+'+'+$scope.newPostData.streetAddress2+'+'+$scope.newPostData.city+'+'+$scope.newPostData.state+'+'+$scope.newPostData.zipCode).split(' ').join('+');
		Http.getCoordsForAddress(address, function(coords) {
			$scope.newPostData.coords = coords;
			Http.saveNewEvent($scope.newPostData);
		});
	};


}])


// angular.module('radar').controller('ModalCtrl', function ($scope, $modalInstance) {

//   $scope.ok = function () {
//     $modalInstance.close();
//   };

//   $scope.cancel = function () {
//     $modalInstance.dismiss('cancel');
//   };

// });
{'fraction_non_alphanumeric': 0.17529711375212223, 'fraction_numerical': 0.0030772495755517827, 'mean_word_length': 3.729051680883091, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5914167', 'n_tokens_mistral': 3541, 'n_tokens_neox': 3111, 'n_words': 581}