diff --git a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js index 88435c84e..281e904f9 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -255,28 +255,31 @@ function eventRender(event, element, view) { } //add scheduled show content empty icon - if (view.name === 'agendaDay' || view.name === 'agendaWeek') { - if (event.show_empty === 1 && event.record === 0 && event.rebroadcast === 0) { - if (event.soundcloud_id === -1) { - $(element).find(".fc-event-time").before(''); - } else if (event.soundcloud_id > 0) { - - } else if (event.soundcloud_id === -2) { - - } else if (event.soundcloud_id === -3) { + addIcon = checkEmptyShowStatus(event); + if (!addIcon) { + if (view.name === 'agendaDay' || view.name === 'agendaWeek') { + if (event.show_empty === 1 && event.record === 0 && event.rebroadcast === 0) { + if (event.soundcloud_id === -1) { + $(element).find(".fc-event-time").before(''); + } else if (event.soundcloud_id > 0) { + + } else if (event.soundcloud_id === -2) { + } else if (event.soundcloud_id === -3) { + + } } - } - } else if (view.name === 'month') { - if (event.show_empty === 1 && event.record === 0 && event.rebroadcast === 0) { - if (event.soundcloud_id === -1) { - $(element).find(".fc-event-title").after(''); - } else if (event.soundcloud_id > 0) { - - } else if (event.soundcloud_id === -2) { - - } else if (event.soundcloud_id === -3) { + } else if (view.name === 'month') { + if (event.show_empty === 1 && event.record === 0 && event.rebroadcast === 0) { + if (event.soundcloud_id === -1) { + $(element).find(".fc-event-title").after(''); + } else if (event.soundcloud_id > 0) { + + } else if (event.soundcloud_id === -2) { + } else if (event.soundcloud_id === -3) { + + } } } } @@ -416,6 +419,7 @@ function getCurrentShow(){ function addQtipToSCIcons(ele){ var id = $(ele).attr("id"); + console.log(ele); if($(ele).hasClass("progress")){ $(ele).qtip({ content: { @@ -508,6 +512,36 @@ function addQtipToSCIcons(ele){ } } +/* This functions does two things: + * 1. Checks if each event(i.e. a show) is over and removes the show empty icon if it is + * 2. Else, if an event is passed in, it checks if the event(i.e. a show) is over + * This gets checked when we are deciding if the show-empty icon should be added + * at the beginning of an event render callback. + */ +function checkEmptyShowStatus(e) { + var currDate = new Date(); + var endTime; + + if (e === undefined) { + var events = $('#schedule_calendar').fullCalendar('clientEvents'); + + $.each(events, function(i, event){ + endTime = event.end; + $emptyIcon = $("span[id="+event.id+"][class='small-icon show-empty']"); + if (currDate.getTime() > endTime.getTime() && $emptyIcon.length === 1) { + $emptyIcon.remove(); + } + }); + } else { + endTime = e.end; + var showOver = false; + if (currDate.getTime() > endTime.getTime()) { + showOver = true; + } + return showOver; + } +} + //Alert the error and reload the page //this function is used to resolve concurrency issue function alertShowErrorAndReload(){ @@ -518,6 +552,7 @@ function alertShowErrorAndReload(){ $(document).ready(function(){ setInterval( "checkSCUploadStatus()", 5000 ); setInterval( "getCurrentShow()", 5000 ); + setInterval( "checkEmptyShowStatus()", 5000 ); }); var view_name;