Elkins School District (2022)

×Info! PRESS ENTER TO JUMP TO TOP OF '+ sameTypeWidgetRowNum + ' (FACEBOOK FEED), SHIFT+TAB TO CONTINUE INTO FB FEED, OR TAB TO CONTINUE

×Info! PRESS ENTER TO SKIP PAST '+ sameTypeWidgetRowNum + ' (TWITTER FEED), OR TAB TO CONTINUE

×Info! PRESS ENTER TO JUMP TO TOP OF '+ sameTypeWidgetRowNum + ' (TWITTER FEED), SHIFT+TAB TO CONTINUE INTO TWITTER FEED, OR TAB TO CONTINUE

'; var calendarRightIcons = ''; //add print button calendarRightIcons += ''; //add email button calendarRightIcons += ''; //add subscribe button calendarRightIcons += ''; $('#fullpage-calendar-content-'+page_calendar_id+' .fc-left').each(function(e) { $(this).append(calendarListToggle); }); $('#fullpage-calendar-content-'+page_calendar_id+' .fc-right').each(function(e) { $(this).prepend(calendarRightIcons); }); //Loop through each calendar and give sub elements ids so can access later $('.calendarDisplay').each(function(e) { var calendar_id = $(this).data('calendar'); var foo = $(this); if (calendar_id) { if (calendar_id && $.isNumeric(calendar_id)) { //loop through fc-view-container of current calendar, assign an id to toggle display //and append listView div to display list $(foo.children('.fc-view-container')).each(function(e) { if ($(this).hasClass('fc-view-container')) { $(this).attr('id', 'fc-view-container_' + calendar_id); } }); foo.append('

'); $('#listView_' + calendar_id).hide(); } } }); //On click of icon, change active classes $(document).delegate('.listIcon', "click", function(event, state) { var calendar_id = $(this).data('calendar'); if (calendar_id) { if ($('#calIcon_' + calendar_id).hasClass('fc-state-active')) { $('#calIcon_' + calendar_id).removeClass('fc-state-active'); $('#listIcon_' + calendar_id).addClass('fc-state-active'); } $('#fc-view-container_' + calendar_id).hide(); $('#listView_' + calendar_id).show(); //$('#listView_' + calendar_id).html('

Elkins School District (1)

'); //populate correct events based on current day var calGetDates = $('#full-page-calendar'+page_calendar_id).fullCalendar('getCalendar'); var startUnix = moment(calGetDates.view.start._d).unix() * 1000; var endUnix = moment(calGetDates.view.end._d).unix() * 1000; //first hour of next day 00:00:00 in GMT var listOutput = ''; if (calendars) { $(calendars).each(function(i, val) { if (parseInt(val.id) == parseInt(page_calendar_id)) { //loop through every day from start->end, find every event that occurs on that day var days = date_diff_indays(startUnix, endUnix); //counter for loop var currentDay = new Date(startUnix); //incremented placeholder var today = moment().format('L'); //current day is one before start, increment once currentDay.setDate(currentDay.getDate() + 1); if (days && !isNaN(days)) { //store each days events in an array to sort by time before populating day var dayEvents = {}; var currentDayCounter = 0; for(var i = 0; i <= days; i++) { //loop through events to see if any occur on current day if (val.events) { if (i != currentDayCounter) { //if dayEvents has events, display non-timed events first, //sort the events that are timed, display timed events if (!jQuery.isEmptyObject(dayEvents)) { var nonTimedEvents = {}; var displayEventCounter = 0; Object.keys(dayEvents).forEach(function(i,val) { //add to display events if no time, remove from array if (!dayEvents[i]['start_time'] && !dayEvents[i]['end_time']) { nonTimedEvents[displayEventCounter] = dayEvents[i]['html_output']; delete dayEvents[i]; displayEventCounter++; } else if (dayEvents[i]['start_time']) { if (dayEvents[i]['start_time'] && dayEvents[i]['start_date']) { var start_date_rep = dayEvents[i]['start_date'].replaceAll("-","/"); var startDateTime = start_date_rep + ' ' + dayEvents[i]['start_time']; dayEvents[i]['start_date_time'] = Date.parse(startDateTime); } } }); //sort any remaining (timed) items in array if (!jQuery.isEmptyObject(dayEvents)) { var sortTimes = []; //compile simple array of id and timestamp for sorting Object.keys(dayEvents).forEach(function(i,val) { if (dayEvents[i].start_date_time) { sortTimes.push([dayEvents[i].start_date_time, dayEvents[i].id]); } }); sortTimes.sort(sortFunction); function sortFunction(a, b) { if (a[0] === b[0]) { return 0; } else { return (a[0] < b[0]) ? -1 : 1; } } } else { var sortTimes = []; } if (!jQuery.isEmptyObject(nonTimedEvents) || sortTimes && sortTimes.length > 0) { //due to currentDay being evaulated at the end of the loop and logic executes when //a new day occurs, must use the previous day var currentDayTmp = new Date(currentDay); var previousDay = new Date(currentDayTmp.setDate(currentDayTmp.getDate() - 1)); var monthName = moment(previousDay).format('MMM'); var dayName = moment(previousDay).format('ddd'); var year = moment(previousDay).format('YYYY'); //if today, make box green if (today == moment(previousDay).format('L')) { var boxColor = 'successBox'; } else { var boxColor = 'lightGrayBox'; } listOutput += '

