<commit_before>angular.module('soundboardApp').controller('SoundboardController', ['$scope', '$firebaseArray', '$routeParams', '$firebaseObject', '$location', 'ngAudio', function($scope, $firebaseArray, $routeParams, $firebaseObject, $location, ngAudio) {
  $scope.soundboard = {};
  $scope.entries = {};
  $scope.currentlyPlaying = {file: ''};
  $scope.player = null;

  // Get the firebase Collection for filtering by slug
  var ref = new Firebase('https://bahuma-soundboard.firebaseio.com/soundboards');
  var soundboards = $firebaseArray(ref);
  soundboards.$ref().orderByChild('slug').equalTo($routeParams.soundboard_slug).once('value', function(dataSnapshot) {
    if(dataSnapshot.exists()) {
      // Loop over the result to get the board key
      angular.forEach(dataSnapshot.val(), function (object, key) {
        var boardKey = key;

        // Create a firebase ref for the specific board
        var boardRef = new Firebase('https://bahuma-soundboard.firebaseio.com/soundboards/' + boardKey);
        $scope.soundboard = $firebaseObject(boardRef);
        onCollectionLoaded();

        $scope.entries = $firebaseArray(boardRef.child('entries'));
      });
    } else {
      $location.path('/');
    }
  });

  var onCollectionLoaded = function () {
    // Executed after the collection $scope.entries has been created
  };

  $scope.togglePlaySound = function (entry) {
    if ($scope.player) {
      $scope.player.pause();
    }

    if ($scope.entryCurrentlyPlaying(entry)) {
      $scope.currentlyPlaying = '';
    } else {
      $scope.currentlyPlaying = entry;

      // Play The audio
      $scope.player = new Audio('./sounds/' + entry.file);
      $scope.player.play();

      // Set buttons inactive when audio finished
      $scope.player.addEventListener('ended', function() {

        $scope.currentlyPlaying = {};
        $scope.$apply();

        // Update playCount
        //entry.playCount++;
        console.log($scope.entries.$indexFor(entry.$id));
        $scope.entries[$scope.entries.$indexFor(entry.$id)].playCount++;
        $scope.entries.$save($scope.entries.$indexFor(entry.$id));
      });
    }
  };

  $scope.entryCurrentlyPlaying = function(entry) {
    if (entry.$id == $scope.currentlyPlaying.$id) {
      return true;
    } else {
      return false;
    }
  };
}]);
<commit_msg>Removed unused onCollectionLoaded<commit_after>angular.module('soundboardApp').controller('SoundboardController', ['$scope', '$firebaseArray', '$routeParams', '$firebaseObject', '$location', 'ngAudio', function($scope, $firebaseArray, $routeParams, $firebaseObject, $location, ngAudio) {
  $scope.soundboard = {};
  $scope.entries = {};
  $scope.currentlyPlaying = {file: ''};
  $scope.player = null;

  // Get the firebase Collection for filtering by slug
  var ref = new Firebase('https://bahuma-soundboard.firebaseio.com/soundboards');
  var soundboards = $firebaseArray(ref);
  soundboards.$ref().orderByChild('slug').equalTo($routeParams.soundboard_slug).once('value', function(dataSnapshot) {
    if(dataSnapshot.exists()) {
      // Loop over the result to get the board key
      angular.forEach(dataSnapshot.val(), function (object, key) {
        var boardKey = key;

        // Create a firebase ref for the specific board
        var boardRef = new Firebase('https://bahuma-soundboard.firebaseio.com/soundboards/' + boardKey);
        $scope.soundboard = $firebaseObject(boardRef);
        $scope.entries = $firebaseArray(boardRef.child('entries'));
      });
    } else {
      $location.path('/');
    }
  });

  $scope.togglePlaySound = function (entry) {
    if ($scope.player) {
      $scope.player.pause();
    }

    if ($scope.entryCurrentlyPlaying(entry)) {
      $scope.currentlyPlaying = '';
    } else {
      $scope.currentlyPlaying = entry;

      // Play The audio
      $scope.player = new Audio('./sounds/' + entry.file);
      $scope.player.play();

      // Set buttons inactive when audio finished
      $scope.player.addEventListener('ended', function() {

        $scope.currentlyPlaying = {};
        $scope.$apply();

        // Update playCount
        //entry.playCount++;
        console.log($scope.entries.$indexFor(entry.$id));
        $scope.entries[$scope.entries.$indexFor(entry.$id)].playCount++;
        $scope.entries.$save($scope.entries.$indexFor(entry.$id));
      });
    }
  };

  $scope.entryCurrentlyPlaying = function(entry) {
    if (entry.$id == $scope.currentlyPlaying.$id) {
      return true;
    } else {
      return false;
    }
  };
}]);

{'fraction_non_alphanumeric': 0.1604502317369234, 'fraction_numerical': 0.0, 'mean_word_length': 3.176958525345622, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '5819585', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1297, 'n_words': 250}