<commit_before>angular.module('photoApp', ['angularMoment'])
    .config(function($interpolateProvider){
        $interpolateProvider.startSymbol('[[');
        $interpolateProvider.endSymbol(']]');
    })
    .controller(
        'PhotosCtrl', function($scope, $http){
/*
|-------------------------------------------------------------
| Set photos in controller scope
|-------------------------------------------------------------
*/
            $http.get('/photos').success(
                function(responseData) {
                    $scope.photos = JSON.parse(responseData);
                }
            );
    })
    .directive(
/*
|-------------------------------------------------------------
| Set directive for each photo, handle when photo is clicked
|-------------------------------------------------------------
*/
        'selectImg', ['$document', function($document) {
            return {
                link: function (scope, element, attr) {
                    element.on('click', function(event){
                        event.preventDefault();
                        $('.selected').toggleClass('selected');
                        element.toggleClass('selected');
                    });
                }
            }
    }]);<commit_msg>(feature) add edit directive; delete directive; select directive<commit_after>angular.module('photoApp', ['angularMoment', 'ngFileUpload', 'ngAnimate'])
    .config(function($interpolateProvider){
        $interpolateProvider.startSymbol('[[');
        $interpolateProvider.endSymbol(']]');
    })
    .controller(
        'PhotosCtrl', function($scope, $http){
/*
|-------------------------------------------------------------
| Set photos in controller scope
|-------------------------------------------------------------
*/
        $http.get('/photos').success(
            function(responseData) {
                $scope.photos = responseData.photos;
            }
        );
        $scope.DestroyAlert = function() {
            $('.alert').addClass('hide');
        }
        $scope.UpdatePhotoTitle = function() {
            var photoId = this.photo.id;
            $http.post('/photo/'+photoId+'/update', {})
            .then(function(response){
                console.log(response.data);
            });
        }
    }).controller(
        'PhotoCtrl', ['$scope', '$http', 'Upload', function($scope, $http, Upload){
            $scope.upload = function ($files) {
                /*$('input[name=image').click();*/
                // console.log($scope.files);
                $scope.doUpload($files[0]);
            };
            $scope.doUpload = function($file) {
                Upload.upload({
                url: '/upload/',
                data: {image: $file}
                }).then(function (response) {
                    $scope.$parent.messages = [response.data.messages];
                    $scope.$parent.photos.unshift(response.data.photo);
                    $scope.$parent.DestroyAlert();
                }, function (response) {
                    console.log('Error status: ' + response.status);
                }, function (event) {
                    var progressPercentage = parseInt(100.0 * event.loaded / event.total);
                    console.log('progress: ' + progressPercentage + '% ');
                });
            };
        }
    ])
    .directive(
/*
|-------------------------------------------------------------
| Set directive to select each photo, handle when photo is clicked
|-------------------------------------------------------------
*/
        'selectPhoto', ['$document', function($document) {
            return {
                templateUrl: 'static/Partials/selection.html',
                link: function (scope, element, attr) {
                    element.on('click', function(event){
                        event.preventDefault();
                        $('.selected').toggleClass('selected');
                        $(this).toggleClass('selected');
                        $('#photo').attr({'src':$(this).attr('data-filesrc')});
                    });
                }
            }
    }])
    .directive(
/*
|-------------------------------------------------------------
| Set directive to delete a selected photo
|-------------------------------------------------------------
*/
        'deletePhoto', ['$document', '$http', function($document, $http) {
            return function (scope, element, attr) {
                    element.on('click', function(event){
                        event.preventDefault();
                        var selectedPhoto = $('.selected');
                        var photoId = selectedPhoto.attr('data-id');
                        if(photoId == undefined){
                            scope.messages = [{'tags':'info', 'text':'Select a photo to delete'}];
                            scope.$apply();
                        }
                        else {
                            selectedPhoto.remove();
                            $http.get('/photo/'+photoId+'/delete').success(
                                function(responseData){
                                    scope.messages = responseData;
                                    scope.DestroyAlert();
                                }
                            );
                        }
                    });
                }
        }])
    .directive(
/*
|-------------------------------------------------------------
| Set directive to edit a selected photo
|-------------------------------------------------------------
*/
        'editPhoto', ['$document', '$http', function ($document, $http) {
            return function (scope, element, attr) {
                element.on('click', function(event){
                    event.preventDefault();
                    var selectedPhoto = $('.selected');
                    var photoId = selectedPhoto.attr('data-id');
                    if(photoId == undefined){
                        scope.messages = [{'tags':'info', 'text':'Select a photo to edit'}];
                        scope.$apply();
                    }
                    else {
                    }
                });
            }
        }])
    .directive(
        'editPhotoTitle', ['$document', '$http', '$compile', function ($document, $compile, $http) {
            return function (scope, element, attr) {
                element.on('click', function (event, $http){
                    $(this).next().toggleClass('hidden');
                    $(this).toggleClass('hidden');
                });
            }
        }]);
{'fraction_non_alphanumeric': 0.2411915923181612, 'fraction_numerical': 0.0007560864962951762, 'mean_word_length': 1.0533995653523751, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '217929', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1367, 'n_words': 255}