pyc-website

main website for pyc inc.

git clone https://9o.is/git/pyc-website.git

AtmHelper.js

(1458B)


      1 angular.module("AtmHelper", [])
      2 
      3 /** Functions used for info about ATM */
      4 .controller('AtmHelperFuncs', ['$scope', function($scope) {		
      5 	$scope.timeRange = function(open, clos) {
      6 		var openv = open.split(":");
      7 		var opend = new Date(2014, 1, 1, openv[0], openv[1]);
      8 		var closv = clos.split(":");
      9 		var closd = new Date(2014, 1, 1, closv[0], closv[1]);
     10 		return formatAMPM(opend) + " - " + formatAMPM(closd);
     11 	};
     12 	
     13 	var formatAMPM = function(date) {
     14 		  var hours = date.getHours();
     15 		  var minutes = date.getMinutes();
     16 		  var ampm = hours >= 12 ? 'pm' : 'am';
     17 		  hours = hours % 12;
     18 		  hours = hours ? hours : 12; // the hour '0' should be '12'
     19 		  minutes = minutes < 10 ? '0'+minutes : minutes;
     20 		  var strTime = hours + ':' + minutes + ' ' + ampm;
     21 		  return strTime;
     22 	};
     23 	
     24 	$scope.today = function() {
     25 		return new Date().getDay();
     26 	};
     27 	
     28 	$scope.day = function(i) {
     29 		if(i===0) {return "Sunday";}
     30 		if(i===1) {return "Monday";}
     31 		if(i===2) {return "Tuesday";}
     32 		if(i===3) {return "Wednesday";}
     33 		if(i===4) {return "Thursday";}
     34 		if(i===5) {return "Friday";}
     35 		if(i===6) {return "Saturday";}
     36 	};
     37 	
     38 	$scope.imageAtm = function(marker, i) {
     39 		if(marker) {
     40 			return "https://s3.amazonaws.com/assets-pyc/atm/"+marker.name+"/"+i+".jpg";
     41 		}
     42 	};
     43 	
     44 	$scope.pageAtm = function(marker) {
     45 		if(marker) {
     46 			return "/atm/"+marker.name;
     47 		}
     48 	};
     49 
     50 	$scope.gotoPageAtm = function(marker) {
     51 		if(marker) {
     52 			window.location = $scope.pageAtm(marker);
     53 		}
     54 	};
     55 	
     56 }]);