$(document).ready( function() { // ---------------------- INITIALIZE ------------------------------ var fluxCalID = '#fluxCalendar'; // reference element on site $.fluxCal = $(fluxCalID); var fetchingRecords = false; // tracks if an AJAX request is active var weekStr = ""; $.ajaxSetup({cache:false}); var debug = 0; var mobileBreakPoint = 420; // ---------------------------------------------------------------- if (debug) { $("
") .css('position', 'fixed') .css('top', '5px') .css('right', '45px') .css('padding', '5px') .css('background-color', '#fff') .css('border', '1px solid #000') .appendTo('body'); } function loadEvents(){ var json = null; fetchingRecords = true; if ($.fluxCal.data('params')) { $.params = '&'+$.fluxCal.data('params'); } else { $.params = ''; } if ($.fluxCal.data('pastevents')) { $.pastevents = '&pastevents='+$.fluxCal.data('pastevents'); } else { $.pastevents = ''; } $.ajax({ 'async': false, 'global': false, 'url': 'http://calendar.instone.com/get.php?cal='+$.fluxCal.data('id')+$.params+'&offset='+$.fluxCal.data('offset')+'&limit='+$.fluxCal.data('limit')+$.pastevents, 'dataType': "jsonp", 'success': function(response) { if (!response.length==0) { // if we have events to show // append new records for (i in response) { // ------------- calendar template start ----------------- if (response[i].WeekEnd==1) { dayClass='holiday' } else {dayClass='weekday'} if (response[i].LocationName!=0) {locationData=""+response[i].LocationName+""} else {locationData=' '} if (response[i].TravelTime!='') {travelTime=response[i].TravelTime+' minutes'} else {travelTime=' '} if (response[i].ArriveTimeDT!='') {arriveBy=response[i].ArriveTime} else {arriveBy=' '} if (response[i].BusTime==null) {response[i].BusTime='';} if (response[i].Opponent) {opponent=response[i].Opponent} else {opponent=' '} if (response[i].Score) {score=response[i].Score} else {score=' '} // if (response[i].Description) {description="
"+response[i].Description+"
"} else {description=''} if (response[i].Description) {description="
"+response[i].Description+"
";} else {description='';} if (response[i].PostponedContent) {description="
"+response[i].PostponedContent+"
"} if (response[i].Directions==null) {response[i].Directions='';} if (response[i].Directions) {directions="

Directions

"+response[i].Directions+"

";} else {directions='';} if (response[i].Phone==null) {response[i].Phone='';} if (response[i].PhotoExists==1) { locationImg=""; photoClass="WithPhoto"; } else { locationImg=''; photoClass=""; } if (response[i].rsvp.length==4) { rsvpStr = ""+response[i].rsvp[0]+" "+response[i].rsvp[1]+" "+response[i].rsvp[2]+" "+response[i].rsvp[3]+""; } else { rsvpStr = "-"; } if (response[i].MultiDay==1) { response[i].Day = response[i].StartDay + '-' + response[i].EndDay; response[i].DayName = response[i].StartDayNameShort + '-' + response[i].EndDayNameShort; response[i].StTime = response[i].MultiStartTime + ' - ' + response[i].MultiEndTime } if (!$("#calWrap #calTitle").length) { subscribeURL = "Subscribe"; $("
"+subscribeURL+" | "+"Login
").appendTo("#calWrap"); $("

"+response[i].calendarName+"

").appendTo("#calWrap"); } if ($.fluxCal.data('week')=="show") { if (response[i].Week != $.fluxCal.data('weeknum')) { weekStr = "

Week "+response[i].Week+"

"; } else { weekStr = ""; } $.fluxCal.data('weeknum', response[i].Week); } if (response[i].Weather.length > 0) { weatherwidget = response[i].Weather; } else { weatherwidget = ""; } calStr = weekStr + "
"+ "
"+ "
"+ "

"+ ""+response[i].MonthYear+" "+response[i].Day+" "+response[i].DayName+""+ "

"+ weatherwidget+ "
"+ "
"+ "
"+ ""+response[i].EventType+""+ ""+response[i].Event+""+ "
"+ "
"+ "Team"+ ""+response[i].teamNames+""+ "
"+ "
"+ "Time"+ ""+response[i].StTime+""+ "
"+ "
"+ "Location"+ ""+locationData+""+ "
"+ "
"+ "Status"+ ""+response[i].apntStatus+""+ "
"+ description+ "
"+ locationImg+ "
"+ "Google Maps"+ "

"+response[i].LocationName+"

"+ "
"+ response[i].Address+"
"+ response[i].City+", "+response[i].StateID+" "+response[i].ZIP+"
"+response[i].Phone+ "
"+ directions+ "
"+ "
"+ "
"+ "
"+ "
"+response[i].addTo+"
"+ "
"; $(calStr).appendTo("#calWrap"); // --------------calendar template end ----------------- } $.fluxCal.data('offset', $.fluxCal.data('offset') + $.fluxCal.data('limit')); // update offset value fetchingRecords = false; if (debug) { $("#debug").text( $.fluxCal.data('offset') ); } } else if ($(".cal_calendarElm").length==0) { $("

There are no future events to show. Login

").appendTo("#calWrap"); } else { $("

End of future events.

").appendTo("#calWrap"); } } }); } if ($.fluxCal.length>0) {// if a fluxcalendar is embedded // toggle description box for a calendar event // $("body").on('click', ".fLocation a", function(){ // $(".descrBlck").hide(); // $(".descrBlck", $(this).closest('.fieldsBlck')).toggle(); // return false; // }); $("body").on('click', ".cal_fLocation a", function(){ $(".cal_descrBlck").hide(); // $(".cal_descrBlck", $(this).closest('.cal_fieldsBlck')).toggle(); $(".cal_descrBlck", $(this).closest('.cal_fieldsBlck')).css('display','flex'); return false; }); // triggering reachBottom event $(window).scroll( function(){ if ($(".cal_calendarElm").length != 0) { // if there is an embedded calendar with future events if ( ($(window).scrollTop() - $(".cal_calendarElm").last().offset().top + $(window).height()) > -($(window).height() ) && !fetchingRecords ) { $.fluxCal.trigger({type:'reachBottom'}); // trigger event } } }); // additional load of content $(document).on('reachBottom', fluxCalID, loadEvents); // initial load of content (function(){ $.fluxCal.empty(); $("
").appendTo(fluxCalID); loadEvents(); })(); } });