Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. function getHolidayCalenderEvents(){
  2.  
  3. var events = [];
  4. //var holidayEvents = [];
  5.  
  6. $().SPServices({
  7. operation: "GetListItems",
  8. listName: "Holiday",
  9. completefunc: function(xData, Status) {
  10. console.log(xData.responseText);
  11. //$(xData.responseXML).find("Fields > Field").each(function() {
  12. $(xData.responseXML).SPFilterNode("z:row").each(function() {
  13. var $node = $(this);
  14.  
  15. var fADE = $( this ).attr( 'ows_fAllDayEvent' );
  16. var thisADE = false;
  17. var thisStart;
  18. var thisEnd;
  19.  
  20.  
  21. if ( typeof fADE !== "undefined" && fADE !== "0" ) {
  22. thisADE = true;
  23. var thisStart = $( this ).attr( 'ows_EventDate' );
  24. var thisEnd = $( this ).attr( 'ows_EndDate' );
  25. }
  26. else {
  27. // 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
  28. //date strings from SharePoint into local time. The formatDateToLocal() function above will take care of this. See comments in that function for more information.
  29. var thisStart = $( this ).attr( 'ows_EventDate' );
  30. //thisStart = thisStart.substring(0,9);
  31. var thisStartDate = moment(thisStart);
  32. var thisEnd = $( this ).attr( 'ows_EndDate' );
  33. //thisEnd = thisEnd.substring(0,9);
  34. var thisEndDate = moment(thisEnd);
  35. }
  36. var thisID = $( this ).attr( 'ows_ID' ).split( ';#' ).join( '.' );
  37.  
  38. // FullCalendar documentation specifies that recurring events should all have the same id value when building the events array (the id is optional,
  39. //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
  40. //information by simply splitting thisID.
  41. var eventID = thisID.split( '.' )[0];
  42.  
  43. // Get the event title. This is displayed on the calendar along with the start time of the event.
  44. var thisTitle = $( this ).attr( 'ows_Title' );
  45.  
  46. // 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.
  47. var thisDesc = $( this ).attr( 'ows_Description' );
  48.  
  49. // Add the event information to the events array so FullCalendar can display it.
  50. events.push({
  51. title: thisTitle,
  52. id: eventID,
  53. description: thisDesc,
  54. });
  55.  
  56. $('#calendar').fullCalendar('addEventSource', {
  57. events: events,
  58. color:'#66CCFF',
  59. allDay: true
  60.  
  61. });
  62.  
  63. events = [];
  64.  
  65. });
  66.  
  67.  
  68. }
  69.  
  70.  
  71. });
  72.  
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement