/* global _, angular, i18n */ 'use strict'; var controllers = angular.module('DinsorApp.controllers', []); controllers.controller('app', ['$scope','$location', '$routeParams','$q','$window','$timeout','$cookies','app','user','member','seller', function($scope, $location, $routeParams, $q, $window, $timeout, $cookies, app, user, member,seller) { // //$scope.apikey = '[#apikey]'; //$scope.mobile = false; $scope.year = new Date().getFullYear(); // $scope.service = {app, user, member, seller}; // $scope.currentUrl = $location.host(); //$scope.navigator = {}; $scope.defaultThumbnail = '/public/img/background/background-no-picture-500x500.jpg'; $scope.defaultBanner = '/public/img/background/background-no-picture-1200x460.jpg'; $scope.bgAcademy = {'background-color':'#f5f5f5'}; $scope.route = ''; /* layout */ $scope.headbar = true; $scope.fullpage = false; $scope.intro = false; // $scope.loading = false; // $scope.member = true; $scope.authorize = false; $scope.barCookies = false; $scope.dashboard = false; $scope.path = '/dashboard'; $scope.init = function() { // prelaunch banner const prelaunch = sessionStorage.getItem("prelaunch"); const path = $location.url(); const except = '/register-form'; if(prelaunch==null && !path.includes(except)) { $window.location.href = '/prelaunch'; sessionStorage.setItem("prelaunch", $location.url()); } var interval = setInterval(function() { if(document.readyState == 'complete') { //console.log(document.readyState) $window.scrollTo(0, 0); clearInterval(interval); } }, 500); return; }; $scope.scrollToTop = function () { // Scroll to Top of Page. var deferred = $q.defer(); deferred.resolve(angular.element("html, body").animate({ "scrollTop": 0 })); return deferred.promise; } $scope.back = function () { //console.log('back'); $window.history.back(); }; $scope.timeout = function(delay, callback) { $timeout(function() { if(callback!=undefined) { callback; } else true; }, delay); } $scope.gotoUrl = function(uri) { $window.location = uri; } $scope.openUrl = function(uri, target) { $window.open(uri, target); } $scope.getPath = function() { $scope.path = $location.path(); } $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: { // // } // }); $timeout(function() { $scope.loading = false; $scope.checkCookies(); }, 900) // $(window).focus(function() { //console.log('window active') }); // $(window).blur(function() { //console.log('window inactive') }); }); $scope.$on("$routeChangeStart", function(event, route, current) { // $timeout(function() { $scope.language = $routeParams.language; // console.log($scope.language); }, 600); // $scope.member = true; }); // cookie policy $scope.checkCookies = function(){ var accept = $cookies.get('cookie_policy'); if(accept != 'accept'){ $scope.barCookies = true; } } $scope.setCookies = function(){ var expireDate = new Date(); expireDate.setDate(expireDate.getDate() + 360); document.cookie = "cookie_policy=accept; expires=" + expireDate + "; path=/"; $scope.barCookies = false; } }]); controllers.controller('home', ['$scope', '$location', '$routeParams', function($scope, $location, $routeParams) { // $scope.$parent.dashboard = false; //$scope.service.app.mockup().then(function(data) { //console.log(data) //}); // $scope.service.app.feature().then(function(data) { // console.log(data) // }); // $scope.service.app.creative().then(function(data) { // console.log(data) // }); // var seller_id = '18b88005-35ed-441b-9e92-dd455220210f'; // $scope.service.app.seller(seller_id).then(function(data) { // console.log(data) // }); }]); controllers.controller('user', ['$scope','$window','$location', function($scope, $window, $location) { // if($scope.service.member.token()=='') { $location.path('/signin') } $scope.$parent.dashboard = false; if($location.path() =='/dashboard') { $scope.$parent.dashboard = true; } }]); controllers.controller('member',['$scope','$window','$location','$routeParams', function($scope, $window, $location, $routeParams) { // var query = $routeParams // console.log(query) //$scope.service.app.projects(query).then(function(data) { // console.log(data) //}); }]); controllers.controller('sso', ['$scope','$window','$location', function($scope, $window, $location) { // // if($scope.service.memebr.sso()=='') { // $location.path('/signin') // } }]); controllers.controller('seller', ['$scope','$window','$location', function($scope, $window, $location) { // if($scope.service.memebr.sso()=='') { $location.path('/signin') } }]);