/* global _, angular, i18n */ 'use strict'; var controllers = angular.module('PromptSkill.controllers', []); controllers.controller('root', ['$scope','$location','$window','$q','$http','$timeout','$cookies','deviceDetector','promptskill','member','user', 'course', 'program', function($scope, $location, $window, $q, $http, $timeout, $cookies, deviceDetector, promptskill, member, user, course, program) { // // $scope.apikey = '[#apikey]'; $scope.year = new Date().getFullYear(); $scope.locale = null; $scope.language = 'en-US'; if($location.search().l) $scope.language = $location.search().l; // $scope.service = {promptskill, member, user, course, program} // $scope.academy = {}; $scope.formdata = {}; $scope.otp = {}; //$scope.navigator = {}; //$scope.academyService = academy; // $scope.bgAcademy = {'background-color':'[#bgacademy]'}; $scope.route = ''; $scope.currentUrl = $location.host(); $scope.parameterUrl = $location.url().split("?").length > 1 ? '?' + $location.url().split("?")[1] : ''; /* Layout */ $scope.promptskill = true; $scope.headbar = false; $scope.fullpage = false; // $scope.loading = true; // $scope.member = true; $scope.authorize = false; $scope.barCookies = false; /* Responsive Device */ $scope.mobile = screen.width <= 600; $scope.tablet = screen.width > 600 && screen.width <= 1024; $scope.init = function() { // academy.key($scope.apikey); // academy.data('identity').then(function(data) { // //console.log(data) // academy.aid(data.aid); // $scope.academy = data // }); // $scope.$watch('language', function(locale, language) { console.log(language) // if(locale=='en-US') $scope.locale = null; promptskill.language(locale).then(function(phrase) { if(phrase) { $scope.locale = phrase; } // console.log($scope.locale) }); }); var interval = setInterval(function() { if(document.readyState == 'complete') { //console.log(document.readyState) $window.scrollTo(0, 0); clearInterval(interval); } }, 200); // return; }; $scope.promptSkill = function() { $window.location.href = '//promptskill.com' + $scope.parameterUrl; } $scope.back = function () { //console.log('back'); $window.history.back(); }; $scope.active = function(path) { //console.log(path) return $location.path().match(new RegExp(path + '.*', 'i')) != null; }; $scope.logout = function() { $scope.service.user.clear(); $window.location.href = '/'; }; // $scope.$on('$viewContentLoaded', function(event, viewConfig) { //Here your view content is fully loaded !! // $('body').overlayScrollbars({ // overflowBehavior: {x:'hidden'}, // scrollbars: { // autoHide: 'leave', // autoHideDelay: 100, // }, // callbacks: { // onScroll:function() { // //console.log(this.scroll().position.y) // if(this.scroll().position.y ==6) { // //$('.promptskill-bar').removeClass('fixed'); // } else { // //$('.promptskill-bar').addClass('fixed'); // } // } // } // }); $timeout(function() { $scope.loading = false; $scope.checkCookie(); }, 2000) }); $scope.$on( "$routeChangeStart", function(event, route, current) { // $scope.member = true; // $scope.service.promptskill.data('identity').then(function(data) { // //$scope.header = data.header; // $scope.identity = data; // $scope.service.academy.aid($scope.identity.aid); // // //$scope.headerBanner = ''; // //console.log($scope.headerBanner) // //if(headBanners.indexOf(route.controller) >-1 && $scope.headerBanner.length <1) { // // $scope.headerBanner = data.header; // //} // var token = $location.hash().substr(6); // //console.log(token) // if(token) { // $scope.service.user.invite(token).then(function(data) { // //console.log(data) // $scope.service.course.invited(data.invited); // $scope.service.user.logged(data); // $window.location.href = '/course/'+$scope.service.course.invited(); // }); // } // // //console.log($scope.header.banner) // if (!$scope.identity.online && $scope.service.user.token()==undefined) { // //$scope.promptskill = false; // //$scope.authorize = false; // //console.log(token) // $location.path('/prelaunch'); // //$window.location.href = '/prelaunch'; // } // }) }); // Initialize Firebase App $scope.service.member.firebase().then(function(response) { // console.log(response) if (response) firebase.initializeApp(response); }) }]); controllers.controller('navigation', ['$scope', function($scope) { // /*$scope.navigation = function() { return 'templates/layouts/header.promptskill'; };*/ }]); controllers.controller('prelaunch', [function() { }]); controllers.controller('home', ['$scope', function($scope) { // $scope.$parent.promptskill = false; $scope.$parent.headbar = true; }]); controllers.controller('academy', [function() { // }]); controllers.controller('user', ['$scope', '$window', '$location', '$routeParams', function($scope, $window, $location, $routeParams) { // console.log($location.hash()); // // if (!$scope.service.user.logged()) $window.location = '/signin'; //console.log($scope.route.controller ) // $scope.user = $routeParams; }]); controllers.controller('course', ['$scope', '$location', '$timeout', '$routeParams', function($scope, $location, $timeout, $routeParams) { // }]); controllers.controller('customer', ['$scope', '$location', '$http' , '$timeout', function($scope, $location, $http ,$timeout) { // }]); controllers.controller('aboutus', ['$scope', '$location', '$http' , '$timeout', function($scope, $location, $http ,$timeout) { // }]); controllers.controller('member', ['$scope', '$window', '$location', '$http' , '$timeout', function($scope, $window, $location, $http ,$timeout) { $scope.$parent.fullpage = true; if($location.hash()) { $scope.passkey = $location.hash(); } //console.log(lastUrl) // if(!$scope.service.user.logged()) { // // // $scope.signup = function() { // // // var formCheck = angular.element('.form-checkbox').find('input'); // var accepted = true; // angular.forEach(formCheck, function(input) { // accepted = accepted && angular.element(input).prop("checked"); // }); // if (accepted) { // //console.log('accepted') // var $forminput = angular.element('.form-input').find('input'); // angular.forEach($forminput, function(input) { // var $input = angular.element(input); // if($input.val() =='') { // $input.addClass('invalid'); // } // }); // $scope.service.user.signup($forminput).then(function(data) { // //console.log(data) // if(data.err) { // $scope.formdata.helper = data.msg; // } else { // user.logged(data); // $window.location.href = '/profile'; // } // }) // } else { // $scope.formdata.helper = 'ยอมรับเงื่อนไขการให้บริการ'; // console.log('rejected') // } // } // // $scope.signin = function() { // // // $scope.formdata = {} // $scope.service.user.signin(angular.element('.form-input').find('input')) // .then(function(data) { // //console.log(data.msg) // //console.log(lastUrl) // if(data.err==undefined) { // user.logged(data); // $window.location = lastUrl; // } else { // //console.log(data.msg) // $scope.formdata.helper = data.msg; // } // //console.log($scope.formdata.helper) // }) // } // } else $window.location = '/'; }]);