<commit_before>const $ = require('jquery');
const moment = require('moment');
require('fullcalendar');
const months = [];
const defferedAjax = [];
const events = [];
let calendar;

let calendarDate, thisMonth, thisYear, thisDay;

$(function () {
    calendar = $('#calendar');
    $('#decrease').click(decreaseMonth);
    $('#increase').click(advanceMonth);
    initMonth();
    initEvents();
});

function getMonthYear(month, year) {
    let date = new Date(year, month - 1, 1);

    return {month: (date.getMonth() + 1), year: date.getFullYear()};
}

async function initEvents() {
    for (let j = thisMonth; j < thisMonth + 4; ++j) {
        let monthYear = getMonthYear(j, thisYear);

        const daysThisMonth = getDaysInMonth(monthYear.month, monthYear.year);
        for (let i = 1; i < daysThisMonth; ++i) {
            defferedAjax.push(
                $.ajax({
                    dataType: "json",
                    url: 'https://event-parking-api.herokuapp.com/event/' + monthYear.year + '/' + monthYear.month + '/' + i
                }).then(addEvents)
            );
        }

    }

    $.when.apply($, defferedAjax).then(() => {
        loadCalendar()
    });

    months.push(thisMonth);
}

async function getMoreEvents() {
    if (months.indexOf(thisMonth) === -1) {
        const daysThisMonth = getDaysInMonth(thisMonth, thisYear);
        for (let i = 1; i < daysThisMonth; ++i) {
            defferedAjax.push(
                $.ajax({
                    dataType: "json",
                    url: 'https://event-parking-api.herokuapp.com/event/' + thisYear + '/' + thisMonth + '/' + i
                }).then(addEvents)
            );
        }
        $.when.apply($, defferedAjax).then(() => {
            console.log(events);
            calendar.fullCalendar('refetchEventSources', events);
        })
    }

    months.push(thisMonth);
}

function getDaysInMonth(month, year) {
    const date = new Date(year, month, 0);
    return date.getDate();
}

async function addEvents(data) {
    for (let i = 0; i < data.length; ++i) {
        events.push({
            title: data[i]['title'],
            start: data[i]['start_date'],
            end: data[i]['end_date'],
            url: data[i]['url'],<commit_msg>added fullcalendar and inserted events into calendar.<commit_after>const $ = require('jquery');
require('fullcalendar');
const moment = require('moment');
const months = [];
const defferedAjax = [];
const events = [];
let calendar;

let calendarDate, thisMonth, thisYear, thisDay;

$(function () {
    calendar = $('#calendar');
    $('#decrease').click(decreaseMonth);
    $('#increase').click(advanceMonth);
    initMonth();
    initEvents();
});

function getMonthYear(month, year) {
    let date = new Date(year, month - 1, 1);

    return {month: (date.getMonth() + 1), year: date.getFullYear()};
}

async function initEvents() {
    for (let j = thisMonth; j < thisMonth + 4; ++j) {
        let monthYear = getMonthYear(j, thisYear);

        const daysThisMonth = getDaysInMonth(monthYear.month, monthYear.year);
        for (let i = 1; i < daysThisMonth; ++i) {
            defferedAjax.push(
                $.ajax({
                    dataType: "json",
                    url: 'https://event-parking-api.herokuapp.com/event/' + monthYear.year + '/' + monthYear.month + '/' + i
                }).then(addEvents)
            );
        }

    }

    $.when.apply($, defferedAjax).then(() => {
        loadCalendar()
    });

    months.push(thisMonth);
}

function getDaysInMonth(month, year) {
    const date = new Date(year, month, 0);
    return date.getDate();
}

async function addEvents(data) {
    for (let i = 0; i < data.length; ++i) {
        events.push({
            title: data[i]['title'],
            start: data[i]['start_date'],
            end: data[i]['end_date'],
            url: data[i]['url'],
{'fraction_non_alphanumeric': 0.16675271037687145, 'fraction_numerical': 0.004130098089829634, 'mean_word_length': 2.337639965546942, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 6, 'https://': 3, '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': '1739691', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1171, 'n_words': 262}