{"size": 1790, "ext": "js", "max_stars_repo_path": "Lesson04/04_album_view/app/controllers/albumlistcontroller.js", "max_stars_repo_name": "ronnel169/AngularJSLiveLessons", "max_stars_repo_stars_event_min_datetime": "2015-01-08T03:40:56.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-12T00:26:09.000Z", "max_issues_repo_path": "Lesson04/04_album_view/app/controllers/albumlistcontroller.js", "max_issues_repo_name": "leojim/AngularJSLiveLessons", "max_issues_repo_issues_event_min_datetime": "2015-12-21T22:40:42.000Z", "max_issues_repo_issues_event_max_datetime": "2016-08-01T12:42:32.000Z", "max_forks_repo_path": "Lesson04/04_album_view/app/controllers/albumlistcontroller.js", "max_forks_repo_name": "leojim/AngularJSLiveLessons", "max_forks_repo_forks_event_min_datetime": "2015-01-15T07:55:19.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-20T10:35:59.000Z"}
{"max_stars_count": 57, "max_issues_count": 2, "max_forks_count": 60, "avg_line_length": 42.619047619, "max_line_length": 134, "alphanum_fraction": 0.5284916201}
(function() {

    function AlbumListController ($scope) {

        $scope.new_album = {};
        $scope.add_error_text = '';

        $scope.albums = [ 
            { name: 'madrid1309', title: 'Weekend in Madrid', date: '2013-09-01', description: 'My favourite trip' },
            { name: 'iceland1404', title: 'Holiday in Iceland', date: '2014-04-15', description: 'This place is cold' },
            { name: 'thailand1210', title: 'Surfing in Thailand', date: '2012-10-01', description: 'So hot!' },
            { name: 'australia1207', title: 'Wedding in Australia', date: '2012-07-31', description: 'So many kangaroos and koalas!' }
        ];

        $scope.addAlbum = function (album_data) {
            if (!album_data.title) 
                $scope.add_error_text = "Missing title";
            else if (!album_data.date)
                $scope.add_error_text = "You must specify a date (yyyy/mm/dd)";
            else if (!album_data.description)
                $scope.add_error_text = "Missing description";
            else if (!album_data.name)
                $scope.add_error_text = "Short album name must be at least 6 chars (ironic, yes)";
            else {
                try {
                    var d = new Date(album_data.date.trim());
                    if (isNaN(d.getTime())) throw new Error("invalid date");
                    // if we made it here the date is good
                    $scope.albums.push(album_data);
                    $scope.new_album = {};
                    $scope.add_error_text = '';
                } catch (e) {
                    $scope.add_error_text = "You must specify a valid date (yyyy/mm/dd)";
                }
            }
        };
    }

    photoApp.controller("AlbumListController", AlbumListController);

})();
