<commit_before>/*global require, module, window*/
var Calendar = function (properties) {
    'use strict';
    properties = properties || {};
    var calendar = {},
        m = window.m || require("mithril"),
        actual = new Date(),
        functionType = Object.prototype.toString.call(function () {});

    properties.time = properties.time === undefined ? true : properties.time;

    calendar.actual = m.prop(new Date(actual.getFullYear(), actual.getMonth(), actual.getDate()));

    calendar.now = properties.now ? m.prop(properties.now) : m.prop(new Date());

    calendar.mindate = properties.mindate;
    if (calendar.mindate) {
        calendar.mindate_nt = new Date(calendar.mindate.getFullYear(), calendar.mindate.getMonth(), calendar.mindate.getDate());
    }
    calendar.maxdate = properties.maxdate;
    if (calendar.maxdate) {
        calendar.maxdate_nt = new Date(calendar.maxdate.getFullYear(), calendar.maxdate.getMonth(), calendar.maxdate.getDate());
    }

    if (calendar.mindate && +calendar.now() < +calendar.mindate) {
        calendar.now(calendar.mindate);
    }
    if (calendar.maxdate && +calendar.now() > +calendar.maxdate) {
        calendar.now(calendar.maxdate);
    }

    function daysInMonth(month, year) {
        return new Date(year, month, 0).getDate();
    }

    function merge(obj1, obj2) {
        for (var p in obj2) {
            try {
                // Property in destination object set; update its value.
                if (obj2[p].constructor == Object) {
                    obj1[p] = merge(obj1[p], obj2[p]);

                } else {
                    obj1[p] = obj2[p];

                }

            } catch (e) {
                // Property in destination object not set; create it and set its value.
                obj1[p] = obj2[p];

            }
        }
        return obj1;
    }

    calendar.editYear = function(date) {
        var cal = this,
            year = date().getFullYear();
        return m('span', [
            m('span', {
                onclick: function () {
                    calendar.editingYear(true);
                },
                style: calendar.editingYear() ? 'display:none;' : 'cursor: pointer;text-decoration: underline;'
            }, year),
            m('input', {
                value: year,
                maxlength: 4,
                type: 'text',
                required: 'required',
                style: !calendar.editingYear() ? 'display:none;' : 'width: 40px;padding: 1px;',
                config: function (element) {
                    if (calendar.editingYear()) {
                        element.focus();
                        element.selectionStart = element.value.length;
                    }
                },
                onblur: function () {
                    if (+this.value < 1800 || +this.value > 2999) {
                        return;
                    }
                    if (cal.mindate && this.value < cal.mindate.getFullYear()) {
                        return;
                    }
                    if (cal.maxdate && this.value > cal.maxdate.getFullYear()) {
                        return;
                    }
                    cal.date().setFullYear(this.value);
                    cal.editingYear(false);
                }
            }),
        ]);
    };

    calendar.editingYear = m.prop(false);

    calendar.i18n = {
        monthsLong: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        months: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        daysLong: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
        days: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
    };

    calendar.small = properties.small;

    calendar.i18n = merge(calendar.i18n, properties.i18n);
    calendar.formatCell = properties.formatCell || function (date) {
        var style = '',
            claz = '',
            cal = this;
        if (+date === +this.actual()) {
            style = 'background-color:#00b5ad;color:#fff;';
        }
        if (+date === +this.value()) {
            style = 'background-color:#5bbd72;color:#fff;';
        }
        if ((cal.mindate_nt && date < cal.mindate_nt) || (cal.maxdate_nt && date > cal.maxdate_nt)) {
            claz = '.disabled';
        }
        return m('td.center.aligned' + claz, {
            style: style
        }, [
            claz.indexOf('.disabled') < 0 ?
                m('a[href="#"]', {
                    style: style,
                    onclick: function (e) {
                        e.preventDefault();
                        cal.value(date);
                        if (properties.onclick) {
                            properties.onclick(cal.getDate());
                        }<commit_msg>Pointer cursor and larger click area on the individual calendar days.<commit_after>/*global require, module, window*/
var Calendar = function (properties) {
    'use strict';
    properties = properties || {};
    var calendar = {},
        m = window.m || require("mithril"),
        actual = new Date(),
        functionType = Object.prototype.toString.call(function () {});

    properties.time = properties.time === undefined ? true : properties.time;

    calendar.actual = m.prop(new Date(actual.getFullYear(), actual.getMonth(), actual.getDate()));

    calendar.now = properties.now ? m.prop(properties.now) : m.prop(new Date());

    calendar.mindate = properties.mindate;
    if (calendar.mindate) {
        calendar.mindate_nt = new Date(calendar.mindate.getFullYear(), calendar.mindate.getMonth(), calendar.mindate.getDate());
    }
    calendar.maxdate = properties.maxdate;
    if (calendar.maxdate) {
        calendar.maxdate_nt = new Date(calendar.maxdate.getFullYear(), calendar.maxdate.getMonth(), calendar.maxdate.getDate());
    }

    if (calendar.mindate && +calendar.now() < +calendar.mindate) {
        calendar.now(calendar.mindate);
    }
    if (calendar.maxdate && +calendar.now() > +calendar.maxdate) {
        calendar.now(calendar.maxdate);
    }

    function daysInMonth(month, year) {
        return new Date(year, month, 0).getDate();
    }

    function merge(obj1, obj2) {
        for (var p in obj2) {
            try {
                // Property in destination object set; update its value.
                if (obj2[p].constructor == Object) {
                    obj1[p] = merge(obj1[p], obj2[p]);

                } else {
                    obj1[p] = obj2[p];

                }

            } catch (e) {
                // Property in destination object not set; create it and set its value.
                obj1[p] = obj2[p];

            }
        }
        return obj1;
    }

    calendar.editYear = function(date) {
        var cal = this,
            year = date().getFullYear();
        return m('span', [
            m('span', {
                onclick: function () {
                    calendar.editingYear(true);
                },
                style: calendar.editingYear() ? 'display:none;' : 'cursor: pointer;text-decoration: underline;'
            }, year),
            m('input', {
                value: year,
                maxlength: 4,
                type: 'text',
                required: 'required',
                style: !calendar.editingYear() ? 'display:none;' : 'width: 40px;padding: 1px;',
                config: function (element) {
                    if (calendar.editingYear()) {
                        element.focus();
                        element.selectionStart = element.value.length;
                    }
                },
                onblur: function () {
                    if (+this.value < 1800 || +this.value > 2999) {
                        return;
                    }
                    if (cal.mindate && this.value < cal.mindate.getFullYear()) {
                        return;
                    }
                    if (cal.maxdate && this.value > cal.maxdate.getFullYear()) {
                        return;
                    }
                    cal.date().setFullYear(this.value);
                    cal.editingYear(false);
                }
            }),
        ]);
    };

    calendar.editingYear = m.prop(false);

    calendar.i18n = {
        monthsLong: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        months: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        daysLong: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
        days: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
    };

    calendar.small = properties.small;

    calendar.i18n = merge(calendar.i18n, properties.i18n);
    calendar.formatCell = properties.formatCell || function (date) {
        var style = {
            cursor: 'pointer'
        }
        var claz = '',
            cal = this;
        if (+date === +this.actual()) {
            style['background-color'] = '#00b5ad';
            style.color = '#fff';
        }
        if (+date === +this.value()) {
            style['background-color'] = '#5bbd72';
            style.color = '#fff';
        }
        if ((cal.mindate_nt && date < cal.mindate_nt) || (cal.maxdate_nt && date > cal.maxdate_nt)) {
            claz = '.disabled';
        }
        return m('td.center.aligned' + claz, {
            style: style,
            onclick: function (e) {
                e.preventDefault();
                cal.value(date);
                if (properties.onclick) {
                    properties.onclick(cal.getDate());
                }
            }
        }, [
            claz.indexOf('.disabled') < 0 ?
                m('a[href="#"]', {
                    style: style,
                    onclick: function (e) {
                        e.preventDefault();
{'fraction_non_alphanumeric': 0.14866352988287115, 'fraction_numerical': 0.008008809690659726, 'mean_word_length': 1.5847347994825356, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '7164895', 'n_tokens_mistral': 2910, 'n_tokens_neox': 2684, 'n_words': 573}