'; listOutput += '

'; listOutput += monthName; listOutput += '

' + previousDay.getDate() + '

'; listOutput += dayName; listOutput += '

'; listOutput += '

'; var eventPerDayCounter = 1; //list untimed events if (!jQuery.isEmptyObject(nonTimedEvents)) { var nonTimedLength = Object.keys(nonTimedEvents).length; Object.keys(nonTimedEvents).forEach(function(i,val) { listOutput += nonTimedEvents[i]; //If not last item, put divider if (eventPerDayCounter != nonTimedLength) { listOutput += '

'; } eventPerDayCounter++; }); } if (sortTimes && sortTimes.length > 0) { var sortedPerDay = 1; //add divider if there are any non-timed events before the timed events if (eventPerDayCounter != 1) { listOutput += '

'; } //loop through sorted times to display them in chronological order by start time $.each(sortTimes, function(i, val) { Object.keys(dayEvents).forEach(function(k,obj) { if (dayEvents[k]['id'] && dayEvents[k]['id'] == sortTimes[i][1]) { listOutput += dayEvents[k]['html_output']; //If not last item, put divider if (sortedPerDay != sortTimes.length) { listOutput += '

'; } sortedPerDay++; } }); }); } listOutput += '

'; listOutput += '

'; listOutput += '

'; } } dayEvents = {}; currentDayCounter = i; } var currentUnix = currentDay.getTime() / 1000; //convert to seconds which moment() uses var eventOutput = ''; $(val.events).each(function(k, obj) { //have to get the start AND end of start day to correctly see if on that day var startOfDayStart = moment(obj.start_date).startOf('day'); var eventStartUnixDayBegin = startOfDayStart.unix(); var endOfDayStart = moment(obj.start_date).endOf('day'); var eventStartUnixDayEnd = endOfDayStart.unix(); //have to get the start AND end of end day to correctly see if on that day var startOfDayEnd = moment(obj.end_date).startOf('day'); var eventEndUnixDayBegin = startOfDayEnd.unix(); var endOfDayEnd = moment(obj.end_date).endOf('day'); var eventEndUnixDayEnd = endOfDayEnd.unix(); //if all day it spans into the next day time wise since timezone //isn't being calculated, fix for list view by taking off 12 hours so //it doesn't span into the next day if (obj.allDay == true) { eventEndUnixDayBegin -= 43200; eventEndUnixDayEnd -= 43200; } if ((eventStartUnixDayBegin <= currentUnix && eventEndUnixDayEnd >= currentUnix) || //multi day event in middle (eventStartUnixDayBegin <= currentUnix && eventStartUnixDayEnd >= currentUnix) || //event starts this day (eventEndUnixDayBegin <= currentUnix && eventEndUnixDayEnd >= currentUnix)) { //event ends this day eventOutput = ''; eventOutput += '

'; eventOutput += ''; eventOutput += ''; eventOutput += ''; eventOutput += ''; eventOutput += ''; eventOutput += ''; eventOutput += '
'; eventOutput += '

'; eventOutput += '
'; // eventOutput += ''; // eventOutput += obj.title; // eventOutput += ''; eventOutput += '

'; eventOutput += obj.title; eventOutput += '

'; eventOutput += '

'; if (!obj.googleCalendarId && obj.calendar_name) { if (parseInt(page_calendar_id) != obj.calendar_id) { if (obj.calendar_name.indexOf('Calendar: ') >= 0) { var title = obj.calendar_name.replace('Calendar: ', ''); } else { var title = obj.calendar_name; } eventOutput += '


'; eventOutput += '(Source: ' + title + ')'; eventOutput += '

'; } } else if (obj.url) { eventOutput += '

'; eventOutput += '
'; eventOutput += ''; eventOutput += ''; if (obj.calendar_name) { eventOutput += obj.calendar_name; } eventOutput += ''; eventOutput += '

