pyc-website

main website for pyc inc.

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

commit c17fdf789672ab12566c5551c86b7dde6d65a838
parent c0644b045fccc0e209852b9e5b0f84fc1601ad22
Author: Jul <jul@9o.is>
Date:   Sat, 23 Aug 2014 14:26:33 -0400

modularized App.js

Diffstat:
Msrc/main/webapp/app/App.js | 711+++----------------------------------------------------------------------------
Asrc/main/webapp/app/mycontrollers/AtmApplication.js | 30++++++++++++++++++++++++++++++
Asrc/main/webapp/app/mycontrollers/AtmHelper.js | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/main/webapp/app/mycontrollers/Contact.js | 27+++++++++++++++++++++++++++
Asrc/main/webapp/app/mycontrollers/FindAtm.js | 188+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/main/webapp/app/mycontrollers/IdVerification.js | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/main/webapp/app/mycontrollers/IntroVideo.js | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/main/webapp/app/mycontrollers/PasswordChange.js | 30++++++++++++++++++++++++++++++
Asrc/main/webapp/app/mycontrollers/PasswordRecovery.js | 27+++++++++++++++++++++++++++
Asrc/main/webapp/app/mycontrollers/PhoneVerification.js | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/main/webapp/app/mycontrollers/PurchaseLimit.js | 11+++++++++++
Asrc/main/webapp/app/mycontrollers/UserLogin.js | 28++++++++++++++++++++++++++++
Asrc/main/webapp/app/mycontrollers/UserRegistration.js | 27+++++++++++++++++++++++++++
Asrc/main/webapp/app/mycontrollers/UserSettings.js | 37+++++++++++++++++++++++++++++++++++++
Asrc/main/webapp/app/mycontrollers/UserVerifyPassword.js | 7+++++++
Asrc/main/webapp/app/mycontrollers/Variables.js | 9+++++++++
Asrc/main/webapp/app/mycontrollers/VerifyId.js | 44++++++++++++++++++++++++++++++++++++++++++++
17 files changed, 730 insertions(+), 692 deletions(-)

