UNPKG

unserver-unify

Version:

49 lines (47 loc) 1.94 kB
'use strict'; angular.module('bamboo').controller('IndexCtrl', function($scope, $stateParams, $state,loginService, $window, ApiService, $localStorage, deviceDetector, $rootScope) { $scope.loginService = loginService; var starttime = new Date(); //starting time $scope.colorStyle = loginService.school.themecolors && loginService.school.themecolors.selectitemhighlightcolor; $scope.themeColor = (loginService.school.themecolors)?loginService.school.themecolors.theme3headercolor:''; console.log($scope.colorStyle); console.log($scope.colorStyle == 'highlight_blue'); if (deviceDetector.isMobile() && !deviceDetector.isTablet()) { $rootScope.mobileView = true; /* angular.element('body').toggleClass('splash_bg'); $scope.$on('$destroy', function(){ angular.element('body').toggleClass('splash_bg'); });*/ } else { $rootScope.mobileView = false; } console.log($state.current.name); //$scope.course_argbg_highlight_flag = ($state.current.name === "index.courses.course.section.video"); if(!$localStorage.open){ $localStorage.open=1; }else{ $localStorage.open++; } console.log($localStorage.open); console.log($localStorage.total); if (loginService.user && $localStorage.total > 60) { ApiService.submitActivityRecord(); console.log('submit result'); } /*window.addEventListener("beforeunload", function (e) { $localStorage.open--; console.log('event before load'); });*/ $window.onbeforeunload = function(e) { // return "Do you really want to close?" $localStorage.open--; // alert("window close!"); console.log("close window, need to notice server !",$localStorage.open); ApiService.submitActivityRecord(null,true); // e.returnValue="Close Event"; return; } // console.log($stateParams); $scope.shareFlag = $stateParams.share; // console.log($state.current.name); });