<commit_before>(function () {
  'use strict';

  var namespace = angular.module('app.directory-selector', [
    'hierarchical-selector',
    'app.acceptd.config'
  ]);

  namespace.directive('directorySelector', DirectorySelector);

  function DirectorySelector($q, $http, $timeout, AcceptdService) {
    return {
      restrict: 'AE',
      template: '<hierarchical-selector load-child-items="loadAsyncData(parent)"' +
      '                       selection="selection" on-selection-changed="onSelectionChanged(items)"' +
      '                       tag-name="tagName(item)">' +
      '</hierarchical-selector>',
      scope: {
        'script_params': '&',
        'selection': '&',
        'selected_project': '&'
      },
      link: function (scope, element, attributes) {
        //console.log(attributes.selectedProject);

        AcceptdService.load_config({}).success(function (result) {
          var id = result.selected_project;
          //var id = attributes.selectedProject;

          $http.get('/file_browser/node' + '?id=' + id).success(function (data) {
            //  //data['_hsmeta'] = {'isExpanded':false,'isActive':false,'selected':true};
            scope.selection = data;
          });
        });

        scope.loadAsyncData = function (parent) {
          var id = parent ? parent.id : '/';

          var defer = $q.defer();

          $http.get('/file_browser/tree' + '?id=' + id).success(function (data) {
            defer.resolve(data);
          }).error(function (data) {
            defer.reject(data);
          });

          return defer.promise;
        };

        scope.onSelectionChanged = function (items) {
          scope.mySelection = items;
        };

        scope.tagName = function (item) {
          return item.id;
        };
      }
    }<commit_msg>simplify code<commit_after>(function () {
  'use strict';

  var namespace = angular.module('app.directory-selector', [
    'hierarchical-selector',
    'app.settings',
    'app.acceptd.config'
  ]);

  namespace.directive('directorySelector', DirectorySelector);

  function DirectorySelector($q, $http, $timeout, Settings, AcceptdService) {
    return {
      restrict: 'AE',
      template: '<hierarchical-selector load-child-items="loadAsyncData(parent)"' +
      '                       selection="selection" on-selection-changed="onSelectionChanged(items)"' +
      '                       tag-name="tagName(item)">' +
      '</hierarchical-selector>',
      scope: {
        'script_params': '&',
        'selection': '&'
      },
      link: function (scope, element, attributes) {
        AcceptdService.load_config({}).success(function (result) {
          var id = result.selected_project;
          //var id = attributes.selectedProject;

          $http.get(Settings.baseUrl + '/file_browser/node' + '?id=' + id).success(function (data) {
            //  //data['_hsmeta'] = {'isExpanded':false,'isActive':false,'selected':true};
            scope.selection = data;
          });
        });

        scope.loadAsyncData = function (parent) {
          var id = parent ? parent.id : '/';

          var defer = $q.defer();

          $http.get('/file_browser/tree' + '?id=' + id).success(function (data) {
            defer.resolve(data);
          }).error(function (data) {
            defer.reject(data);
          });

          return defer.promise;
        };

        scope.onSelectionChanged = function (items) {
          scope.mySelection = items;
        };

        scope.tagName = function (item) {
          return item.id;
        };
      }
    }
{'fraction_non_alphanumeric': 0.15476854433909648, 'fraction_numerical': 0.0, 'mean_word_length': 2.1191304347826088, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2650640', 'n_tokens_mistral': 1036, 'n_tokens_neox': 1000, 'n_words': 164}