<commit_before>angular.module('focus.controllers')
  .controller('AddProgramController', function($scope, $ionicSlideBoxDelegate,
      SoundCategory, AudioLibrary, $stateParams, soundsByCategoryFilter,
      $timeout, TrainingProgram, $state, $ionicPopup, $ionicHistory, $location, $ionicScrollDelegate) {

    var getCategory = function(cat) {
      for(var i = 0; i < $scope.categories.length; i++) {
        if ($scope.categories[i].id == cat) {
          $timeout(function() {
            $ionicSlideBoxDelegate.$getByHandle('program').slide(1);
          }, 200);
          return $scope.categories[i];
        }
      }
      return null;
    };

    var allSounds = AudioLibrary.getAllSounds();
    $scope.categories = SoundCategory.getCategories();
    $scope.selectedSound = $stateParams.selectedSound;
    $scope.selectedCategory = getCategory($stateParams.selectedCategory) || $scope.categories[0];

    $scope.sounds = soundsByCategoryFilter(allSounds, $scope.selectedCategory);
    $scope.slideIndex = 0;
    $scope.showCategoryInfo = false;
    $scope.showProgramInfo = false;
    $scope.addFromLibrary = $stateParams.addFromLibrary || false;

    $scope.toggleActiveCategory = function(category) {
      if ($scope.showCategoryInfo === true) {
        $scope.toggleCategoryInfo();
      }
      $scope.selectedCategory = category;
      $scope.sounds = soundsByCategoryFilter(allSounds, $scope.selectedCategory);
      $location.hash(category.id);
      $ionicScrollDelegate.anchorScroll(true);
    };

    $scope.toggleActiveSound = function(sound) {
      if ($scope.showProgramInfo === true) {
        $scope.toggleProgramInfo();
      }
      if ($scope.selectedSound !== null && sound === $scope.selectedSound) {
        $scope.selectedSound = null;<commit_msg>Scroll to selected program when adding from library<commit_after>angular.module('focus.controllers')
  .controller('AddProgramController', function($scope, $ionicSlideBoxDelegate,
      SoundCategory, AudioLibrary, $stateParams, soundsByCategoryFilter,
      $timeout, TrainingProgram, $state, $ionicPopup, $ionicHistory, $location, $ionicScrollDelegate) {

    var getCategory = function(cat) {
      for(var i = 0; i < $scope.categories.length; i++) {
        if ($scope.categories[i].id == cat) {
          $timeout(function() {
            $ionicSlideBoxDelegate.$getByHandle('program').slide(1);
          }, 200);
          return $scope.categories[i];
        }
      }
      return null;
    };

    var allSounds = AudioLibrary.getAllSounds();
    $scope.categories = SoundCategory.getCategories();
    $scope.selectedSound = $stateParams.selectedSound;
    $scope.selectedCategory = getCategory($stateParams.selectedCategory) || $scope.categories[0];

    $scope.sounds = soundsByCategoryFilter(allSounds, $scope.selectedCategory);
    $scope.slideIndex = 0;
    $scope.showCategoryInfo = false;
    $scope.showProgramInfo = false;
    $scope.addFromLibrary = $stateParams.addFromLibrary || false;

    if ($stateParams.addFromLibrary) {
      $timeout(function() {
        $location.hash($stateParams.selectedSound.trackNumber);
        $ionicScrollDelegate.anchorScroll(true);
      },1000);
    }

    $scope.toggleActiveCategory = function(category) {
      if ($scope.showCategoryInfo === true) {
        $scope.toggleCategoryInfo();
      }
      $scope.selectedCategory = category;
      $scope.sounds = soundsByCategoryFilter(allSounds, $scope.selectedCategory);
      $location.hash(category.id);
      $ionicScrollDelegate.anchorScroll(true);
    };

    $scope.toggleActiveSound = function(sound) {
      if ($scope.showProgramInfo === true) {
        $scope.toggleProgramInfo();
      }
      if ($scope.selectedSound !== null && sound === $scope.selectedSound) {
        $scope.selectedSound = null;
{'fraction_non_alphanumeric': 0.13354363827549948, 'fraction_numerical': 0.00473186119873817, 'mean_word_length': 3.513641755634638, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5504194', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1044, 'n_words': 176}