<commit_before>'use strict';

angular.module('GSB.controllers.addSubject', ['ngSanitize', 'ui.select'])
.controller('AddSubjectCtrl', ['$scope', '$http', 'globalConfig', function($scope, $http, globalConfig) {
//	 List of available subject classes that can be added to the workspace.
  $scope.availableSubjectClasses = [];

  //  Subject selected to be added to the workspace.
  $scope.selectedSubjectClass = undefined;

  //  Get Availabe Subject Classes from Server
  $http.get(globalConfig.baseURL + 'mockup/classes.json').success(function(data) {
    var availClasses = data.results.bindings;
    for (var key in availClasses) {
      if(availClasses.hasOwnProperty(key)){
        $scope.availableSubjectClasses.push(
          {
            alias: availClasses[key].alias.value,
            uri: availClasses[key].class.value
          }
        );
      }
      // console.log(availClasses[key].alias.value);
    }
  }); 
		
		
		$scope.uiAddSubject = function() {
				console.log($scope.selectedSubjectClass);
    if($scope.selectedSubjectClass) { // If the selected option is undefined no subject will be added.
      $scope.$emit('newSubjectEvent', $scope.selectedSubjectClass);
						  $scope.selectedSubjectClass = undefined;
    }
  };
}]);

<commit_msg>Moved code to get classes from 'server' (json) to its own factory.<commit_after>'use strict';

angular.module('GSB.controllers.addSubject', ['ngSanitize', 'ui.select'])
  .factory('test', function($http, globalConfig) {
    var factory = {};
    factory.getClasses = function(asc) { // version 1
      //  Get Availabe Subject Classes from Server
      $http.get(globalConfig.baseURL + 'mockup/classes.json').success(function(data) {
        var availClasses = data.results.bindings;
        for (var key in availClasses) {
          if(availClasses.hasOwnProperty(key)){
            asc.push(
              {
                alias: availClasses[key].alias.value,
                uri: availClasses[key].class.value
              }
            );
          }
          // console.log(availClasses[key].alias.value);
        }
      }); 
    }
    // factory.getClasses = function() { // version 2
    //   var asc = [];
    //   //  Get Availabe Subject Classes from Server
    //   $http.get(globalConfig.baseURL + 'mockup/classes.json').success(function(data) {
    //     var availClasses = data.results.bindings;
    //     for (var key in availClasses) {
    //       if(availClasses.hasOwnProperty(key)){
    //         asc.push(
    //           {
    //             alias: availClasses[key].alias.value,
    //             uri: availClasses[key].class.value
    //           }
    //         );
    //       }
    //       // console.log(availClasses[key].alias.value);
    //     }
    //   }); 
    //   return asc;
    // }
    return factory;
  })
  .controller('AddSubjectCtrl', ['$scope', '$http', 'globalConfig', 'test', function($scope, $http, globalConfig, test) {
    //  List of available subject classes that can be added to the workspace.
    $scope.availableSubjectClasses = [];

    //  Subject selected to be added to the workspace.
    $scope.selectedSubjectClass = undefined;

    // //  Get Availabe Subject Classes from Server
    // $http.get(globalConfig.baseURL + 'mockup/classes.json').success(function(data) {
    //   var availClasses = data.results.bindings;
    //   for (var key in availClasses) {
    //     if(availClasses.hasOwnProperty(key)){
    //       $scope.availableSubjectClasses.push(
    //         {
    //           alias: availClasses[key].alias.value,
    //           uri: availClasses[key].class.value
    //         }
    //       );
    //     }
    //     // console.log(availClasses[key].alias.value);
    //   }
    // }); 
    
    
		test.getClasses($scope.availableSubjectClasses);       // version 1
		//$scope.availableSubjectClasses = test.getClasses();  // version 2

		$scope.uiAddSubject = function() {
			console.log($scope.selectedSubjectClass);
      if($scope.selectedSubjectClass) { // If the selected option is undefined no subject will be added.
        $scope.$emit('newSubjectEvent', $scope.selectedSubjectClass);
				$scope.selectedSubjectClass = undefined;
      }
    };
  }]);


{'fraction_non_alphanumeric': 0.14055844770468529, 'fraction_numerical': 0.000946521533364884, 'mean_word_length': 2.271671826625387, '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': '5427331', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1198, 'n_words': 239}