'use strict';

angular.module('portfolioApp', [
  'ngRoute',
  'portfolioControllers',
  'portfolioDirectives',
  'portfolioFilters',
  'portfolioServices'
]);

angular.module('portfolioApp').config(['$routeProvider', function ($routeProvider) {
  $routeProvider.
    when('/start', {
      templateUrl: 'partials/start.html',
      controller: 'StartCtrl'
    }).
    otherwise({
      redirectTo: '/start'
    });
}]);

angular.module('portfolioApp').run(['$rootScope', '$location', '$window', '$log', 'ConfigService', function ($rootScope, $location, $window, $log, ConfigService) {
  ConfigService.get().then(function successCallback(config) {
    var id = config['google-analytics-tracking-id'];
    //$log.debug('tracking id = ' + id);
    if ($window.ga) {
      $window.ga('create', id);
    }
  });
  $rootScope.$on('$locationChangeSuccess', function (event) {
    //$log.debug('$locationChangeSuccess: ' + $location.path());
    if ($window.ga) {
      //$log.debug('send pageview to google: ' + $location.path());
      $window.ga('send', 'pageview', {page: $location.path()});
    }
  });
}]);

@@ -694,26 +694,48 @@
 g-id'%5D;%0A    
-//
+if ($window.ga) %7B%0A      
 $log.debug('
@@ -757,38 +757,16 @@
  + id);%0A
-    if ($window.ga) %7B%0A
       $w
@@ -797,20 +797,16 @@
     %7D%0A  
-%7D);%0A
   $rootS
@@ -855,24 +855,26 @@
 n (event) %7B%0A
+  
     //$log.d
@@ -926,24 +926,26 @@
 ath());%0A    
+  
 if ($window.
@@ -948,34 +948,34 @@
 dow.ga) %7B%0A      
-//
+  
 $log.debug('send
@@ -1016,32 +1016,34 @@
 .path());%0A      
+  
 $window.ga('send
@@ -1088,17 +1088,27 @@
 %7D);%0A    
+ 
-%7D
+ %7D%0A    %7D);
 %0A  %7D);%0A%7D

send pageview after create