Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getHolidayCalenderEvents(){
- var events = [];
- //var holidayEvents = [];
- $().SPServices({
- operation: "GetListItems",
- listName: "Holiday",
- completefunc: function(xData, Status) {
- console.log(xData.responseText);
- //$(xData.responseXML).find("Fields > Field").each(function() {
- $(xData.responseXML).SPFilterNode("z:row").each(function() {
- var $node = $(this);
- var fADE = $( this ).attr( 'ows_fAllDayEvent' );
- var thisADE = false;
- var thisStart;
- var thisEnd;
- if ( typeof fADE !== "undefined" && fADE !== "0" ) {
- thisADE = true;
- var thisStart = $( this ).attr( 'ows_EventDate' );
- var thisEnd = $( this ).attr( 'ows_EndDate' );
- }
- else {
- // Get the start and end date/time of the event. FullCalendar will parse date strings in local time automagically, so we need to convert the UTC
- //date strings from SharePoint into local time. The formatDateToLocal() function above will take care of this. See comments in that function for more information.
- var thisStart = $( this ).attr( 'ows_EventDate' );
- //thisStart = thisStart.substring(0,9);
- var thisStartDate = moment(thisStart);
- var thisEnd = $( this ).attr( 'ows_EndDate' );
- //thisEnd = thisEnd.substring(0,9);
- var thisEndDate = moment(thisEnd);
- }
- var thisID = $( this ).attr( 'ows_ID' ).split( ';#' ).join( '.' );
- // FullCalendar documentation specifies that recurring events should all have the same id value when building the events array (the id is optional,
- //but I'm including it for completeness). We can get the list item ID (which is the same for all instances of recurring events) without the recurrence
- //information by simply splitting thisID.
- var eventID = thisID.split( '.' )[0];
- // Get the event title. This is displayed on the calendar along with the start time of the event.
- var thisTitle = $( this ).attr( 'ows_Title' );
- // Get the event description. I don't use it in this example, but you could use it for something, perhaps as a tooltip when hovering over the event.
- var thisDesc = $( this ).attr( 'ows_Description' );
- // Add the event information to the events array so FullCalendar can display it.
- events.push({
- title: thisTitle,
- id: eventID,
- description: thisDesc,
- });
- $('#calendar').fullCalendar('addEventSource', {
- events: events,
- color:'#66CCFF',
- allDay: true
- });
- events = [];
- });
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement