<commit_before>/*
 * jcalendarview
 * Continuous improvement to convert an unordered list into a calendar view.
 * 
 * Leftclick.com.au jQuery plugin library
 * 
 * Copyright (c) 2009 Leftclick.com.au, <NAME>
 * 
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 */

;(function($) {
	
	/**
	 * Convert a &lt;ul&gt; element into a calendar view.
	 * 
	 * TODO Document options
	 */
	$.fn.jcalendarview = function(options, date) {
		var calendar = null;
		$(this).each(function() {
			if (this.nodeName.toLowerCase() == 'ul') {
				calendar = new $.jcalendarview(this, options, date);
			}
		});
		return calendar;
	};
	
	/**
	 * Initialise the given element as a calendar view.
	 * 
	 * @param elem &lt;ul&gt; element to convert into a calendar view
	 * @param options See $.fn.jcalendarview(options)
	 */
	$.jcalendarview = function(elem, options, date) {
		this.options = $.extend({}, $.jcalendarview.defaultOptions, options);
		this.date = this.fixDate(date ? date : new Date());
		this.elem = $(elem);
		this.container = $('<div class="' + this.options.calendarViewClass + '"></div>');
		this.elem.parent().append(this.container);
		this.data = this.getData($('li', this.elem));
		this.size = Math.floor(this.container.innerWidth() / 7.0);
		this.render();
		this.container.append('<div style="clear:both;"></div>');
		this.container.css('display', 'inline-block');
		this.elem.css('display', 'none');
		return this.container;
	};

	/**
	 * Calendar view default options.
	 */
	$.jcalendarview.defaultOptions = {
		'displayControls' : true,
		'minDate' : null,
		'maxDate' : null,
		
		'dateFieldInputClass' : 'date',
		'previewTextInputClass' : 'previewText',
		'fullTextInputClass' : 'fullText',
	
		'calendarViewClass' : 'cvCalendarView',
		'monthYearClass' : 'cvMonthYear',
		'previousMonthLinkClass' : 'cvPreviousMonth',
		'nextMonthLinkClass' : 'cvNextMonth',
		'dayNameDivClass' : 'cvDayNameDiv',
		'dayNameLabelClass' : 'cvDayNameLabel',
		'dayClass' : 'cvDay',
		'dayOutOfMonthClass' : 'cvDayOutOfMonth',
		'pastDateClass' : 'cvPastDate',
		'currentDateClass' : 'cvCurrentDate',
		'futureDateClass' : 'cvFutureDate',
		'dayNumberClass' : 'cvDayNumber',
		'currentDateLabelClass' : 'cvCurrentDateLabel',
		'innerClass' : 'cvInner',
		'dateFieldClass' : 'cvDate',
		'previewTextContainerClass' : 'cvPreviewText',
		'fullTextContainerClass' : 'cvFullText',
		
		'currentDateLabelText' : 'today',
		'previousMonthLinkText' : '&lArr; previous',
		'nextMonthLinkText' : 'next &rArr;'
	};
	
	/**
	 * Instance methods for calendar view widget.
	 */
	$.extend($.jcalendarview.prototype, {
		
		/**
		 * Get the data from the given set of &lt;li&gt; elements.
		 * 
		 * @param liElems Elements to inspect.
		 * 
		 * @return Key-value map of data from the list.
		 */
        getData : function(liElems) {
	        data = [];
	        for (var i=0; i<liElems.length; i++) {
                var liElem = liElems[i];
                if (liElem.nodeName.toLowerCase() == 'li') {
                    liElem = $(liElem);
                    var dateElem = liElem.find('.'+this.options.dateFieldInputClass);
                    if (dateElem && dateElem.length > 0) {
                        var date = Date.parse($(dateElem).text());
                        var previewTextElem = liElem.find('.'+this.options.previewTextInputClass);
                        var fullTextElem = liElem.find('.'+this.options.fullTextInputClass);
                        date.set({ 'hour' : 0, 'minute' : 0, 'second' : 0, 'millisecond' : 0 });
                        data[data.length] = {
                            'date' : date,
                            'previewText' : previewTextElem.html(),
                            'fullText' : fullTextElem.html()
                        };
                    }
	            }
	        }
	        return data;
		},
		
		/**
		 * Helper method.<commit_msg>ben: jquery.jcalendarview: bugfix<commit_after>/*
 * jcalendarview
 * Continuous improvement to convert an unordered list into a calendar view.
 * 
 * Leftclick.com.au jQuery plugin library
 * 
 * Copyright (c) 2009 Leftclick.com.au, <NAME>
 * 
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 */

;(function($) {
	
	/**
	 * Convert a &lt;ul&gt; element into a calendar view.
	 * 
	 * TODO Document options
	 */
	$.fn.jcalendarview = function(options, date) {
		var calendar = null;
		$(this).each(function() {
			if (this.nodeName.toLowerCase() == 'ul') {
				calendar = new $.jcalendarview(this, options, date);
			}
		});
		return calendar;
	};
	
	/**
	 * Initialise the given element as a calendar view.
	 * 
	 * @param elem &lt;ul&gt; element to convert into a calendar view
	 * @param options See $.fn.jcalendarview(options)
	 */
	$.jcalendarview = function(elem, options, date) {
		this.options = $.extend({}, $.jcalendarview.defaultOptions, options);
		this.date = this.fixDate(date ? date : new Date());
		this.elem = $(elem);
		this.container = $('<div class="' + this.options.calendarViewClass + '"></div>');
		this.elem.parent().append(this.container);
		this.data = this.getData($('li', this.elem));
		this.size = Math.floor(this.container.innerWidth() / 7.0);
		this.render();
		this.container.append('<div style="clear:both;"></div>');
		this.container.css('display', 'inline-block');
		this.elem.css('display', 'none');
		return this.container;
	};

	/**
	 * Calendar view default options.
	 */
	$.jcalendarview.defaultOptions = {
		'displayControls' : true,
		'minDate' : null,
		'maxDate' : null,
		
		'dateFieldInputClass' : 'date',
		'previewTextInputClass' : 'previewText',
		'fullTextInputClass' : 'fullText',
	
		'calendarViewClass' : 'cvCalendarView',
		'monthYearClass' : 'cvMonthYear',
		'previousMonthLinkClass' : 'cvPreviousMonth',
		'nextMonthLinkClass' : 'cvNextMonth',
		'dayNameDivClass' : 'cvDayNameDiv',
		'dayNameLabelClass' : 'cvDayNameLabel',
		'dayClass' : 'cvDay',
		'dayOutOfMonthClass' : 'cvDayOutOfMonth',
		'pastDateClass' : 'cvPastDate',
		'currentDateClass' : 'cvCurrentDate',
		'futureDateClass' : 'cvFutureDate',
		'dayNumberClass' : 'cvDayNumber',
		'currentDateLabelClass' : 'cvCurrentDateLabel',
		'innerClass' : 'cvInner',
		'dateFieldClass' : 'cvDate',
		'previewTextContainerClass' : 'cvPreviewText',
		'fullTextContainerClass' : 'cvFullText',
		
		'currentDateLabelText' : 'today',
		'previousMonthLinkText' : '&lArr; previous',
		'nextMonthLinkText' : 'next &rArr;'
	};
	
	/**
	 * Instance methods for calendar view widget.
	 */
	$.extend($.jcalendarview.prototype, {
		
		/**
		 * Get the data from the given set of &lt;li&gt; elements.
		 * 
		 * @param liElems Elements to inspect.
		 * 
		 * @return Key-value map of data from the list.
		 */
        getData : function(liElems) {
	        data = [];
	        for (var i=0; i<liElems.length; i++) {
                var liElem = liElems[i];
                if (liElem.nodeName.toLowerCase() == 'li') {
                    liElem = $(liElem);
                    var dateElem = liElem.find('.'+this.options.dateFieldInputClass);
                    if (dateElem && dateElem.length > 0) {
                    	var dateText = $.trim($(dateElem).text());
                        var date = Date.parse(dateText);
                        var previewTextElem = liElem.find('.'+this.options.previewTextInputClass);
                        var fullTextElem = liElem.find('.'+this.options.fullTextInputClass);
                        date.set({ 'hour' : 0, 'minute' : 0, 'second' : 0, 'millisecond' : 0 });
                        data[data.length] = {
                            'date' : date,
                            'previewText' : previewTextElem.html(),
                            'fullText' : fullTextElem.html()
                        };
                    }
	            }
	        }
	        return data;
		},
		
		/**
		 * Helper method.
{'fraction_non_alphanumeric': 0.15445819651427128, 'fraction_numerical': 0.0030310684516291994, 'mean_word_length': 2.6225983531564503, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '243094', 'n_tokens_mistral': 2694, 'n_tokens_neox': 2423, 'n_words': 516}