');
}
if( response.data[count].nextlink != "")
{
nextpageurl = response.data[count].nextlink;
jQuery("#o365_sp_view_load_more").css("display","block");
}
}
}
else
{
jQuery("#o365o365_events_view_data_loader").html('');
jQuery("#o365o365_events_view_data").append('
');
}
} else {
jQuery("#o365o365_events_view_data_loader").html('');
jQuery("#o365o365_events_view_data").append('
');
}
})
.fail(function()
{
jQuery("#o365o365_events_view_data_loader").html('');
alert("ERROR: Please Try Again!!!");
});
jQuery("#o365_sp_view_load_more").click(function(e)
{
if( nextpageurl != "" )
{
jQuery("#temp2o365_events_view_data").html('');
jQuery("#o365_sp_view_load_more").css("display","none");
jQuery("#o365_sp_view_loading").css("display","block");
var data = { 'action':'o365_sp_calendar_records','nextpage':nextpageurl,'shorcode_atts':{"url":"","siteid":"","listid":"","fromdate":"","todate":"","template":"","category":"","month":"","id":"o365","columns":"EndDate,EventDate,Category,ID,Location,Title,fAllDayEvent,RecurrenceID,fRecurrence,RecurrenceData,MasterSeriesItemID,Description","maxresults":1000,"type":"list","color":"","sort":"EventDate asc","timediff":"","userbinding":"no","timezone":"Central Standard Time","showcountdown":"no","mthviewdaylimit":"","eventtype":"","page_id":1770,"is_cached":"","cache_duration":"8","cf7id":"","addthis_id":"","addthis_tool_id":"","addthis":"","showsocialshare":"yes","showmap":"yes","showprintview":"yes"}};
jQuery.post( "https://valorandhonoroutdoors.com/wp-admin/admin-ajax.php", data , function( response, txtStatus, jqXHR )
{
all_recordes = [];
if(response.success && response.data.length > 0)
{
all_recordes = all_recordes.concat( response.data[0].data );
response.data[0].data = all_recordes;
response.data[0].data.sort(function(a, b){
var keyA = new Date(a.fields.EventDate),
keyB = new Date(b.fields.EventDate);
/* Compare the 2 dates */
if(keyA < keyB) return -1;
if(keyA > keyB) return 1;
return 0;
});
nextpageurl = "";
if( response.data.length > 0 )
{
jQuery("#o365_sp_view_loading").css("display","none");
for( var count=0; count< response.data.length; count++ )
{
for( var inner_count=0; inner_count< response.data[count].data.length; inner_count++ )
{
var EventDate = new Date(response.data[count].data[inner_count]["fields"]["EventDate"]);
var EndDate = new Date(response.data[count].data[inner_count]["fields"]["EndDate"]);
var monthShortNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var month_date = monthShortNames[EventDate.getMonth()];
var end_month_date = monthShortNames[EndDate.getMonth()];
if(EventDate.getDate() != EndDate.getDate())
{
if(response.data[count].data[inner_count]["fields"]["isAllDay"] == true)
{
timedata = EventDate.toLocaleString('en-US', { month:'short', timeZone: 'UTC' }) + ' '+EventDate.toLocaleString('en-US', { day:'numeric', timeZone: 'UTC' })+' @ ' + EventDate.toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true, timeZone: 'UTC' }) + ' - '+ ' 11:59 PM';
}
else
{
timedata = EventDate.toLocaleString('en-US', { month:'short', timeZone: 'UTC' }) + ' '+EventDate.toLocaleString('en-US', { day:'numeric', timeZone: 'UTC' })+' @ ' + EventDate.toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true, timeZone: 'UTC' }) + ' - '+ EndDate.toLocaleString('en-US', { month:'short', timeZone: 'UTC' }) + ' '+ EndDate.toLocaleString('en-US', { day:'numeric', timeZone: 'UTC' }) + ' @ '+EndDate.toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true, timeZone: 'UTC' });
}
}
else
{
timedata = EventDate.toLocaleString('en-US', { month:'short', timeZone: 'UTC' }) + ' '+EventDate.toLocaleString('en-US', { day:'numeric', timeZone: 'UTC' })+' @ ' + EventDate.toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true, timeZone: 'UTC' }) + ' - '+ EndDate.toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true, timeZone: 'UTC' });
}
if(response.data[count].data[inner_count]["fields"]["Location"]!=null)
{
area_loc = response.data[count].data[inner_count]["fields"]["Location"];
}
else
{
area_loc='';
}
var single_event_link = "";
if( base_ajax_url_check == "spcalendarsingleeventwpsite" )
{
single_event_link = 'https://valorandhonoroutdoors.com/sp-event/'+response.data[count].data[inner_count]["fields"]["Title"]+'/'+response.data[count].data[inner_count]["fields"]["id"]+ "///o365";
}
else if( base_ajax_url_check == "spcalendarsingleeventstaticsite" )
{
single_event_link = 'https://valorandhonoroutdoors.com/sp-event/' + '' + response.data[count].data[inner_count]["fields"]["Title"] + '/' + response.data[count].data[inner_count]["fields"]["id"]+ "&spsiteid=&splistid=/o365";
}
jQuery("#o365-cal__form_for_siteid_listid").attr("action", single_event_link );
jQuery("#o365o365_events_view_data").append('
'+EventDate.toLocaleString('en-US', { weekday:'short', timeZone: 'UTC' })+''+EventDate.toLocaleString('en-US', { day:'numeric', timeZone: 'UTC' })+'
'+response.data[count].data[inner_count]["fields"]["Title"]+'
'+timedata+'
'+area_loc+'
');
}
}
if( response.data[0].nextlink != "")
{
nextpageurl = response.data[0].nextlink;
jQuery("#o365_sp_view_load_more").css("display","block");
}
else
{
jQuery("#o365_sp_view_loading").css("display","none");
jQuery("#o365o365_events_view_data").append('
');
}
}
else
{
jQuery("#o365_sp_view_loading").css("display","none");
jQuery("#o365o365_events_view_data").append('
')
}
}
else
{
jQuery("#o365_sp_view_loading").css("display","none");
jQuery("#o365o365_events_view_data").append('
')
}
})
.fail(function()
{
jQuery("#o365_sp_view_loading").css("display","none");
alert("ERROR:Please Try Again!!!");
});
}
});
jQuery(document).on("click", ".o365_events_view_tbody", function(e)
{
var single_event_link_span = jQuery(this).find(".o365_events_view_tbody_span").attr("data-url");
jQuery("#o365-cal__form_for_siteid_listid").attr("action", single_event_link_span );
jQuery("#o365-cal__form_for_siteid_listid").submit();
});
function sortfunction()
{
}
});
Load More