'; } //don't show times if all day if (val.events['all_day'] != true) { eventOutput += '

'; eventOutput += '
'; //they did not set an end time, defaults to 12:00:00 if (val.events[k]['start_time'] && val.events[k]['end_time']) { eventOutput += val.events[k]['start'] + ' ' + val.events[k]['start_time']; eventOutput += ' to ' + val.events[k]['start'] + ' ' +val.events[k]['end_time']; } else if (val.events['start_time']) { eventOutput += val.events[k]['start'] + ' ' + val.events[k]['start_time']; } eventOutput += '

'; } eventOutput += '
'; if (obj.description && obj.description.trim()) { eventOutput += '

'; eventOutput += '
'; eventOutput += obj.description.trim(); eventOutput += '

'; } if (obj.location && obj.location.trim()) { eventOutput += '

'; eventOutput += '
'; eventOutput += obj.location.trim(); eventOutput += '

'; } if (obj.map && obj.map.trim()) { eventOutput += '

'; eventOutput += 'Map'; eventOutput += '

'; } if (obj.directions && obj.directions.trim()) { eventOutput += '

'; eventOutput += '
'; eventOutput += obj.directions.trim(); eventOutput += '

'; } if (obj.attachment) { eventOutput += '

'; eventOutput += '
'; var attachmentName = obj.attachment + ''; // var attachmentName = 'Attachments'; if (obj.attachment.indexOf('/')) { var attachmentArr = obj.attachment.split('/'); var attachmentArrLength = attachmentArr.length - 1; attachmentName = attachmentArr[attachmentArrLength]; } eventOutput += ''; // eventOutput += ''; eventOutput += ''; eventOutput += attachmentName; // eventOutput += 'Attachment'; eventOutput += ''; eventOutput += '

'; } eventOutput += '

'; //add event to day array for sorting if (i == currentDayCounter) { dayEvents[obj.id] = { 'id' : obj.id, 'html_output' : '

' + eventOutput + '

', 'start' : obj.start, 'start_date' : obj.start_date, 'start_time' : obj.start_time, 'end' : obj.end, 'end_date' : obj.end_date, 'end_time' : obj.end_time, 'all_day' : obj.all_day }; } eventPerDayCounter++; } }); } //increment to next day currentDay.setDate(currentDay.getDate() + 1); } } } }); } if (listOutput && listOutput.length > 0) { listOutput = '

    ' + listOutput + '

'; $('#listView_' + calendar_id).html(listOutput); } else { //no events var listOutput = '

    '; listOutput += '

    '; listOutput += '

    No events Occurred.

    '; listOutput += '

    '; listOutput += '

    '; listOutput += '

'; $('#listView_' + calendar_id).html(listOutput); } } }); //calculate days between two dates var date_diff_indays = function(date1, date2) { dt1 = new Date(date1); dt2 = new Date(date2); return Math.floor((Date.UTC(dt2.getFullYear(), dt2.getMonth(), dt2.getDate()) - Date.UTC(dt1.getFullYear(), dt1.getMonth(), dt1.getDate()) ) /(1000 * 60 * 60 * 24)); } $(document).delegate('.subscribeIcon', "click", function(event, state) { var calendar_id = $(this).data('calendar'); window.location.href = '/page/subscribe?calendar_id=' + calendar_id; }); //On click of icon, change active classes $(document).delegate('.calendarIcon', "click", function(event, state) { var calendar_id = $(this).data('calendar'); var id = $(this).attr('id'); if (calendar_id) { $('#calIcon_' + calendar_id).addClass('fc-state-active'); if ($('#listIcon_' + calendar_id).hasClass('fc-state-active')) { $('#listIcon_' + calendar_id).removeClass('fc-state-active'); } //change view from list to calendar, show calendar, hide list $('#fc-view-container_' + calendar_id).show(); $('#listView_' + calendar_id).hide(); } }); $(document).delegate('.printIcon', 'click', function(event, state) { var startDate = $('#full-page-calendar'+page_calendar_id).fullCalendar('getView').intervalStart.unix(); var endDate = $('#full-page-calendar'+page_calendar_id).fullCalendar('getView').intervalEnd.unix(); var calendar_id = $(this).data('calendar'); if (startDate && endDate && calendar_id) { if ($(this).hasClass('emailIcon')) { window.location.href = '/page/page_calendar_print?calendar_id=' + calendar_id + '&start_date=' + startDate + '&end_date=' + endDate + '&email=true'; } else { window.location.href = '/page/page_calendar_print?calendar_id=' + calendar_id + '&start_date=' + startDate + '&end_date=' + endDate; } } }); //if linked from sidebar module change view and date to get vars &view=day &date=2016-08-11 if ('' && '') { switch('') { case 'day': $('#full-page-calendar'+page_calendar_id).fullCalendar('changeView', 'agendaDay'); $('#full-page-calendar'+page_calendar_id).fullCalendar('gotoDate', ''); break; } } });

You might also like

Latest Posts

Article information

Author: Annamae Dooley

Last Updated: 07/04/2022

Views: 6606

Rating: 4.4 / 5 (65 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Annamae Dooley

Birthday: 2001-07-26

Address: 9687 Tambra Meadow, Bradleyhaven, TN 53219

Phone: +9316045904039

Job: Future Coordinator

Hobby: Archery, Couponing, Poi, Kite flying, Knitting, Rappelling, Baseball

Introduction: My name is Annamae Dooley, I am a witty, quaint, lovely, clever, rich, sparkling, powerful person who loves writing and wants to share my knowledge and understanding with you.