<commit_before>/**
 * A customizable date picker based on jQuery.
 * @author <NAME> <EMAIL>
 * @version 1.0
 * Released under terms of the MIT lincense.
 */

(function($) {

    // default setting
	var defaults = {
		container: 'body',
		language: 'cn',
		mode: 'single',
        weekStart: '1',
        theme: 'normal',
	};

	var _html = '<div id="calendar" class="cal-style">'
            		+ '<div class="cal-header">'
                		+ '<div class="cal-info">'
                    		+ '<span class="prev"><span class="prev-icon"></span></span>'
                    		+ '<span class="cal-year-month"></span>'
                    		+ '<span class="next"><span class="next-icon"></span></span>'
                		+ '</div>'
                		+ '<div class="cal-weeks"></div>'
            		+ '</div>'
            		+ '<div class="cal-body"></div>'
            		+ '<div class="cal-footer"></div>'
        		+ '</div>';

    var weeks = {
    	enShort: ['Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun'],
    	cnShort: ['一', '二', '三', '四', '五', '六', '日'],
    	enLong: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
    	cnLong: ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']
    };

    // Sets the default current date is now
    var current = new Date(),
    	currYear = current.getFullYear(),
    	currMonth = current.getMonth() + 1,
    	currDate = current.getDate();

    /**
     * Render the calendar
     */
    var init = function(options) {
        // set options for global use
        $.fn.calendar.settings = options;
    	var container = options.container,
    		language = options.language;
        $(container).html($(_html));

        // render weeks
        /*var weeksPanel = $('#calendar').find('.cal-weeks'),
        	weeksData = weeks[language + 'Short'];
        weeksData.forEach(function(d) {
        	var perDay = $('<span class="cal-day"></span>');
        	weeksPanel.append(perDay.text(d));
        });*/
        renderWeeks();

        // render some cells to show date
        var datesPanel = $('#calendar').find('.cal-body');
        for (var i = 1; i <= 5; i++) {
        	var perWeek = $('<div class="cal-per-week"></div>');
        	for (var j = (i - 1) * 7 + 1; j <= i * 7; j++) {
        		var perDate = $('<span class="cal-per-date"></span>');
        		perWeek.append(perDate);
        	}
        	datesPanel.append(perWeek);
        }
    };

    /**
     * Render weeks
     */
    var renderWeeks = function() {
        var options = $.fn.calendar.settings;
        // gets language and week-start
        var  language = options.language,
             weekStart = options.weekStart;

        var panel = $('#calendar').find('.cal-weeks'),
            weeksData = weeks[language + 'Short'];
        weekStart--;

        var firstDay = $('<span class="cal-day"></span>');
        $(panel[0]).append(firstDay.text(weeksData[weekStart]));
        for (var i = 1; i < weeks[language + 'Short'].length - weekStart; i++) {
            var perDay = $('<span class="cal-day"></span>');
            panel.append(perDay.text(weeks[language + 'Short'][i + weekStart]));
        }
        for (var i = 0; i < weekStart; i++) {
            var perDay = $('<span class="cal-day"></span>');
            panel.append(perDay.text(weeks[language + 'Short'][i]));
        }
    };

    /**
     * Sets current year and month for calendar
     */
    var renderYearMonth = function() {
        var yearAndMonth = format.call(current);
        $('.cal-year-month').text(yearAndMonth);
    };

    /**
     * Fills cells with dates
     */
    var renderCells = function() {
        var options = $.fn.calendar.settings;
        $('.cal-per-date').text('').removeClass('has-date');
    	var firstDayInMonth = getFirstDayInMonth(current),
    		datesInMonth = getDatesInMonth(current);

        var weekStart = options.weekStart;
        var firstDate;
        if (firstDayInMonth < weekStart) {
            firstDate = firstDayInMonth - weekStart + 7;
        } else {
            firstDate = firstDayInMonth - weekStart
        }

    	var cells = $('.cal-per-date:eq(' + firstDate + '), .cal-per-date:gt(' + firstDate + ')');
    	for (var i = 1; i <= datesInMonth; i++) {
    		var dataDate = format.call(current);
    		$(cells[i - 1]).text(i).addClass('has-date').attr('data-date', dataDate);
    	}<commit_msg>Refined the renderCells function<commit_after>/**
 * A customizable date picker based on jQuery.
 * @author <NAME> <EMAIL>
 * @version 1.0
 * Released under terms of the MIT lincense.
 */

(function($) {

    // default setting
	var defaults = {
		container: 'body',
		language: 'cn',
		mode: 'single',
        weekStart: '1',
        theme: 'normal',
	};

	var _html = '<div id="calendar" class="cal-style">'
            		+ '<div class="cal-header">'
                		+ '<div class="cal-info">'
                    		+ '<span class="prev"><span class="prev-icon"></span></span>'
                    		+ '<span class="cal-year-month"></span>'
                    		+ '<span class="next"><span class="next-icon"></span></span>'
                		+ '</div>'
                		+ '<div class="cal-weeks"></div>'
            		+ '</div>'
            		+ '<div class="cal-body"></div>'
            		+ '<div class="cal-footer"></div>'
        		+ '</div>';

    var weeks = {
    	enShort: ['Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun'],
    	cnShort: ['一', '二', '三', '四', '五', '六', '日'],
    	enLong: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
    	cnLong: ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']
    };

    // Sets the default current date is now
    var current = new Date(),
    	currYear = current.getFullYear(),
    	currMonth = current.getMonth() + 1,
    	currDate = current.getDate();

    /**
     * Render the calendar
     */
    var init = function(options) {
        // set options for global use
        $.fn.calendar.settings = options;
    	var container = options.container,
    		language = options.language;
        $(container).html($(_html));

        // render weeks
        /*var weeksPanel = $('#calendar').find('.cal-weeks'),
        	weeksData = weeks[language + 'Short'];
        weeksData.forEach(function(d) {
        	var perDay = $('<span class="cal-day"></span>');
        	weeksPanel.append(perDay.text(d));
        });*/
        renderWeeks();

        // render some cells to show date
        /*var datesPanel = $('#calendar').find('.cal-body');
        for (var i = 1; i <= 5; i++) {
        	var perWeek = $('<div class="cal-per-week"></div>');
        	for (var j = (i - 1) * 7 + 1; j <= i * 7; j++) {
        		var perDate = $('<span class="cal-per-date"></span>');
        		perWeek.append(perDate);
        	}
        	datesPanel.append(perWeek);
        }*/
        for (var i = 0; i < 5; i++) {
            createSingleContainer();
        }
    };

    /**
     * Creates a single line of container for fill every seven dates
     */
    var createSingleContainer = function() {
        var panel = $('#calendar').find('.cal-body'),
            container = $('<div class="cal-per-week"></div>');
        for (var i = 0; i < 7; i++) {
            var perDate = $('<span class="cal-per-date"></span>');
            container.append(perDate);
        }
        panel.append(container);
    };

    /**
     * Render weeks
     */
    var renderWeeks = function() {
        var options = $.fn.calendar.settings;
        // gets language and week-start
        var  language = options.language,
             weekStart = options.weekStart;

        var panel = $('#calendar').find('.cal-weeks'),
            weeksData = weeks[language + 'Short'];
        weekStart--;

        var firstDay = $('<span class="cal-day"></span>');
        $(panel[0]).append(firstDay.text(weeksData[weekStart]));
        for (var i = 1; i < weeks[language + 'Short'].length - weekStart; i++) {
            var perDay = $('<span class="cal-day"></span>');
            panel.append(perDay.text(weeks[language + 'Short'][i + weekStart]));
        }
        for (var i = 0; i < weekStart; i++) {
            var perDay = $('<span class="cal-day"></span>');
            panel.append(perDay.text(weeks[language + 'Short'][i]));
        }
    };

    /**
     * Sets current year and month for calendar
     */
    var renderYearMonth = function() {
        var yearAndMonth = format.call(current);
        $('.cal-year-month').text(yearAndMonth);
    };

    /**
     * Fills cells with dates
     */
    var renderCells = function() {
        var options = $.fn.calendar.settings;
        $('.cal-per-date').text('').removeClass('has-date');
    	var firstDayInMonth = getFirstDayInMonth(current),
    		datesInMonth = getDatesInMonth(current);

        var weekStart = options.weekStart;
        var firstDate;
        if (firstDayInMonth < weekStart) {
            firstDate = firstDayInMonth - weekStart + 7;
        } else {
            firstDate = firstDayInMonth - weekStart
        }

    	var cells = $('.cal-per-date:eq(' + firstDate + '), .cal-per-date:gt(' + firstDate + ')'),
            last,
            curr = new Date(current);
    	for (var i = 1; i <= datesInMonth; i++) {
            if (cells[i - 1]) {
                curr.setDate(i);
                 var dataDate = format.call(curr);
                $(cells[i - 1]).text(i).addClass('has-date').attr('data-date', dataDate);
                last = i;
            }
    	}

        // render the rest dates
        if (last < datesInMonth) {
            createSingleContainer();
            cells = $('.cal-per-date:gt(34)');
            var rest = datesInMonth - last;
            for (var i = 0; i < rest; i++) {
                if (cells[i]) {
                    curr.setDate(last + i + 1);
                    var dataDate = format.call(curr);
                    $(cells[i]).text(last + i + 1).addClass('has-date').attr('data-date', dataDate);
                }
            }
        }

{'fraction_non_alphanumeric': 0.18360819590204897, 'fraction_numerical': 0.004197901049475262, 'mean_word_length': 1.9360328638497653, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 79, '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': '2697355', 'n_tokens_mistral': 3181, 'n_tokens_neox': 3077, 'n_words': 701}