<commit_before>"use strict";

angular.module('arethusa.core').controller('MainCtrl', function($scope, $injector, configurator, state, documentStore) {
  documentStore.reset();

  $scope.aU = arethusaUtil;

  $scope.debug = false;
  $scope.toggleDebugMode = function() {
    $scope.debug = !$scope.debug;
  };

  var conf = configurator.configurationFor('main');

  var partitionPlugins = function(plugins) {
    $scope.mainPlugins = [];
    $scope.subPlugins = [];
    $scope.pluginsWithMenu = [];

    angular.forEach(plugins, function(plugin, name) {
      $scope.registerPlugin(plugin);
    });
  };

  $scope.retrievePlugins = function(plugins) {
    var obj = {};
    angular.forEach(plugins, function(name, i) {
      obj[name] = $scope.retrievePlugin(name);
    });
    return obj;
  };

  $scope.registerPlugin = function(plugin) {
    $scope.pushPlugin(plugin);
    $scope.registerListener(plugin);
  };

  $scope.retrievePlugin = function(name) {
    var pluginConf = configurator.configurationFor(name);
    if (pluginConf.external) {
      // We copy because this object will be extended once the plugin
      // is really initialized through the inclusion of its template
      // by the plugin directive.
      return angular.copy(pluginConf);
    } else {
      return  $injector.get(name);
    }
  };

  $scope.pushPlugin = function(plugin) {
    if (plugin.main) {
      $scope.mainPlugins.push(plugin);
    } else {
      $scope.subPlugins.push(plugin);
    }

    if (plugin.contextMenu) {
      $scope.pluginsWithMenu.push(plugin);
    }
  };

  // Working on the assumptions that plugins will generally be grouped
  // in something like a tabset - impossible to show them all at the same
  // time, we expose some variables and functions to get info about their
  // visibility.
  // Templates can use this to implement ngIf, which removes elements
  // temporarily from the DOM.<commit_msg>Add ability to hide plugin views<commit_after>"use strict";

angular.module('arethusa.core').controller('MainCtrl', function($scope, $injector, configurator, state, documentStore) {
  documentStore.reset();

  $scope.aU = arethusaUtil;

  $scope.debug = false;
  $scope.toggleDebugMode = function() {
    $scope.debug = !$scope.debug;
  };

  var conf = configurator.configurationFor('main');

  var partitionPlugins = function(plugins) {
    $scope.mainPlugins = [];
    $scope.subPlugins = [];
    $scope.pluginsWithMenu = [];

    angular.forEach(plugins, function(plugin, name) {
      $scope.registerPlugin(plugin);
    });
  };

  $scope.retrievePlugins = function(plugins) {
    var obj = {};
    angular.forEach(plugins, function(name, i) {
      obj[name] = $scope.retrievePlugin(name);
    });
    return obj;
  };

  $scope.registerPlugin = function(plugin) {
    $scope.pushPlugin(plugin);
    $scope.registerListener(plugin);
  };

  $scope.retrievePlugin = function(name) {
    var pluginConf = configurator.configurationFor(name);
    if (pluginConf.external) {
      // We copy because this object will be extended once the plugin
      // is really initialized through the inclusion of its template
      // by the plugin directive.
      return angular.copy(pluginConf);
    } else {
      return  $injector.get(name);
    }
  };

  function hasView(plugin) {
    return ! ((! plugin.template) || plugin.noView);
  }

  $scope.pushPlugin = function(plugin) {
    if (hasView(plugin)) {
      if (plugin.main) {
        $scope.mainPlugins.push(plugin);
      } else {
        $scope.subPlugins.push(plugin);
      }
    }

    if (plugin.contextMenu) {
      $scope.pluginsWithMenu.push(plugin);
    }
  };

  // Working on the assumptions that plugins will generally be grouped
  // in something like a tabset - impossible to show them all at the same
  // time, we expose some variables and functions to get info about their
  // visibility.
  // Templates can use this to implement ngIf, which removes elements
  // temporarily from the DOM.
{'fraction_non_alphanumeric': 0.1255977850490813, 'fraction_numerical': 0.0, 'mean_word_length': 3.1438998957247133, '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': '6335260', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1155, 'n_words': 293}