<commit_before>/*!
 * HoloDateWidget v0.1 ~ Copyright (c) 2013 <NAME>, http://galaxyard.com
 * Released under MIT license
 */

(function(){
    var defOptions = {
        onChange: function(val) {},
        defDate: new XDate(),
        locale: 'ru',
        dateFormat: 'dd/MM/yyyy',
        startYearOffset: -10,
        endYearOffset: +10
    };

    var HDW = function(el, options){
        this.element = typeof el == 'object' ? el : document.getElementById(el);
        this.options = extend(defOptions, options);
        XDate.defaultLocale = this.options.locale;
        this.date = this.options.defDate;
        var that = this, opt=that.options;

        if (opt.startYearOffset>=opt.endYearOffset) {
            opt.endYearOffset = opt.startYearOffset + 2;
        }
        that.startYear = that.date.getFullYear()+opt.startYearOffset;
        that.endYear = that.date.getFullYear()+opt.endYearOffset;

        this.element.readOnly = true;

        var hdw = document.createDocumentFragment();
        var dlg = newDiv('hdw-dialog hdw-theme', hdw);
        dlg.style.display = 'none';

        var btn = newDiv('hdw-btn theme', dlg);
        btn.innerText = 'OK';

        var title = newDiv('hdw-title theme', dlg);
        title.innerText = that.options.defDate.toString('ddd d MMMM, yyyy', that.options.locale);

        //day selector
        var daySel = newDiv('hdw-day-sel', dlg);
        newDiv('hdv-day-active theme', dlg);

        var scl =  newDiv('hdw-day-scl', daySel);
        var ul = newElement('ul','hdw-day-ul',scl);

        var li = newElement('li','hdw-day-li theme',ul);
        for (var i=1; i<32; ++i) {
            li = newElement('li','hdw-day-li theme',ul);
            li.innerText = i;
        }
        newElement('li','hdw-day-li theme',ul);

        //month selector
        var monthSel = newDiv('hdw-month-sel', dlg);
        newDiv('hdv-month-active theme', dlg);

        scl =  newDiv('hdw-month-scl', monthSel);
        ul = newElement('ul','hdw-month-ul',scl);

        li = newElement('li','hdw-month-li theme',ul);
        for (var i=1; i<13; ++i) {
            li = newElement('li','hdw-month-li theme',ul);
            li.innerText = i;
        }
        newElement('li','hdw-month-li theme',ul);

        //year selector
        var yearSel = newDiv('hdw-year-sel', dlg);
        newDiv('hdv-year-active theme', dlg);

        scl =  newDiv('hdw-year-scl', yearSel);
        ul = newElement('ul','hdw-year-ul',scl);

        li = newElement('li','hdw-year-li theme',ul);

        for (var i=that.startYear; i<=that.endYear; ++i) {
            li = newElement('li','hdw-year-li theme',ul);
            li.innerText = i;
        }
        newElement('li','hdw-year-li theme',ul);

        var ovl = newDiv('hdw-overlay', hdw);
        ovl.style.display = 'none';

        document.body.appendChild(hdw);

        this.dayScroll = new iScroll(daySel, {
            snap: 'li',
            momentum: true,
            hScrollbar: false,
            vScrollbar: false,
            hScroll: false,
            bounce: false,
            useTransition:true
        }, function(day) {
            that.date.setDate(day+1);
            updateDate(that.date, that, title);
        });

        this.monthScroll = new iScroll(monthSel, {
            snap: 'li',
            momentum: true,
            hScrollbar: false,
            vScrollbar: false,
            hScroll: false,
            bounce: false,
            useTransition:true
        }, function(month) {
            that.date.setMonth(month);
            updateDate(that.date, that, title);
        });

        this.yearScroll = new iScroll(yearSel, {
            snap: 'li',
            momentum: true,
            hScrollbar: false,
            vScrollbar: false,
            hScroll: false,
            bounce: false,
            useTransition:true
        }, function(yearNum) {
            that.date.setFullYear(that.startYear+yearNum);
            updateDate(that.date, that, title);
        });

        this.xbtn = XButton(btn, {dlg: dlg, ovl: ovl, hdw: this}, onOkBtnClick, 'btn-down');

        this.element.addEventListener('click', function() {
            //this.removeEventListener('click', arguments.callee, false );
            ovl.style.display = 'block';
            dlg.style.display = 'block';
            ovl.style.opacity = 0.5;
            dlg.style.opacity = 1;

            setDate(that, title);

            console.log(that.dayScroll.currPageY);
        }, false);
    };

    HDW.prototype = {
        destroy: function(){
            this.xbtn.destroy();
            this.xbtn = null;
            this.dayScroll.destroy();
            this.dayScroll = null;
            this.monthScroll.destroy();
            this.monthScroll = null;
            this.yearScroll.destroy();
            this.yearScroll = null;
        }
    };

    function onOkBtnClick(rel) {
        var dlg = rel.dlg;
        var ovl = rel.ovl;
        var hdw = rel.hdw;

        ovl.style.display = 'none';
        dlg.style.display = 'none';<commit_msg>fix: initialize on input with value<commit_after>/*!
 * HoloDateWidget v0.1 ~ Copyright (c) 2013 <NAME>, http://galaxyard.com
 * Released under MIT license
 */

(function(){
    var defOptions = {
        onChange: function(val) {},
        defDate: new XDate(),
        locale: 'ru',
        dateFormat: 'dd/MM/yyyy',
        startYearOffset: -10,
        endYearOffset: +10
    };

    var HDW = function(el, options){
        this.element = typeof el == 'object' ? el : document.getElementById(el);
        this.options = extend(defOptions, options);
        XDate.defaultLocale = this.options.locale;

        if (this.element.value != null && this.element.value != '') {
            this.date = new XDate(this.element.value);
        } else {
            this.date = this.options.defDate;
        }

        var that = this, opt=that.options;

        if (opt.startYearOffset>=opt.endYearOffset) {
            opt.endYearOffset = opt.startYearOffset + 2;
        }
        that.startYear = that.date.getFullYear()+opt.startYearOffset;
        that.endYear = that.date.getFullYear()+opt.endYearOffset;

        this.element.readOnly = true;

        var hdw = document.createDocumentFragment();
        var dlg = newDiv('hdw-dialog hdw-theme', hdw);
        dlg.style.display = 'none';

        var btn = newDiv('hdw-btn theme', dlg);
        btn.innerText = 'OK';

        var title = newDiv('hdw-title theme', dlg);
        title.innerText = that.options.defDate.toString('ddd d MMMM, yyyy', that.options.locale);

        //day selector
        var daySel = newDiv('hdw-day-sel', dlg);
        newDiv('hdv-day-active theme', dlg);

        var scl =  newDiv('hdw-day-scl', daySel);
        var ul = newElement('ul','hdw-day-ul',scl);

        var li = newElement('li','hdw-day-li theme',ul);
        for (var i=1; i<32; ++i) {
            li = newElement('li','hdw-day-li theme',ul);
            li.innerText = i;
        }
        newElement('li','hdw-day-li theme',ul);

        //month selector
        var monthSel = newDiv('hdw-month-sel', dlg);
        newDiv('hdv-month-active theme', dlg);

        scl =  newDiv('hdw-month-scl', monthSel);
        ul = newElement('ul','hdw-month-ul',scl);

        li = newElement('li','hdw-month-li theme',ul);
        for (var i=1; i<13; ++i) {
            li = newElement('li','hdw-month-li theme',ul);
            li.innerText = i;
        }
        newElement('li','hdw-month-li theme',ul);

        //year selector
        var yearSel = newDiv('hdw-year-sel', dlg);
        newDiv('hdv-year-active theme', dlg);

        scl =  newDiv('hdw-year-scl', yearSel);
        ul = newElement('ul','hdw-year-ul',scl);

        li = newElement('li','hdw-year-li theme',ul);

        for (var i=that.startYear; i<=that.endYear; ++i) {
            li = newElement('li','hdw-year-li theme',ul);
            li.innerText = i;
        }
        newElement('li','hdw-year-li theme',ul);

        var ovl = newDiv('hdw-overlay', hdw);
        ovl.style.display = 'none';

        document.body.appendChild(hdw);

        this.dayScroll = new iScroll(daySel, {
            snap: 'li',
            momentum: true,
            hScrollbar: false,
            vScrollbar: false,
            hScroll: false,
            bounce: false,
            useTransition:true
        }, function(day) {
            that.date.setDate(day+1);
            updateDate(that.date, that, title);
        });

        this.monthScroll = new iScroll(monthSel, {
            snap: 'li',
            momentum: true,
            hScrollbar: false,
            vScrollbar: false,
            hScroll: false,
            bounce: false,
            useTransition:true
        }, function(month) {
            that.date.setMonth(month);
            updateDate(that.date, that, title);
        });

        this.yearScroll = new iScroll(yearSel, {
            snap: 'li',
            momentum: true,
            hScrollbar: false,
            vScrollbar: false,
            hScroll: false,
            bounce: false,
            useTransition:true
        }, function(yearNum) {
            that.date.setFullYear(that.startYear+yearNum);
            updateDate(that.date, that, title);
        });

        this.xbtn = XButton(btn, {dlg: dlg, ovl: ovl, hdw: this}, onOkBtnClick, 'btn-down');

        this.element.addEventListener('click', function() {
            //this.removeEventListener('click', arguments.callee, false );
            ovl.style.display = 'block';
            dlg.style.display = 'block';
            ovl.style.opacity = 0.5;
            dlg.style.opacity = 1;

            setDate(that, title);
        }, false);
    };

    HDW.prototype = {
        destroy: function(){
            this.xbtn.destroy();
            this.xbtn = null;
            this.dayScroll.destroy();
            this.dayScroll = null;
            this.monthScroll.destroy();
            this.monthScroll = null;
            this.yearScroll.destroy();
            this.yearScroll = null;
        }
    };

    function onOkBtnClick(rel) {
        var dlg = rel.dlg;
        var ovl = rel.ovl;
        var hdw = rel.hdw;

        ovl.style.display = 'none';
        dlg.style.display = 'none';
{'fraction_non_alphanumeric': 0.14405458089668616, 'fraction_numerical': 0.004093567251461989, 'mean_word_length': 1.8321832735302235, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '6828599', 'n_tokens_mistral': 3269, 'n_tokens_neox': 3171, 'n_words': 621}