<commit_before>'use strict';

var loMod = angular.module('loApp.controllers.global', []);

loMod.controller('GlobalCtrl', function($log, $rootScope, $scope, $location, $route, $modal, LiveOak) {

  $log.debug('GlobalCtrl' + LiveOak);

  $rootScope.$on('$routeChangeError',
    /* Following function can get use of 'event, current, previous, rejection' arguments to specify the error */
    function () {
      $log.error('failed to change routes');
      $location.path('/error');
    });

  // to avoid initial flashing of sidebar on non-sidebar pages
  $rootScope.hideSidebar = true;

  // originalPath is used to calculate the sidebar active element
  $rootScope.$on('$locationChangeSuccess', function() {
    $rootScope.oPath = $route.current.$$route.originalPath;
  });

  // so that it shows back when switching from non-sidebar to sidebar pages
  $rootScope.$on('$routeChangeSuccess', function() {
    delete $rootScope.hideSidebar;
  });

  // show prevent lose change
  $rootScope.preventLoseChanges = function(theScope/*, saveFun, discardFun*/) {
    //$scope.saveFun = saveFun;
    //$scope.discardFun = discardFun;
    theScope.$on('$locationChangeStart', function(event, next) {
      theScope.next = next.substr(next.indexOf('#')+1, next.length);
      if (theScope.changed) {
        event.preventDefault();
        $modal.open({
          templateUrl: '/admin/console/templates/modal/unsaved-changes.html',
          controller: UnsavedChangesCtrl,
          scope: theScope
        });
      }
    });
  };

  var UnsavedChangesCtrl = function ($scope, $modalInstance, $log) {
    $scope.cancel = function () {
      $modalInstance.dismiss('cancel');
    };

    $scope.discard = function() {
      $modalInstance.close();
      $scope.$parent.changed = false;
      $location.path($scope.$parent.next);
    };

    // Not being used yet. Requires changes:
    // - Need promise on save method for knowing when completed;
    // - Need to handle save method redirect;
    // - Possibly more...
    /*
    $scope.save = function() {
      $modalInstance.close();
      $scope.$parent.saveFun();
      isStillChanged(0, 10);
    };

    var isStillChanged = function(count, max) {<commit_msg>Fix a jshint error on an unused $log variable<commit_after>'use strict';

var loMod = angular.module('loApp.controllers.global', []);

loMod.controller('GlobalCtrl', function($log, $rootScope, $scope, $location, $route, $modal, LiveOak) {

  $log.debug('GlobalCtrl' + LiveOak);

  $rootScope.$on('$routeChangeError',
    /* Following function can get use of 'event, current, previous, rejection' arguments to specify the error */
    function () {
      $log.error('failed to change routes');
      $location.path('/error');
    });

  // to avoid initial flashing of sidebar on non-sidebar pages
  $rootScope.hideSidebar = true;

  // originalPath is used to calculate the sidebar active element
  $rootScope.$on('$locationChangeSuccess', function() {
    $rootScope.oPath = $route.current.$$route.originalPath;
  });

  // so that it shows back when switching from non-sidebar to sidebar pages
  $rootScope.$on('$routeChangeSuccess', function() {
    delete $rootScope.hideSidebar;
  });

  // show prevent lose change
  $rootScope.preventLoseChanges = function(theScope/*, saveFun, discardFun*/) {
    //$scope.saveFun = saveFun;
    //$scope.discardFun = discardFun;
    theScope.$on('$locationChangeStart', function(event, next) {
      theScope.next = next.substr(next.indexOf('#')+1, next.length);
      if (theScope.changed) {
        event.preventDefault();
        $modal.open({
          templateUrl: '/admin/console/templates/modal/unsaved-changes.html',
          controller: UnsavedChangesCtrl,
          scope: theScope
        });
      }
    });
  };

  var UnsavedChangesCtrl = function ($scope, $modalInstance) {
    $scope.cancel = function () {
      $modalInstance.dismiss('cancel');
    };

    $scope.discard = function() {
      $modalInstance.close();
      $scope.$parent.changed = false;
      $location.path($scope.$parent.next);
    };

    // Not being used yet. Requires changes:
    // - Need promise on save method for knowing when completed;
    // - Need to handle save method redirect;
    // - Possibly more...
    /*
    $scope.save = function() {
      $modalInstance.close();
      $scope.$parent.saveFun();
      isStillChanged(0, 10);
    };

    var isStillChanged = function(count, max) {
{'fraction_non_alphanumeric': 0.14617117117117118, 'fraction_numerical': 0.0018018018018018018, 'mean_word_length': 3.1044362292051755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4935994', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1276, 'n_words': 313}