<commit_before>---
layout: default
title: Calendar
---
<article class="container card">
    <div class="card-body">
        <h1 class="card-title">Calendar <a href="/feeds/calendar.ics" target="_blank"><span class="far fa-calendar-alt icon-orange"></span></a></h1>
        <div id="menu">
            <span id="menu-navi">
                <button type="button" class="btn btn-default btn-sm move-today" data-action="move-today">Today</button>
                <button type="button" class="btn btn-default btn-sm move-day" data-action="move-prev">
                <i class="fas fa-chevron-left" data-action="move-prev"></i>
                </button>
                <button type="button" class="btn btn-default btn-sm move-day" data-action="move-next">
                <i class="fas fa-chevron-right" data-action="move-next"></i>
                </button>
            </span>
            <span id="renderRange" class="render-range"></span>
        </div>
        <br>
        
        <div id="calendar"></div>
        <br>
    </div>
</article>

<link rel="stylesheet" type="text/css" href="https://uicdn.toast.com/tui-calendar/latest/tui-calendar.css" />
<script src="https://uicdn.toast.com/tui.code-snippet/latest/tui-code-snippet.js"></script>
<script src="https://uicdn.toast.com/tui.dom/v3.0.0/tui-dom.js"></script>
<script src="https://uicdn.toast.com/tui-calendar/latest/tui-calendar.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ical.js/1.3.0/ical.min.js" integrity="sha256-1oaCObP6yNz1ouAW50FOpNBBSNqZtpINrbL8B4W+kmM=" crossorigin="anonymous"></script>
<script>
// Load iCal feed (generated by Jekyll)
fetch('/feeds/calendar.ics').then((res) => {
    // If fails to load, error and stop
    if(!res.ok) {
        document.querySelector('#calendar').innerText = 'Could not load feed (request failed)';
        return;
    }

    // Get body of request
    res.text().then((str) => {
        try {
            // Parse with ical.js
            let parsed = ICAL.parse(str);

            // Helpers for month text
            const monthText = document.querySelector('.render-range');
            const updateMonthText = () => {
                monthText.innerText = new Intl.DateTimeFormat('en-US', { month: 'long', year: 'numeric' }).format(calendar.getDate().toDate());
            }

            // Initialize calendar
            let calendar = new tui.Calendar('#calendar', {
                defaultView: 'month',
                isReadOnly: true,
                usageStatistics: false,
                useCreationPopup: false,
                useDetailPopup: true
            });

            // Bind buttons to calendar
            document.querySelector('[data-action="move-today"]').addEventListener('click', () => { calendar.today(); updateMonthText(); });
            document.querySelector('[data-action="move-next"]').addEventListener('click', () => { calendar.next(); updateMonthText(); });
            document.querySelector('[data-action="move-prev"]').addEventListener('click', () => { calendar.prev(); updateMonthText(); });
            updateMonthText();

            // Array of events to eventually be loaded into the calendar
            let evtArr = [];

            // Iterate through events from iCal feed
            parsed[2].forEach((i, no) => {
                // Define base parameters
                let obj = {
                    bgColor: 'black',
                    body: '',
                    category: 'time',
                    color: 'white',
                    id: `${no}`,
                    isReadOnly: true,
                    isVisible: true
                };

                // Define vars for special cases
                let rrule = false;
                let url = '';

                // Iterate through parameters and map to object properties
                // (Convert iCal property names to tui.calendar property names)
                i[1].forEach((j) => {
                    switch (j[0]) {
                        //case 'uid':
                        //    obj.id = j[3];
                        //    break;
                        case 'summary':
                            // Remove prefix added in iCal generation
                            obj.title = (j[3].startsWith('RITlug: ') ? j[3].substring(8) : j[3]);
                            break;
                        case 'description':
                            obj.body = j[3];
                            break;
                        case 'dtstart':
                            // ical.js adds empty time strings if an all-day event
                            // strip these and set all-day properties instead if needed
                            if(j[3].endsWith('T::')) {
                                obj.category = 'allday';
                                obj.isAllDay = true;
                                obj.start = j[3].replace('T::','');
                            } else {
                                obj.start = j[3];
                            }
                            break;
                        case 'dtend':
                            // Strip empty time strings if needed (see dtstart comments)
                            obj.end = j[3].replace('T::','');
                            break;
                        case 'location':
                            obj.location = j[3];<commit_msg>:clipboard: calendar: Remove summary prefix logic (#121)<commit_after>---
layout: default
title: Calendar
---
<article class="container card">
    <div class="card-body">
        <h1 class="card-title">Calendar <a href="/feeds/calendar.ics" target="_blank"><span class="far fa-calendar-alt icon-orange"></span></a></h1>
        <div id="menu">
            <span id="menu-navi">
                <button type="button" class="btn btn-default btn-sm move-today" data-action="move-today">Today</button>
                <button type="button" class="btn btn-default btn-sm move-day" data-action="move-prev">
                <i class="fas fa-chevron-left" data-action="move-prev"></i>
                </button>
                <button type="button" class="btn btn-default btn-sm move-day" data-action="move-next">
                <i class="fas fa-chevron-right" data-action="move-next"></i>
                </button>
            </span>
            <span id="renderRange" class="render-range"></span>
        </div>
        <br>

        <div id="calendar"></div>
        <br>
    </div>
</article>

<link rel="stylesheet" type="text/css" href="https://uicdn.toast.com/tui-calendar/latest/tui-calendar.css" />
<script src="https://uicdn.toast.com/tui.code-snippet/latest/tui-code-snippet.js"></script>
<script src="https://uicdn.toast.com/tui.dom/v3.0.0/tui-dom.js"></script>
<script src="https://uicdn.toast.com/tui-calendar/latest/tui-calendar.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ical.js/1.3.0/ical.min.js" integrity="sha256-1oaCObP6yNz1ouAW50FOpNBBSNqZtpINrbL8B4W+kmM=" crossorigin="anonymous"></script>
<script>
// Load iCal feed (generated by Jekyll)
fetch('/feeds/calendar.ics').then((res) => {
    // If fails to load, error and stop
    if(!res.ok) {
        document.querySelector('#calendar').innerText = 'Could not load feed (request failed)';
        return;
    }

    // Get body of request
    res.text().then((str) => {
        try {
            // Parse with ical.js
            let parsed = ICAL.parse(str);

            // Helpers for month text
            const monthText = document.querySelector('.render-range');
            const updateMonthText = () => {
                monthText.innerText = new Intl.DateTimeFormat('en-US', { month: 'long', year: 'numeric' }).format(calendar.getDate().toDate());
            }

            // Initialize calendar
            let calendar = new tui.Calendar('#calendar', {
                defaultView: 'month',
                isReadOnly: true,
                usageStatistics: false,
                useCreationPopup: false,
                useDetailPopup: true
            });

            // Bind buttons to calendar
            document.querySelector('[data-action="move-today"]').addEventListener('click', () => { calendar.today(); updateMonthText(); });
            document.querySelector('[data-action="move-next"]').addEventListener('click', () => { calendar.next(); updateMonthText(); });
            document.querySelector('[data-action="move-prev"]').addEventListener('click', () => { calendar.prev(); updateMonthText(); });
            updateMonthText();

            // Array of events to eventually be loaded into the calendar
            let evtArr = [];

            // Iterate through events from iCal feed
            parsed[2].forEach((i, no) => {
                // Define base parameters
                let obj = {
                    bgColor: 'black',
                    body: '',
                    category: 'time',
                    color: 'white',
                    id: `${no}`,
                    isReadOnly: true,
                    isVisible: true
                };

                // Define vars for special cases
                let rrule = false;
                let url = '';

                // Iterate through parameters and map to object properties
                // (Convert iCal property names to tui.calendar property names)
                i[1].forEach((j) => {
                    switch (j[0]) {
                        case 'summary':
                            obj.title = j[3];
                            break;
                        case 'description':
                            obj.body = j[3];
                            break;
                        case 'dtstart':
                            // ical.js adds empty time strings if an all-day event
                            // strip these and set all-day properties instead if needed
                            if(j[3].endsWith('T::')) {
                                obj.category = 'allday';
                                obj.isAllDay = true;
                                obj.start = j[3].replace('T::','');
                            } else {
                                obj.start = j[3];
                            }
                            break;
                        case 'dtend':
                            // Strip empty time strings if needed (see dtstart comments)
                            obj.end = j[3].replace('T::','');
                            break;
                        case 'location':
                            obj.location = j[3];
{'fraction_non_alphanumeric': 0.14065601663673316, 'fraction_numerical': 0.005955194252764912, 'mean_word_length': 1.4547563805104409, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 99, 'https://': 10, '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': '6290909', 'n_tokens_mistral': 2839, 'n_tokens_neox': 2731, 'n_words': 592}