<commit_before>app.controller("slidesCtrl", function ($scope, $location,  loginService, $state) {
    // Queries
    console.log("in itemViewerCtrl");
    console.log("in itemViewerCtrl selected item is " + $scope.item);
    console.log("in itemViewerCtrl selected item is " + $scope.item.id);
    //$scope.editMode = false;
    $scope.myUrl = '#' + $location.url();

    $scope.entityClicked = function (entityIndex, itemSelected) {
        if ($scope.editMode)
            return;
        setTimeout(function () {
            $scope.page.selectedSlide++;
            $scope.$apply()
        }, 1000);

        var selectedSlide = $scope.page.slides[$scope.page.selectedSlide];
        var selectedEntity = selectedSlide.entities[entityIndex];

        if (selectedEntity.points == 0) {
            selectedEntity.isFailed = true;
            selectedSlide.isFailed = true;
        }
        else {
            selectedSlide.isSuccess = true;
        }

        selectedSlide.entities.forEach(
            function handleEntity(entity) {
                if (entity.points > 0) {
                    entity.isSuccess = true;
                }
                entity.isPressed = true;
            }
        );
    }

    $scope.jumpToSlide = function (slideIndex) {
        $scope.page.selectedSlide = slideIndex;
    }



    $scope.openImageSelector = function (item, strCrop) {
        uploadcare.openDialog(null, {
            publicKey: "4b4265edeea7c06bf980",
            imagesOnly: true,
            crop: strCrop
        }).done(function (file) {
            if (file) {
                file.done(function (info) {
                    item.imgSmall = info.cdnUrl;
                });
                $scope.$apply();
            }
        });
    }

    $scope.createDefaultEntity = function()
    {
        var emptySlide = {text : "", imgSmall : "", entities : []}

    }

    $scope.createDefaultSlide = function()
    {
        var emptySlide = {text : "", imgSmall : "", entities : []}
        emptySlide.entities.push($scope.createDefaultEntity());
        emptySlide.entities.push($scope.createDefaultEntity());

        return emptySlide;
    }

    $scope.createDefaultEntity = function()
    {
        return {imgSmall : "", title : "", points : 0};
    }

    $scope.removeSlide = function()
    {
        if ($scope.page.slides.length <= 1)
            return;

        $scope.page.slides.splice($scope.page.selectedSlide,1);
        if ($scope.page.selectedSlide >= $scope.page.slides.length)
            $scope.page.selectedSlide = $scope.page.slides.length-1;
    }

    $scope.addSlide = function() {
        if ($scope.page.slides.length >= 10)
            return;

        $scope.page.slides.splice($scope.selectedSlide+1, 0, $scope.createDefaultSlide());
        $scope.page.selectedSlide+=1;
    }

});
<commit_msg>Fix add slide from current index<commit_after>app.controller("slidesCtrl", function ($scope, $location,  loginService, $state) {
    // Queries
    console.log("in itemViewerCtrl");
    console.log("in itemViewerCtrl selected item is " + $scope.item);
    console.log("in itemViewerCtrl selected item is " + $scope.item.id);
    //$scope.editMode = false;
    $scope.myUrl = '#' + $location.url();

    $scope.entityClicked = function (entityIndex, itemSelected) {
        if ($scope.editMode)
            return;
        setTimeout(function () {
            $scope.page.selectedSlide++;
            $scope.$apply()
        }, 1000);

        var selectedSlide = $scope.page.slides[$scope.page.selectedSlide];
        var selectedEntity = selectedSlide.entities[entityIndex];

        if (selectedEntity.points == 0) {
            selectedEntity.isFailed = true;
            selectedSlide.isFailed = true;
        }
        else {
            selectedSlide.isSuccess = true;
        }

        selectedSlide.entities.forEach(
            function handleEntity(entity) {
                if (entity.points > 0) {
                    entity.isSuccess = true;
                }
                entity.isPressed = true;
            }
        );
    }

    $scope.jumpToSlide = function (slideIndex) {
        $scope.page.selectedSlide = slideIndex;
    }



    $scope.openImageSelector = function (item, strCrop) {
        uploadcare.openDialog(null, {
            publicKey: "4b4265edeea7c06bf980",
            imagesOnly: true,
            crop: strCrop
        }).done(function (file) {
            if (file) {
                file.done(function (info) {
                    item.imgSmall = info.cdnUrl;
                });
                $scope.$apply();
            }
        });
    }

    $scope.createDefaultEntity = function()
    {
        var emptySlide = {text : "", imgSmall : "", entities : []}

    }

    $scope.createDefaultSlide = function()
    {
        var emptySlide = {text : "", imgSmall : "", entities : []}
        emptySlide.entities.push($scope.createDefaultEntity());
        emptySlide.entities.push($scope.createDefaultEntity());

        return emptySlide;
    }

    $scope.createDefaultEntity = function()
    {
        return {imgSmall : "", title : "", points : 0};
    }

    $scope.removeSlide = function()
    {
        if ($scope.page.slides.length <= 1)
            return;

        $scope.page.slides.splice($scope.page.selectedSlide,1);
        if ($scope.page.selectedSlide >= $scope.page.slides.length)
            $scope.page.selectedSlide = $scope.page.slides.length-1;
    }

    $scope.addSlide = function() {
        if ($scope.page.slides.length >= 10)
            return;

        $scope.page.slides.splice($scope.page.selectedSlide+1, 0, $scope.createDefaultSlide());
        $scope.page.selectedSlide+=1;
    }

});

{'fraction_non_alphanumeric': 0.13327495621716287, 'fraction_numerical': 0.009106830122591943, 'mean_word_length': 1.9272168118913378, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4427726', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1653, 'n_words': 273}