<commit_before>angular.module('foosey')
	.controller('HistoryController', function($scope, FooseyService)
	{
        // create a pull-to-refresh function
        $scope.refresh = refresh;

        // initialize the page
        $scope.refresh();
        $scope.loading = true;

        function refresh()
        {
		    // get history of games and group by the date
            FooseyService.history()
            .then(function successCallback(result) 
            { 
                $scope.dates = _.chain(result.data.games)
                    .groupBy('date')
                    .pairs()
                    .map(function (currentItem)
                    {
                      return _.object(_.zip(['date', 'games'], currentItem));
                    })
                    .value();
                done();
            }, function errorCallback(response)
            {
                $scope.error = true;
                done();
            });
        }

        // turns off spinner and notifies
        function done()
        {
          $scope.loading = false;
          $scope.$broadcast('scroll.refreshComplete');
        }

        // Remove game
        $scope.removeLast = function()
        {
            $scope.loading = true;
            FooseyService.undo().then(function() 
            {
                refresh();
            });
        }
	});<commit_msg>You now need to confirm that you want to delete the last game<commit_after>angular.module('foosey')
	.controller('HistoryController', function($scope, $ionicPopup, FooseyService)
	{
        // create a pull-to-refresh function
        $scope.refresh = refresh;

        // initialize the page
        $scope.refresh();
        $scope.loading = true;

        function refresh()
        {
		    // get history of games and group by the date
            FooseyService.history()
            .then(function successCallback(result) 
            { 
                $scope.dates = _.chain(result.data.games)
                    .groupBy('date')
                    .pairs()
                    .map(function (currentItem)
                    {
                      return _.object(_.zip(['date', 'games'], currentItem));
                    })
                    .value();
                done();
            }, function errorCallback(response)
            {
                $scope.error = true;
                done();
            });
        }

        // turns off spinner and notifies
        function done()
        {
          $scope.loading = false;
          $scope.$broadcast('scroll.refreshComplete');
        }

        // Remove game
        $scope.removeLast = function()
        {
            // confirm that they actually want to remove
            var confirmPopup = $ionicPopup.confirm({
              title: 'Remove Last Game',
              template: 'Are you sure you want to remove the last game? This cannot be undone.'
            });

            // if yes, delete the last game
            confirmPopup.then(function(positive) {
              if(positive) {
                $scope.loading = true;
                FooseyService.undo().then(function() 
                {
                    refresh();
                });
              }
            });
        }
	});
{'fraction_non_alphanumeric': 0.10883521858758789, 'fraction_numerical': 0.0, 'mean_word_length': 1.2033670033670034, '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': '2122877', 'n_tokens_mistral': 809, 'n_tokens_neox': 757, 'n_words': 181}