diff --git a/src/main/webapp/app/App.js b/src/main/webapp/app/App.js @@ -1,4 +1,4 @@ -var app = angular.module("app", [ +angular.module("app", [ 'google-maps', 'ui.bootstrap', //'ui.router', @@ -11,695 +11,22 @@ var app = angular.module("app", [ 'match', 'disabler', 'ngAlert', - 'Forms', + 'Forms', 'mgo-angular-wizard', 'ngAnimate', - 'ngReallyClick']); - -var PASSWORD_REGEXP = /^(?=.*[^a-zA-Z])\S{8,}$/; -var UNSAFE_URL_REGEXP = /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/; - -var screen_xs = 480; -//var screen_md = 992; - - -app.controller('IntroVideoCtrl', ['$scope', function($scope) { - - $scope.current = 0; - var intervals = [1,4,6.5,9,11]; - - var navbar_height = 80; - var videow = document.getElementById("intro-content"); - var videobg = document.getElementById("bgvid"); - - videow.setAttribute("style", "height:" + (window.innerHeight - navbar_height) + "px"); - videobg.setAttribute("style", "height:" + (window.innerHeight - navbar_height) + "px"); - - - $(document).ready(function() { - - Modernizr.addTest('ipad', function () { - return !!navigator.userAgent.match(/iPad/i); - }); - - Modernizr.addTest('iphone', function () { - return !!navigator.userAgent.match(/iPhone/i); - }); - - Modernizr.addTest('ipod', function () { - return !!navigator.userAgent.match(/iPod/i); - }); - - Modernizr.addTest('android', function () { - return !!navigator.userAgent.match(/android/i); - }); - - Modernizr.addTest('excludedplatforms', function () { - return (Modernizr.ipad || Modernizr.ipod || Modernizr.iphone || Modernizr.android); - }); - - if(!Modernizr.excludedplatforms) { - jQuery.backgroundVideo(jQuery('#bgvid'), { - "align" : "centerXY", - "width" : 1280, - "height" : 720, - "path" : "https://s3.amazonaws.com/assets-pyc/", - "filename" : "lamassu_how_to", - "types" : [ "mp4", "webm" ] - }); - - var video = document.getElementById("video_background"); - - video.addEventListener("ended",function(){ - video.pause(); - $scope.current = $scope.current + 1; - $scope.$apply(); - },false); - - video.addEventListener("timeupdate",function(){ - if(video.currentTime >= intervals[$scope.current]) { - $scope.current = ($scope.current+1 >= intervals.length) ? 0 : ($scope.current+1); - $scope.$apply(); - } - },false); - - setTimeout(function(){ - video.muted = true; - video.play(); - }, 2000); - } else { - $scope.current = 5; - $scope.$apply(); - } - - }); -}]); - - -app.controller('AtmApplicationAlert', ['$scope', '$controller', function($scope, $controller) { - $controller('AlertCtrl', {$scope: $scope}); - - $scope.$on('alertAtmApp', function(event, alert) { - $scope.addAlert(alert); - }); -}]); - -app.controller('AtmApplicationCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { - $controller('FormCtrl', {$scope: $scope}); - - $scope.url_regex = UNSAFE_URL_REGEXP; - - $scope.save = function() { - var success = function(alert) { - $rootScope.$broadcast('alertAtmApp', alert); - $scope.reset(); - }; - - var failure = function(alert) { - $rootScope.$broadcast('alertAtmApp', alert); - }; - - $scope.submit('AtmApplication', 'submit', success, failure); - }; -}]); - - -app.controller('ContactAlert', ['$scope', '$controller', function($scope, $controller) { - $controller('AlertCtrl', {$scope: $scope}); - - $scope.$on('alertContactApp', function(event, alert) { - $scope.addAlert(alert); - }); -}]); - -app.controller('ContactCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { - $controller('FormCtrl', {$scope: $scope}); - - $scope.save = function() { - var success = function(alert) { - $rootScope.$broadcast('alertContactApp', alert); - $scope.reset(); - }; - - var failure = function(alert) { - $rootScope.$broadcast('alertContactApp', alert); - }; - - $scope.submit('Contact', 'submit', success, failure); - }; -}]); - - -app.controller('UserRegistrationAlert', ['$scope', '$controller', function($scope, $controller) { - $controller('AlertCtrl', {$scope: $scope}); - - $scope.$on('alertUserRegister', function(event, alert) { - $scope.addAlert(alert); - }); -}]); - -app.controller('UserRegistrationCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { - $controller('FormCtrl', {$scope: $scope}); - - $scope.save = function() { - var success = function(alert) { - $rootScope.$broadcast('alertUserRegister', alert); - $scope.reset(); - }; - - var failure = function(alert) { - $rootScope.$broadcast('alertUserRegister', alert); - }; - - $scope.submit('UserRegistration', 'submit', success, failure); - }; -}]); - -app.controller('PasswordRecoveryAlert', ['$scope', '$controller', function($scope, $controller) { - $controller('AlertCtrl', {$scope: $scope}); - - $scope.$on('alertPasswordRecover', function(event, alert) { - $scope.addAlert(alert); - }); -}]); - -app.controller('PasswordRecoveryCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { - $controller('FormCtrl', {$scope: $scope}); - - $scope.save = function() { - var success = function(alert) { - $rootScope.$broadcast('alertPasswordRecover', alert); - $scope.reset(); - }; - - var failure = function(alert) { - $rootScope.$broadcast('alertPasswordRecover', alert); - }; - - $scope.submit('PasswordRecovery', 'submit', success, failure); - }; -}]); - -app.controller('UserLoginAlert', ['$scope', '$controller', function($scope, $controller) { - $controller('AlertCtrl', {$scope: $scope}); - - $scope.$on('alertUserLogin', function(event, alert) { - $scope.addAlert(alert); - }); -}]); - -app.controller('UserLoginCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { - $controller('FormCtrl', {$scope: $scope}); - - $scope.model = {remember: false}; - - $scope.save = function() { - var success = function() { - window.location.href = "/settings"; - }; - - var failure = function(alert) { - $rootScope.$broadcast('alertUserLogin', alert); - }; - - $scope.submit('UserLogin', 'submit', success, failure); - }; -}]); - - -app.controller('PasswordChangeAlert', ['$scope', '$controller', function($scope, $controller) { - $controller('AlertCtrl', {$scope: $scope}); - - $scope.$on('alertPasswordChange', function(event, alert) { - $scope.addAlert(alert); - }); -}]); - -app.controller('PasswordChangeCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { - $controller('FormCtrl', {$scope: $scope}); - - $scope.password_regex = PASSWORD_REGEXP; - - $scope.save = function() { - var success = function(alert) { - $rootScope.$broadcast('alertPasswordChange', alert); - $scope.reset(); - }; - - var failure = function(alert) { - $rootScope.$broadcast('alertPasswordChange', alert); - }; - - $scope.submit('PasswordChange', 'submit', success, failure); - }; -}]); - - -app.controller('PurchaseLimitCtrl', ['$scope', function($scope) { - $scope.thirdPartyVerified = false; -}]); - - -app.controller('PhoneVerificationAlert', ['$scope', '$controller', function($scope, $controller) { - $controller('AlertCtrl', {$scope: $scope}); - - $scope.$on('alertPhoneVerification', function(event, alert) { - $scope.addAlert(alert); - }); -}]); - -app.controller('PhoneVerificationCtrl', ['$scope', '$controller', '$rootScope', 'WizardHandler', function($scope, $controller, $rootScope, WizardHandler) { - $controller('AutoUpdateFormCtrl', {$scope: $scope, $controller: $controller, $rootScope: $rootScope}); - $scope.init('PhoneVerification', 'init'); - - $scope.updatePostal = function() { - var failure = function(alert) { - $rootScope.$broadcast('alertPhoneVerification', alert); - }; - - $scope.update('PhoneVerification', 'postal', function(){}, failure); - }; - - $scope.sentsms = false; - - $scope.sendsms = function() { - var success = function() { - $scope.sentsms = true; - $rootScope.$broadcast('alertPhoneVerification', { - msg_type: "success", - msg: "SMS Private Code has been sent. Input the private code to verify.", - timeout: 4000 - }); - }; - - var failure = function(alert) { - $rootScope.$broadcast('alertPhoneVerification', alert); - }; - - $scope.submit('PhoneVerification', 'sendsms', success, failure); - }; - - $scope.verifyphone = function () { - var success = function() { - WizardHandler.wizard().next(); - }; - - var failure = function(alert) { - $rootScope.$broadcast('alertPhoneVerification', alert); - }; - - $scope.submit('PhoneVerification', 'verifyphone', success, failure); - }; -}]); - - -app.controller('IdVerificationAlert', ['$scope', '$controller', function($scope, $controller) { - $controller('AlertCtrl', {$scope: $scope}); - - $scope.$on('alertIdVerification', function(event, alert) { - $scope.addAlert(alert); - }); -}]); - -app.controller('IdVerificationCtrl', ['$scope', '$controller', '$rootScope', '$fileUploader', function($scope, $controller, $rootScope, $fileUploader) { - $controller('FormCtrl', {$scope: $scope, $controller: $controller}); - - $scope.uploader = $fileUploader.create({ - scope: $scope, - url: '/settings/verification/upload' - }); - - // file must be an image - $scope.uploader.filters.push(function(item) { - var type = $scope.uploader.isHTML5 ? item.type : '/' + item.value.slice(item.value.lastIndexOf('.') + 1); - type = '|' + type.toLowerCase().slice(type.lastIndexOf('/') + 1) + '|'; - return '|jpg|png|jpeg|pdf|'.indexOf(type) !== -1; - }); - - // file must be less than 5 MB (5243000 bytes) - $scope.uploader.filters.push(function(item) { - return item.size < 5243000; - }); - - // 1 file max are allowed - $scope.uploader.queueLimit = 1; - - // 1 file minimum required before submitting - $scope.filesRequired = function() { - return $scope.uploader.queue.length < 1; - }; - - $scope.uploader.bind('whenaddingfilefailed', function () { - $rootScope.$broadcast('alertIdVerification', {msg_type: "danger", msg: "Your file could not be added."}); - }); - - $scope.uploader.bind('error', function () { - $rootScope.$broadcast('alertIdVerification', {msg_type: "danger", msg: "Your file could not be uploaded. Please try again."}); - }); - - $scope.uploader.bind('success', function () { - var success = function(alert) { - $rootScope.$broadcast('alertIdVerification', alert); - //$state.go($state.$current, null, { reload: true }); - $scope.uploader.clearQueue(); - $scope.reset(); - }; - - var failure = function(alert) { - $rootScope.$broadcast('alertIdVerification', alert); - }; - - $scope.submit('IdVerification', 'submit', success, failure); - }); - - $scope.save = function() { - $scope.loading = true; - $scope.uploader.uploadAll(); - }; -}]); - -app.controller('UserSettingsCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { - $controller('AutoUpdateFormCtrl', {$scope: $scope, $controller: $controller, $rootScope: $rootScope}); - $scope.init('UserSettings','init'); - - $scope.updateUserSettings = function(funcName) { - $scope.update('UserSettings', funcName); - }; -}]); - - -app.controller('UserSettingsEmailAlert', ['$scope', '$controller', function($scope, $controller) { - $controller('AlertCtrl', {$scope: $scope}); - - $scope.$on('alertUserSettingsEmail', function(event, alert) { - $scope.addAlert(alert); - }); -}]); - -app.controller('UserSettingsEmailCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { - $controller('LoadedFormCtrl', {$scope: $scope, $controller: $controller}); - $scope.init('UserSettingsEmail', 'init'); - - $scope.save = function() { - var success = function(alert) { - $rootScope.$broadcast('alertUserSettingsEmail', alert); - }; - - var failure = function(alert) { - $rootScope.$broadcast('alertUserSettingsEmail', alert); - }; - - $scope.submit('UserSettingsEmail', 'submit', success, failure); - }; -}]); - - -app.controller('UserVerifyPasswordCtrl', ['$scope', '$controller', function($scope, $controller) { - $controller('LoadedFormCtrl', {$scope: $scope, $controller: $controller}); - $scope.init('UserVerifyPassword', 'init'); -}]); - - -app.controller('PurchaseLimitListCtrl', ['$scope', '$controller', function($scope, $controller) { - $controller('LoadedFormCtrl', {$scope: $scope, $controller: $controller}); - $scope.init('PurchaseLimitList', 'init'); -}]); - -app.controller('VerifyIdCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { - $controller('LoadedFormCtrl', {$scope: $scope, $controller: $controller}); - - $scope.init('VerifyId', 'init', function() { - $scope.currentUser = $scope.model.users[0]; - $scope.response = {}; - }); - - - $scope.accept = function() { - $scope.response.accepted = true; - $scope.save(); - }; - - $scope.reject = function() { - $scope.response.accepted = false; - $scope.save(); - }; - - $scope.setCurrentUser = function(user, index) { - $scope.currentUser = angular.copy(user); - $scope.currentUser.index = index; - }; - - $scope.save = function() { - var success = function(alert) { - $scope.model.users.splice($scope.currentUser.index,1); - $scope.currentUser = {}; - $scope.response = {}; - $rootScope.$broadcast('alertDialog', alert); - }; - - var failure = function(alert) { - $rootScope.$broadcast('alertDialog', alert); - }; - - $scope.response.userId = $scope.currentUser.id; - $scope.submit('VerifyId', 'submit', success, failure, $scope.response); - }; - -}]); - - -/** Functions used for info about BTM */ -app.controller('AtmHelperFuncs', ['$scope', function($scope) { - $scope.timeRange = function(open, clos) { - var openv = open.split(":"); - var opend = new Date(2014, 1, 1, openv[0], openv[1]); - var closv = clos.split(":"); - var closd = new Date(2014, 1, 1, closv[0], closv[1]); - return formatAMPM(opend) + " - " + formatAMPM(closd); - }; - - var formatAMPM = function(date) { - var hours = date.getHours(); - var minutes = date.getMinutes(); - var ampm = hours >= 12 ? 'pm' : 'am'; - hours = hours % 12; - hours = hours ? hours : 12; // the hour '0' should be '12' - minutes = minutes < 10 ? '0'+minutes : minutes; - var strTime = hours + ':' + minutes + ' ' + ampm; - return strTime; - }; - - $scope.today = function() { - return new Date().getDay(); - }; - - $scope.day = function(i) { - if(i===0) {return "Sunday";} - if(i===1) {return "Monday";} - if(i===2) {return "Tuesday";} - if(i===3) {return "Wednesday";} - if(i===4) {return "Thursday";} - if(i===5) {return "Friday";} - if(i===6) {return "Saturday";} - }; - - $scope.imageAtm = function(marker, i) { - if(marker) { - return "https://s3.amazonaws.com/assets-pyc/atm/"+marker.name+"/"+i+".jpg"; - } - }; - - $scope.pageAtm = function(marker) { - if(marker) { - return "/btm/"+marker.name; - } - }; - -}]); - - -app.controller('NearAtmNotifyAlert', ['$scope', '$controller', function($scope, $controller) { - $controller('AlertCtrl', {$scope: $scope}); - - $scope.$on('alertNearAtm', function(event, alert) { - $scope.addAlert(alert); - }); -}]); - - -app.controller('FindAtmCtrl', ['$scope', '$timeout', '$location', '$anchorScroll', '$controller', '$rootScope', function($scope, $timeout, $location, $anchorScroll, $controller, $rootScope) { - $controller('LoadedFormCtrl', {$scope: $scope, $controller: $controller}); - $controller('AtmHelperFuncs', {$scope: $scope}); - - $scope.init('FindAtm', 'init', function() { - - $scope.markers = angular.copy($scope.model); - $scope.featuredMarker = $scope.markers[0]; - $scope.currentMarker = $scope.featuredMarker; - $scope.model = {}; - /* - $scope.map.center = { - latitude: $scope.featuredMarker.loc.latitude, - longitude: $scope.featuredMarker.loc.longitude - }; - */ - setDynamicMarkers(); - }); - - $scope.nonfound = false; - - $scope.mapExpanded = window.innerWidth < screen_xs; - - $scope.expandMap = function() { - $scope.mapExpanded = true; - $location.hash("locations"); - $anchorScroll(); - }; - - $scope.zoomIn = function() { - $scope.map.zoom = $scope.map.zoom + 1; - }; - - $scope.zoomOut = function() { - $scope.map.zoom = $scope.map.zoom - 1; - }; - - $scope.search = function() { - var success = function(alert) { - $scope.nonfound = false; - - if(alert.data) { - $scope.markers = angular.copy(alert.data); - $scope.currentMarker = $scope.markers[0]; - $scope.map.center = angular.copy($scope.currentMarker.loc); - setDynamicMarkers(); - } - }; - - var failure = function(alert) { - $scope.nonfound = true; - - if(alert.data.loc) { - $scope.map.center = alert.data.loc; - } - }; - - $scope.submit('FindAtm', 'submit', success, failure); - }; - - $scope.markers = []; - $scope.featuredMarker = {}; - - var setDynamicMarkers = function() { $timeout(function() { - var dynamicMarkers = $scope.markers; - - _.each(dynamicMarkers, function(marker) { - marker.closeClick = function() { - marker.showWindow = false; - $scope.currentMarker = null; - window.console.log("Now it's: "+$scope.currentMarker); - $scope.$apply(); - }; - marker.onClicked = function() { - $scope.onMarkerClicked(marker); - }; - }); - - $scope.map.dynamicMarkers = dynamicMarkers; - google.maps.event.trigger(mapObj, 'resize'); - }, 2000); }; - - /** Google Map Object */ - var mapObj = null; - - $scope.map = { - center: { - latitude: 42.058938, - longitude: -75.627209 - }, - zoom: 7, - dynamicMarkers: [], - markers: { - fit: false - }, - icon: "https://s3.amazonaws.com/assets-pyc/blue_marker2.png", - events: { - tilesloaded: function (map) { - $scope.$apply(function () { - mapObj = map; - }); - }/*, - resize: function (map) { - $scope.$apply(function () { - - // pan view on resize (markers were added to map) - if(window.innerWidth >= screen_md) { - map.panBy(-150,-150); - } else if(window.innerWidth >= screen_xs) { - map.panBy(0,-250); - } else { - map.panBy(0,-40); - } - }); - }*/ - }, - infoWindow: { - options: { - pixelOffset: { 'width': 0, 'height': -44 } - } - } - }; - - $scope.currentMarker = {}; - - $scope.onMarkerClicked = function(marker) { - if ($scope.currentMarker) { - $scope.currentMarker.closeClick(); - } - $scope.currentMarker = marker; - marker.showWindow = true; - $scope.$apply(); - }; - - - $scope.searchPlaceholder = function() { - - if($scope.currentMarker) { - var marker = $scope.currentMarker; - return marker.address + ", " + marker.city + ", " + marker.state; - } - - return "Search address, business name ... "; - }; - - $scope.notification = {}; - - $scope.notifyEmail = function() { - var success = function(alert) { - $scope.notify_loading = false; - $rootScope.$broadcast('alertNearAtm', alert); - $scope.notification = {}; - }; - - var failure = function(alert) { - $scope.notify_loading = false; - $rootScope.$broadcast('alertNearAtm', alert); - }; - - $scope.notify_loading = true; - $scope.submit('FindAtm', 'notifyEmail', success, failure, $scope.notification, $scope.notify_loading); - }; - - - // set the map open - $scope.mapExpanded = true; - -}]); - - -app.controller('AtmProfileCtrl', ['$scope', '$controller', function($scope, $controller) { - $controller('LoadedFormCtrl', {$scope: $scope, $controller: $controller}); - $controller('AtmHelperFuncs', {$scope: $scope}); - - $scope.init('AtmProfile', 'init'); -}]); -\ No newline at end of file + 'ngReallyClick', + 'AtmApplication', + 'Contact', + 'FindAtm', + 'IdVerification', + 'IntroVideo', + 'PasswordChange', + 'PasswordRecovery', + 'PhoneVerification', + 'PurchaseLimit', + 'UserLogin', + 'UserRegistration', + 'UserSettings', + 'UserVerifyPassword', + 'VerifyId' +]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/AtmApplication.js b/src/main/webapp/app/mycontrollers/AtmApplication.js @@ -0,0 +1,29 @@ +angular.module("AtmApplication", ['Forms', 'ngAlert', 'Variables']) + +.controller('AtmApplicationAlert', ['$scope', '$controller', function($scope, $controller) { + $controller('AlertCtrl', {$scope: $scope}); + + $scope.$on('alertAtmApp', function(event, alert) { + $scope.addAlert(alert); + }); +}]) + +.controller('AtmApplicationCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { + $controller('FormCtrl', {$scope: $scope}); + $controller('VariablesCtrl', {$scope: $scope}); + + $scope.url_regex = $scope.UNSAFE_URL_REGEXP; + + $scope.save = function() { + var success = function(alert) { + $rootScope.$broadcast('alertAtmApp', alert); + $scope.reset(); + }; + + var failure = function(alert) { + $rootScope.$broadcast('alertAtmApp', alert); + }; + + $scope.submit('AtmApplication', 'submit', success, failure); + }; +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/AtmHelper.js b/src/main/webapp/app/mycontrollers/AtmHelper.js @@ -0,0 +1,50 @@ +angular.module("AtmHelper", []) + +/** Functions used for info about BTM */ +.controller('AtmHelperFuncs', ['$scope', function($scope) { + $scope.timeRange = function(open, clos) { + var openv = open.split(":"); + var opend = new Date(2014, 1, 1, openv[0], openv[1]); + var closv = clos.split(":"); + var closd = new Date(2014, 1, 1, closv[0], closv[1]); + return formatAMPM(opend) + " - " + formatAMPM(closd); + }; + + var formatAMPM = function(date) { + var hours = date.getHours(); + var minutes = date.getMinutes(); + var ampm = hours >= 12 ? 'pm' : 'am'; + hours = hours % 12; + hours = hours ? hours : 12; // the hour '0' should be '12' + minutes = minutes < 10 ? '0'+minutes : minutes; + var strTime = hours + ':' + minutes + ' ' + ampm; + return strTime; + }; + + $scope.today = function() { + return new Date().getDay(); + }; + + $scope.day = function(i) { + if(i===0) {return "Sunday";} + if(i===1) {return "Monday";} + if(i===2) {return "Tuesday";} + if(i===3) {return "Wednesday";} + if(i===4) {return "Thursday";} + if(i===5) {return "Friday";} + if(i===6) {return "Saturday";} + }; + + $scope.imageAtm = function(marker, i) { + if(marker) { + return "https://s3.amazonaws.com/assets-pyc/btm/"+marker.name+"/"+i+".jpg"; + } + }; + + $scope.pageAtm = function(marker) { + if(marker) { + return "/btm/"+marker.name; + } + }; + +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/Contact.js b/src/main/webapp/app/mycontrollers/Contact.js @@ -0,0 +1,26 @@ +angular.module("Contact", ['Forms', 'ngAlert']) + +.controller('ContactAlert', ['$scope', '$controller', function($scope, $controller) { + $controller('AlertCtrl', {$scope: $scope}); + + $scope.$on('alertContactApp', function(event, alert) { + $scope.addAlert(alert); + }); +}]) + +.controller('ContactCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { + $controller('FormCtrl', {$scope: $scope}); + + $scope.save = function() { + var success = function(alert) { + $rootScope.$broadcast('alertContactApp', alert); + $scope.reset(); + }; + + var failure = function(alert) { + $rootScope.$broadcast('alertContactApp', alert); + }; + + $scope.submit('Contact', 'submit', success, failure); + }; +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/FindAtm.js b/src/main/webapp/app/mycontrollers/FindAtm.js @@ -0,0 +1,187 @@ +angular.module("FindAtm", ['Forms', 'ngAlert', 'AtmHelper', 'Variables']) + +.controller('NearAtmNotifyAlert', ['$scope', '$controller', function($scope, $controller) { + $controller('AlertCtrl', {$scope: $scope}); + + $scope.$on('alertNearAtm', function(event, alert) { + $scope.addAlert(alert); + }); +}]) + + +.controller('FindAtmCtrl', ['$scope', '$timeout', '$location', '$anchorScroll', '$controller', '$rootScope', function($scope, $timeout, $location, $anchorScroll, $controller, $rootScope) { + $controller('LoadedFormCtrl', {$scope: $scope, $controller: $controller}); + $controller('AtmHelperFuncs', {$scope: $scope}); + $controller('VariablesCtrl', {$scope: $scope}); + + $scope.init('FindAtm', 'init', function() { + + $scope.markers = angular.copy($scope.model); + $scope.featuredMarker = $scope.markers[0]; + $scope.currentMarker = $scope.featuredMarker; + $scope.model = {}; + /* + $scope.map.center = { + latitude: $scope.featuredMarker.loc.latitude, + longitude: $scope.featuredMarker.loc.longitude + }; + */ + setDynamicMarkers(); + }); + + $scope.nonfound = false; + + $scope.mapExpanded = window.innerWidth < $scope.screen_xs; + + $scope.expandMap = function() { + $scope.mapExpanded = true; + $location.hash("locations"); + $anchorScroll(); + }; + + $scope.zoomIn = function() { + $scope.map.zoom = $scope.map.zoom + 1; + }; + + $scope.zoomOut = function() { + $scope.map.zoom = $scope.map.zoom - 1; + }; + + $scope.search = function() { + var success = function(alert) { + $scope.nonfound = false; + + if(alert.data) { + $scope.markers = angular.copy(alert.data); + $scope.currentMarker = $scope.markers[0]; + $scope.map.center = angular.copy($scope.currentMarker.loc); + setDynamicMarkers(); + } + }; + + var failure = function(alert) { + $scope.nonfound = true; + + if(alert.data.loc) { + $scope.map.center = alert.data.loc; + } + }; + + $scope.submit('FindAtm', 'submit', success, failure); + }; + + $scope.markers = []; + $scope.featuredMarker = {}; + + var setDynamicMarkers = function() { $timeout(function() { + var dynamicMarkers = $scope.markers; + + _.each(dynamicMarkers, function(marker) { + marker.closeClick = function() { + marker.showWindow = false; + $scope.currentMarker = null; + window.console.log("Now it's: "+$scope.currentMarker); + $scope.$apply(); + }; + marker.onClicked = function() { + $scope.onMarkerClicked(marker); + }; + }); + + $scope.map.dynamicMarkers = dynamicMarkers; + google.maps.event.trigger(mapObj, 'resize'); + }, 2000); }; + + /** Google Map Object */ + var mapObj = null; + + $scope.map = { + center: { + latitude: 42.058938, + longitude: -75.627209 + }, + zoom: 7, + dynamicMarkers: [], + markers: { + fit: false + }, + icon: "https://s3.amazonaws.com/assets-pyc/blue_marker2.png", + events: { + tilesloaded: function (map) { + $scope.$apply(function () { + mapObj = map; + }); + }/*, + resize: function (map) { + $scope.$apply(function () { + + // pan view on resize (markers were added to map) + if(window.innerWidth >= screen_md) { + map.panBy(-150,-150); + } else if(window.innerWidth >= $scope.screen_xs) { + map.panBy(0,-250); + } else { + map.panBy(0,-40); + } + }); + }*/ + }, + infoWindow: { + options: { + pixelOffset: { 'width': 0, 'height': -44 } + } + } + }; + + $scope.currentMarker = {}; + + $scope.onMarkerClicked = function(marker) { + if ($scope.currentMarker) { + $scope.currentMarker.closeClick(); + } + $scope.currentMarker = marker; + marker.showWindow = true; + $scope.$apply(); + }; + + + $scope.searchPlaceholder = function() { + + if($scope.currentMarker) { + var marker = $scope.currentMarker; + return marker.address + ", " + marker.city + ", " + marker.state; + } + + return "Search address, business name ... "; + }; + + $scope.notification = {}; + + $scope.notifyEmail = function() { + var success = function(alert) { + $scope.notify_loading = false; + $rootScope.$broadcast('alertNearAtm', alert); + $scope.notification = {}; + }; + + var failure = function(alert) { + $scope.notify_loading = false; + $rootScope.$broadcast('alertNearAtm', alert); + }; + + $scope.notify_loading = true; + $scope.submit('FindAtm', 'notifyEmail', success, failure, $scope.notification, $scope.notify_loading); + }; + + + // set the map open + $scope.mapExpanded = true; + +}]) + +.controller('AtmProfileCtrl', ['$scope', '$controller', function($scope, $controller) { + $controller('LoadedFormCtrl', {$scope: $scope, $controller: $controller}); + $controller('AtmHelperFuncs', {$scope: $scope}); + + $scope.init('AtmProfile', 'init'); +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/IdVerification.js b/src/main/webapp/app/mycontrollers/IdVerification.js @@ -0,0 +1,66 @@ +angular.module("IdVerification", ['Forms', 'ngAlert', 'angularFileUpload']) + +.controller('IdVerificationAlert', ['$scope', '$controller', function($scope, $controller) { + $controller('AlertCtrl', {$scope: $scope}); + + $scope.$on('alertIdVerification', function(event, alert) { + $scope.addAlert(alert); + }); +}]) + +.controller('IdVerificationCtrl', ['$scope', '$controller', '$rootScope', '$fileUploader', function($scope, $controller, $rootScope, $fileUploader) { + $controller('FormCtrl', {$scope: $scope, $controller: $controller}); + + $scope.uploader = $fileUploader.create({ + scope: $scope, + url: '/settings/verification/upload' + }); + + // file must be an image + $scope.uploader.filters.push(function(item) { + var type = $scope.uploader.isHTML5 ? item.type : '/' + item.value.slice(item.value.lastIndexOf('.') + 1); + type = '|' + type.toLowerCase().slice(type.lastIndexOf('/') + 1) + '|'; + return '|jpg|png|jpeg|pdf|'.indexOf(type) !== -1; + }); + + // file must be less than 5 MB (5243000 bytes) + $scope.uploader.filters.push(function(item) { + return item.size < 5243000; + }); + + // 1 file max are allowed + $scope.uploader.queueLimit = 1; + + // 1 file minimum required before submitting + $scope.filesRequired = function() { + return $scope.uploader.queue.length < 1; + }; + + $scope.uploader.bind('whenaddingfilefailed', function () { + $rootScope.$broadcast('alertIdVerification', {msg_type: "danger", msg: "Your file could not be added."}); + }); + + $scope.uploader.bind('error', function () { + $rootScope.$broadcast('alertIdVerification', {msg_type: "danger", msg: "Your file could not be uploaded. Please try again."}); + }); + + $scope.uploader.bind('success', function () { + var success = function(alert) { + $rootScope.$broadcast('alertIdVerification', alert); + //$state.go($state.$current, null, { reload: true }); + $scope.uploader.clearQueue(); + $scope.reset(); + }; + + var failure = function(alert) { + $rootScope.$broadcast('alertIdVerification', alert); + }; + + $scope.submit('IdVerification', 'submit', success, failure); + }); + + $scope.save = function() { + $scope.loading = true; + $scope.uploader.uploadAll(); + }; +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/IntroVideo.js b/src/main/webapp/app/mycontrollers/IntroVideo.js @@ -0,0 +1,73 @@ +angular.module("IntroVideo", []) + +.controller('IntroVideoCtrl', ['$scope', function($scope) { + + $scope.current = 0; + var intervals = [1,4,6.5,9,11]; + + var navbar_height = 80; + var videow = document.getElementById("intro-content"); + var videobg = document.getElementById("bgvid"); + + videow.setAttribute("style", "height:" + (window.innerHeight - navbar_height) + "px"); + videobg.setAttribute("style", "height:" + (window.innerHeight - navbar_height) + "px"); + + + $(document).ready(function() { + + Modernizr.addTest('ipad', function () { + return !!navigator.userAgent.match(/iPad/i); + }); + + Modernizr.addTest('iphone', function () { + return !!navigator.userAgent.match(/iPhone/i); + }); + + Modernizr.addTest('ipod', function () { + return !!navigator.userAgent.match(/iPod/i); + }); + + Modernizr.addTest('android', function () { + return !!navigator.userAgent.match(/android/i); + }); + + Modernizr.addTest('excludedplatforms', function () { + return (Modernizr.ipad || Modernizr.ipod || Modernizr.iphone || Modernizr.android); + }); + + if(!Modernizr.excludedplatforms) { + jQuery.backgroundVideo(jQuery('#bgvid'), { + "align" : "centerXY", + "width" : 1280, + "height" : 720, + "path" : "https://s3.amazonaws.com/assets-pyc/", + "filename" : "lamassu_how_to", + "types" : [ "mp4", "webm" ] + }); + + var video = document.getElementById("video_background"); + + video.addEventListener("ended",function(){ + video.pause(); + $scope.current = 5; + $scope.$apply(); + },false); + + video.addEventListener("timeupdate",function(){ + if(video.currentTime >= intervals[$scope.current]) { + $scope.current = ($scope.current+1 >= intervals.length) ? 0 : ($scope.current+1); + $scope.$apply(); + } + },false); + + setTimeout(function(){ + video.muted = true; + video.play(); + }, 2000); + } else { + $scope.current = 5; + $scope.$apply(); + } + + }); +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/PasswordChange.js b/src/main/webapp/app/mycontrollers/PasswordChange.js @@ -0,0 +1,29 @@ +angular.module("PasswordChange", ['Forms', 'ngAlert', 'Variables']) + +.controller('PasswordChangeAlert', ['$scope', '$controller', function($scope, $controller) { + $controller('AlertCtrl', {$scope: $scope}); + + $scope.$on('alertPasswordChange', function(event, alert) { + $scope.addAlert(alert); + }); +}]) + +.controller('PasswordChangeCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { + $controller('FormCtrl', {$scope: $scope}); + $controller('VariablesCtrl', {$scope: $scope}); + + $scope.password_regex = $scope.PASSWORD_REGEXP; + + $scope.save = function() { + var success = function(alert) { + $rootScope.$broadcast('alertPasswordChange', alert); + $scope.reset(); + }; + + var failure = function(alert) { + $rootScope.$broadcast('alertPasswordChange', alert); + }; + + $scope.submit('PasswordChange', 'submit', success, failure); + }; +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/PasswordRecovery.js b/src/main/webapp/app/mycontrollers/PasswordRecovery.js @@ -0,0 +1,26 @@ +angular.module("PasswordRecovery", ['Forms', 'ngAlert']) + +.controller('PasswordRecoveryAlert', ['$scope', '$controller', function($scope, $controller) { + $controller('AlertCtrl', {$scope: $scope}); + + $scope.$on('alertPasswordRecover', function(event, alert) { + $scope.addAlert(alert); + }); +}]) + +.controller('PasswordRecoveryCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { + $controller('FormCtrl', {$scope: $scope}); + + $scope.save = function() { + var success = function(alert) { + $rootScope.$broadcast('alertPasswordRecover', alert); + $scope.reset(); + }; + + var failure = function(alert) { + $rootScope.$broadcast('alertPasswordRecover', alert); + }; + + $scope.submit('PasswordRecovery', 'submit', success, failure); + }; +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/PhoneVerification.js b/src/main/webapp/app/mycontrollers/PhoneVerification.js @@ -0,0 +1,53 @@ +angular.module("PhoneVerification", ['Forms', 'ngAlert', 'mgo-angular-wizard']) + +.controller('PhoneVerificationAlert', ['$scope', '$controller', function($scope, $controller) { + $controller('AlertCtrl', {$scope: $scope}); + + $scope.$on('alertPhoneVerification', function(event, alert) { + $scope.addAlert(alert); + }); +}]) + +.controller('PhoneVerificationCtrl', ['$scope', '$controller', '$rootScope', 'WizardHandler', function($scope, $controller, $rootScope, WizardHandler) { + $controller('AutoUpdateFormCtrl', {$scope: $scope, $controller: $controller, $rootScope: $rootScope}); + $scope.init('PhoneVerification', 'init'); + + $scope.updatePostal = function() { + var failure = function(alert) { + $rootScope.$broadcast('alertPhoneVerification', alert); + }; + + $scope.update('PhoneVerification', 'postal', function(){}, failure); + }; + + $scope.sentsms = false; + + $scope.sendsms = function() { + var success = function() { + $scope.sentsms = true; + $rootScope.$broadcast('alertPhoneVerification', { + msg_type: "success", + msg: "SMS Private Code has been sent. Input the private code to verify.", + timeout: 4000 + }); + }; + + var failure = function(alert) { + $rootScope.$broadcast('alertPhoneVerification', alert); + }; + + $scope.submit('PhoneVerification', 'sendsms', success, failure); + }; + + $scope.verifyphone = function () { + var success = function() { + WizardHandler.wizard().next(); + }; + + var failure = function(alert) { + $rootScope.$broadcast('alertPhoneVerification', alert); + }; + + $scope.submit('PhoneVerification', 'verifyphone', success, failure); + }; +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/PurchaseLimit.js b/src/main/webapp/app/mycontrollers/PurchaseLimit.js @@ -0,0 +1,10 @@ +angular.module("PurchaseLimit", ['Forms']) + +.controller('PurchaseLimitCtrl', ['$scope', function($scope) { + $scope.thirdPartyVerified = false; +}]) + +.controller('PurchaseLimitListCtrl', ['$scope', '$controller', function($scope, $controller) { + $controller('LoadedFormCtrl', {$scope: $scope, $controller: $controller}); + $scope.init('PurchaseLimitList', 'init'); +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/UserLogin.js b/src/main/webapp/app/mycontrollers/UserLogin.js @@ -0,0 +1,27 @@ +angular.module("UserLogin", ['Forms', 'ngAlert']) + +.controller('UserLoginAlert', ['$scope', '$controller', function($scope, $controller) { + $controller('AlertCtrl', {$scope: $scope}); + + $scope.$on('alertUserLogin', function(event, alert) { + $scope.addAlert(alert); + }); +}]) + +.controller('UserLoginCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { + $controller('FormCtrl', {$scope: $scope}); + + $scope.model = {remember: false}; + + $scope.save = function() { + var success = function() { + window.location.href = "/settings"; + }; + + var failure = function(alert) { + $rootScope.$broadcast('alertUserLogin', alert); + }; + + $scope.submit('UserLogin', 'submit', success, failure); + }; +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/UserRegistration.js b/src/main/webapp/app/mycontrollers/UserRegistration.js @@ -0,0 +1,26 @@ +angular.module("UserRegistration", ['Forms', 'ngAlert']) + +.controller('UserRegistrationAlert', ['$scope', '$controller', function($scope, $controller) { + $controller('AlertCtrl', {$scope: $scope}); + + $scope.$on('alertUserRegister', function(event, alert) { + $scope.addAlert(alert); + }); +}]) + +.controller('UserRegistrationCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { + $controller('FormCtrl', {$scope: $scope}); + + $scope.save = function() { + var success = function(alert) { + $rootScope.$broadcast('alertUserRegister', alert); + $scope.reset(); + }; + + var failure = function(alert) { + $rootScope.$broadcast('alertUserRegister', alert); + }; + + $scope.submit('UserRegistration', 'submit', success, failure); + }; +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/UserSettings.js b/src/main/webapp/app/mycontrollers/UserSettings.js @@ -0,0 +1,36 @@ +angular.module("UserSettings", ['Forms', 'ngAlert']) + +.controller('UserSettingsCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { + $controller('AutoUpdateFormCtrl', {$scope: $scope, $controller: $controller, $rootScope: $rootScope}); + $scope.init('UserSettings','init'); + + $scope.updateUserSettings = function(funcName) { + $scope.update('UserSettings', funcName); + }; +}]) + + +.controller('UserSettingsEmailAlert', ['$scope', '$controller', function($scope, $controller) { + $controller('AlertCtrl', {$scope: $scope}); + + $scope.$on('alertUserSettingsEmail', function(event, alert) { + $scope.addAlert(alert); + }); +}]) + +.controller('UserSettingsEmailCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { + $controller('LoadedFormCtrl', {$scope: $scope, $controller: $controller}); + $scope.init('UserSettingsEmail', 'init'); + + $scope.save = function() { + var success = function(alert) { + $rootScope.$broadcast('alertUserSettingsEmail', alert); + }; + + var failure = function(alert) { + $rootScope.$broadcast('alertUserSettingsEmail', alert); + }; + + $scope.submit('UserSettingsEmail', 'submit', success, failure); + }; +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/UserVerifyPassword.js b/src/main/webapp/app/mycontrollers/UserVerifyPassword.js @@ -0,0 +1,6 @@ +angular.module("UserVerifyPassword", ['Forms']) + +.controller('UserVerifyPasswordCtrl', ['$scope', '$controller', function($scope, $controller) { + $controller('LoadedFormCtrl', {$scope: $scope, $controller: $controller}); + $scope.init('UserVerifyPassword', 'init'); +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/Variables.js b/src/main/webapp/app/mycontrollers/Variables.js @@ -0,0 +1,8 @@ +angular.module("Variables", []) + +.controller("VariablesCtrl", ['$scope', function($scope) { + $scope.PASSWORD_REGEXP = /^(?=.*[^a-zA-Z])\S{8,}$/; + $scope.UNSAFE_URL_REGEXP = /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/; + $scope.screen_xs = 480; + $scope.screen_md = 992; +}]); +\ No newline at end of file diff --git a/src/main/webapp/app/mycontrollers/VerifyId.js b/src/main/webapp/app/mycontrollers/VerifyId.js @@ -0,0 +1,43 @@ +angular.module("VerifyId", ['Forms']) + +.controller('VerifyIdCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { + $controller('LoadedFormCtrl', {$scope: $scope, $controller: $controller}); + + $scope.init('VerifyId', 'init', function() { + $scope.currentUser = $scope.model.users[0]; + $scope.response = {}; + }); + + + $scope.accept = function() { + $scope.response.accepted = true; + $scope.save(); + }; + + $scope.reject = function() { + $scope.response.accepted = false; + $scope.save(); + }; + + $scope.setCurrentUser = function(user, index) { + $scope.currentUser = angular.copy(user); + $scope.currentUser.index = index; + }; + + $scope.save = function() { + var success = function(alert) { + $scope.model.users.splice($scope.currentUser.index,1); + $scope.currentUser = {}; + $scope.response = {}; + $rootScope.$broadcast('alertDialog', alert); + }; + + var failure = function(alert) { + $rootScope.$broadcast('alertDialog', alert); + }; + + $scope.response.userId = $scope.currentUser.id; + $scope.submit('VerifyId', 'submit', success, failure, $scope.response); + }; + +}]); +\ No newline at end of file