<commit_before>/*
    Creator: <NAME> For ARCA-Computing - www.arca-computing.fr
    Date: July 2014
    Version: 1.0.0

    Description:    MultipleDatePicker is an Angular directive to show a simple calendar allowing user to select multiple dates.
                    A callback is called everytime a de/selection is done.
                    Css style can be changed by editing less or css stylesheet.
                    See scope declaration below for options you can pass through html directive.
                    Feel free to edit and share this piece of code, our idea is to keep simple ;)
 */
angular.module('multipleDatePicker', [])
    .directive('multipleDatePicker', [function(){
    "use strict";
    return {
        restrict: 'AE',
        scope: {
            /*
            * Type: function(timestamp, boolean)
            * Will be called when un/select a date
            * Param timestamp will be the date at midnight
            * */
            callback: '&',
            /*
            * Type: array of milliseconds timestamps
            * Days already selected
            * */
            daysSelected: '=',
            /*
            * Type: array of integers
            * Recurrent week days not selectables
            * /!\ Sunday = 0, Monday = 1 ... Saturday = 6
            * */
            weekDaysOff: '=',
            /*
            * Type: array of milliseconds timestamps
            * Days not selectables
            * */
            daysOff: '='
        },
        template: '<div class="multiple-date-picker">'+
                        '<div class="picker-top-row">'+
                            '<div class="text-center picker-navigate" ng-click="previousMonth()">&lt;</div>'+
                            '<div class="text-center picker-month">{{month.format(\'MMMM YYYY\')}}</div>'+
                            '<div class="text-center picker-navigate" ng-click="nextMonth()">&gt;</div>'+
                        '</div>'+
                        '<div class="picker-days-week-row">'+
                            '<div class="text-center" ng-repeat="day in daysOfWeek">{{day}}</div>'+
                        '</div>'+
                        '<div class="picker-days-row">'+
                            '<div class="text-center picker-day picker-empty" ng-repeat="x in emptyFirstDays">&nbsp;</div>'+
                            '<div class="text-center picker-day" ng-repeat="day in days" ng-click="toggleDay(day)" ng-mouseover="day.hover=true" ng-mouseleave="day.hover=false" ng-class="{\'picker-selected\':day.selected, \'picker-off\':!day.selectable, \'hover\':day.hover && day.selectable, \'today\':day.today}">{{day ? day.format(\'D\') : \'\'}}</div>'+
                            '<div class="text-center picker-day picker-empty" ng-repeat="x in emptyLastDays">&nbsp;</div>'+
                        '</div>'+
                    '</div>',
        link: function(scope){
            scope.$watch('daysSelected', function(newValue) {
                if(newValue){
                    var momentDates = [];
                    _.each(newValue, function(timestamp){
                        momentDates.push(moment(timestamp));
                    });
                    scope.convertedDaysSelected = momentDates;
                    scope.generate();
                }
            });
            scope.$watch('callback', function() {
                scope.generate();
            });
            scope.$watch('weekDaysOff', function() {
                scope.generate();
            });
            scope.$watch('daysOff', function() {
                scope.generate();
            });

            scope.month = scope.month || moment().startOf('day');
            scope.days = [];
            scope.convertedDaysSelected = scope.convertedDaysSelected || [];

            /*To display days of week names in moment.lang*/
            var momentDaysOfWeek = moment().lang()._weekdaysMin;
            scope.daysOfWeek = [momentDaysOfWeek[1], momentDaysOfWeek[2], momentDaysOfWeek[3], momentDaysOfWeek[4], momentDaysOfWeek[5], momentDaysOfWeek[6], momentDaysOfWeek[0]];



            /*When user un/select a date, call the callback with 2 params :
            *     timestamp : timestamp in ms
            *     selected : true if date has been selected, false if date has been unselected
            * */
            scope.toggleDay = function(momentDate){
                if(momentDate.selectable){
                    momentDate.selected = !momentDate.selected;
                    if(momentDate.selected){
                        scope.convertedDaysSelected.push(momentDate);
                    }else{
                        _.remove(scope.convertedDaysSelected, function(date){
                            return date.valueOf() === momentDate.valueOf();
                        });
                        momentDate.hover = false;
                    }
                    if(typeof(scope.callback) === "function"){
                        scope.callback({timestamp:momentDate.valueOf(), selected:momentDate.selected});
                    }
                }
            };

            /*Navigate to previous month*/
            scope.previousMonth = function(){
                scope.month = scope.month.subtract('month', 1);
                scope.generate();
            };

            /*Navigate to next month*/
            scope.nextMonth = function(){
                scope.month = scope.month.add('month', 1);
                scope.generate();
            };

            /*Check if the date is off : unselectable*/
            scope.isDayOff = function(scope, date){
                return _.any(scope.weekDaysOff, function(dayOff){
                    return date.day() === dayOff;
                }) || _.any(scope.daysOff, function(dayOff){
                    return date.isSame(dayOff, 'day');
                });
            };

            /*Check if the date is selected*/
            scope.isSelected = function(scope, date){
                return _.any(scope.convertedDaysSelected, function(d){
                    return date.isSame(d, 'day');
                });
            };

            /*Generate the calendar*/
            scope.generate = function(){
                var previousDay = moment(scope.month).date(0),
                    firstDayOfMonth = moment(scope.month).date(1),
                    days = [],
                    now = moment(),
                    lastDayOfMonth = moment(firstDayOfMonth).endOf('month'),
                    maxDays = lastDayOfMonth.date();

                scope.emptyFirstDays = [];
                for (var i = firstDayOfMonth.day() === 0 ? 6 : firstDayOfMonth.day() - 1; i > 0; i--) {
                    scope.emptyFirstDays.push({});<commit_msg>fixing double 18th on OCT 2014 BRT timezone<commit_after>/*
    Creator: <NAME> For ARCA-Computing - www.arca-computing.fr
    Date: July 2014
    Version: 1.0.0

    Description:    MultipleDatePicker is an Angular directive to show a simple calendar allowing user to select multiple dates.
                    A callback is called everytime a de/selection is done.
                    Css style can be changed by editing less or css stylesheet.
                    See scope declaration below for options you can pass through html directive.
                    Feel free to edit and share this piece of code, our idea is to keep simple ;)
 */
angular.module('multipleDatePicker', [])
    .directive('multipleDatePicker', [function(){
    "use strict";
    return {
        restrict: 'AE',
        scope: {
            /*
            * Type: function(timestamp, boolean)
            * Will be called when un/select a date
            * Param timestamp will be the date at midnight
            * */
            callback: '&',
            /*
            * Type: array of milliseconds timestamps
            * Days already selected
            * */
            daysSelected: '=',
            /*
            * Type: array of integers
            * Recurrent week days not selectables
            * /!\ Sunday = 0, Monday = 1 ... Saturday = 6
            * */
            weekDaysOff: '=',
            /*
            * Type: array of milliseconds timestamps
            * Days not selectables
            * */
            daysOff: '='
        },
        template: '<div class="multiple-date-picker">'+
                        '<div class="picker-top-row">'+
                            '<div class="text-center picker-navigate" ng-click="previousMonth()">&lt;</div>'+
                            '<div class="text-center picker-month">{{month.format(\'MMMM YYYY\')}}</div>'+
                            '<div class="text-center picker-navigate" ng-click="nextMonth()">&gt;</div>'+
                        '</div>'+
                        '<div class="picker-days-week-row">'+
                            '<div class="text-center" ng-repeat="day in daysOfWeek">{{day}}</div>'+
                        '</div>'+
                        '<div class="picker-days-row">'+
                            '<div class="text-center picker-day picker-empty" ng-repeat="x in emptyFirstDays">&nbsp;</div>'+
                            '<div class="text-center picker-day" ng-repeat="day in days" ng-click="toggleDay(day)" ng-mouseover="day.hover=true" ng-mouseleave="day.hover=false" ng-class="{\'picker-selected\':day.selected, \'picker-off\':!day.selectable, \'hover\':day.hover && day.selectable, \'today\':day.today}">{{day ? day.format(\'D\') : \'\'}}</div>'+
                            '<div class="text-center picker-day picker-empty" ng-repeat="x in emptyLastDays">&nbsp;</div>'+
                        '</div>'+
                    '</div>',
        link: function(scope){
            scope.$watch('daysSelected', function(newValue) {
                if(newValue){
                    var momentDates = [];
                    _.each(newValue, function(timestamp){
                        momentDates.push(moment(timestamp));
                    });
                    scope.convertedDaysSelected = momentDates;
                    scope.generate();
                }
            });
            scope.$watch('callback', function() {
                scope.generate();
            });
            scope.$watch('weekDaysOff', function() {
                scope.generate();
            });
            scope.$watch('daysOff', function() {
                scope.generate();
            });

            scope.month = scope.month || moment().startOf('day');
            scope.days = [];
            scope.convertedDaysSelected = scope.convertedDaysSelected || [];

            /*To display days of week names in moment.lang*/
            var momentDaysOfWeek = moment().lang()._weekdaysMin;
            scope.daysOfWeek = [momentDaysOfWeek[1], momentDaysOfWeek[2], momentDaysOfWeek[3], momentDaysOfWeek[4], momentDaysOfWeek[5], momentDaysOfWeek[6], momentDaysOfWeek[0]];



            /*When user un/select a date, call the callback with 2 params :
            *     timestamp : timestamp in ms
            *     selected : true if date has been selected, false if date has been unselected
            * */
            scope.toggleDay = function(momentDate){
                if(momentDate.selectable){
                    momentDate.selected = !momentDate.selected;
                    if(momentDate.selected){
                        scope.convertedDaysSelected.push(momentDate);
                    }else{
                        _.remove(scope.convertedDaysSelected, function(date){
                            return date.valueOf() === momentDate.valueOf();
                        });
                        momentDate.hover = false;
                    }
                    if(typeof(scope.callback) === "function"){
                        scope.callback({timestamp:momentDate.valueOf(), selected:momentDate.selected});
                    }
                }
            };

            /*Navigate to previous month*/
            scope.previousMonth = function(){
                scope.month = scope.month.subtract('month', 1);
                scope.generate();
            };

            /*Navigate to next month*/
            scope.nextMonth = function(){
                scope.month = scope.month.add('month', 1);
                scope.generate();
            };

            /*Check if the date is off : unselectable*/
            scope.isDayOff = function(scope, date){
                return _.any(scope.weekDaysOff, function(dayOff){
                    return date.day() === dayOff;
                }) || _.any(scope.daysOff, function(dayOff){
                    return date.isSame(dayOff, 'day');
                });
            };

            /*Check if the date is selected*/
            scope.isSelected = function(scope, date){
                return _.any(scope.convertedDaysSelected, function(d){
                    return date.isSame(d, 'day');
                });
            };

            /*Generate the calendar*/
            scope.generate = function(){
                var previousDay = moment.utc(scope.month).date(0),
                    firstDayOfMonth = moment(scope.month).date(1),
                    days = [],
                    now = moment(),
                    lastDayOfMonth = moment(firstDayOfMonth).endOf('month'),
                    maxDays = lastDayOfMonth.date();

                scope.emptyFirstDays = [];
                for (var i = firstDayOfMonth.day() === 0 ? 6 : firstDayOfMonth.day() - 1; i > 0; i--) {
                    scope.emptyFirstDays.push({});
{'fraction_non_alphanumeric': 0.12696893861327838, 'fraction_numerical': 0.0042691005446783455, 'mean_word_length': 1.459185520361991, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1032725', 'n_tokens_mistral': 3482, 'n_tokens_neox': 3264, 'n_words': 762}