diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index d00c8ca0c..7fdbe041e 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -1126,7 +1126,6 @@ function checkLibrarySCUploadStatus(){ else if (json.sc_id == "-3") { span.removeClass("progress").addClass("sc-error"); } - setTimeout(checkLibrarySCUploadStatus, 5000); } function checkSCUploadStatusRequest() { @@ -1138,6 +1137,7 @@ function checkLibrarySCUploadStatus(){ } $("#library_display span.progress").each(checkSCUploadStatusRequest); + setTimeout(checkLibrarySCUploadStatus, 5000); } function addQtipToSCIcons(){ 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 be42c53b7..634be5511 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -211,6 +211,7 @@ function viewDisplay( view ) { function eventRender(event, element, view) { + $(element).attr("id", "fc-show-instance-"+event.id); $(element).data("event", event); //only put progress bar on shows that aren't being recorded. @@ -228,35 +229,28 @@ function eventRender(event, element, view) { $(element).find(".fc-event-content").append(div); } - - //need to add id for every event to find the current show - if (view.name === 'agendaDay' || view.name === 'agendaWeek') { - $(element).find(".fc-event-time").attr("id", event.id); - } else if (view.name === 'month') { - $(element).find(".fc-event-title").attr("id", event.id); - } - + //add the record/rebroadcast/soundcloud icons if needed if (event.record === 1) { if (view.name === 'agendaDay' || view.name === 'agendaWeek') { if (event.soundcloud_id === -1) { - $(element).find(".fc-event-time").before(''); + $(element).find(".fc-event-time").before(''); } else if ( event.soundcloud_id > 0) { - $(element).find(".fc-event-time").before(''); + $(element).find(".fc-event-time").before(''); } else if (event.soundcloud_id === -2) { - $(element).find(".fc-event-time").before(''); + $(element).find(".fc-event-time").before(''); } else if (event.soundcloud_id === -3) { - $(element).find(".fc-event-time").before(''); + $(element).find(".fc-event-time").before(''); } } else if (view.name === 'month') { if(event.soundcloud_id === -1) { - $(element).find(".fc-event-title").after(''); + $(element).find(".fc-event-title").after(''); } else if (event.soundcloud_id > 0) { - $(element).find(".fc-event-title").after(''); + $(element).find(".fc-event-title").after(''); } else if (event.soundcloud_id === -2) { - $(element).find(".fc-event-title").after(''); + $(element).find(".fc-event-title").after(''); } else if (event.soundcloud_id === -3) { - $(element).find(".fc-event-title").after(''); + $(element).find(".fc-event-title").after(''); } } } @@ -267,27 +261,27 @@ function eventRender(event, element, view) { if (event.linked) { $(element) .find(".fc-event-time") - .before(''); + .before(''); } else { $(element) .find(".fc-event-time") - .before(''); + .before(''); } } else if (event.show_partial_filled === true) { if (event.linked) { $(element) .find(".fc-event-time") - .before(''); + .before(''); } else { $(element) .find(".fc-event-time") - .before(''); + .before(''); } } else { if (event.linked) { $(element) .find(".fc-event-time") - .before(''); + .before(''); } } } else if (view.name === 'month') { @@ -295,27 +289,27 @@ function eventRender(event, element, view) { if (event.linked) { $(element) .find(".fc-event-title") - .after(''); + .after(''); } else { $(element) .find(".fc-event-title") - .after(''); + .after(''); } } else if (event.show_partial_filled === true) { if (event.linked) { $(element) .find(".fc-event-title") - .after(''); + .after(''); } else { $(element) .find(".fc-event-title") - .after(''); + .after(''); } } else { if (event.linked) { $(element) .find(".fc-event-title") - .after(''); + .after(''); } } } @@ -324,9 +318,9 @@ function eventRender(event, element, view) { //rebroadcast icon if (event.rebroadcast === 1) { if (view.name === 'agendaDay' || view.name === 'agendaWeek') { - $(element).find(".fc-event-time").before(''); + $(element).find(".fc-event-time").before(''); } else if (view.name === 'month') { - $(element).find(".fc-event-title").after(''); + $(element).find(".fc-event-title").after(''); } } } @@ -334,7 +328,7 @@ function eventRender(event, element, view) { function eventAfterRender( event, element, view ) { $(element).find(".small-icon").live('mouseover',function(){ - addQtipsToIcons($(this)); + addQtipsToIcons($(this), event.id); }); } @@ -403,15 +397,25 @@ function getFullCalendarEvents(start, end, callback) { } function checkSCUploadStatus(){ - var url = baseUrl+'Library/get-upload-to-soundcloud-status/format/json'; + var url = baseUrl+'Library/get-upload-to-soundcloud-status/format/json', + id; $("span[class*=progress]").each(function(){ - var id = $(this).attr("id"); + id = $(this).parents("div.fc-event").data("event").id; + $.post(url, {format: "json", id: id, type:"show"}, function(json){ - if(json.sc_id > 0){ - $("span[id="+id+"]:not(.recording)").removeClass("progress").addClass("soundcloud"); - }else if(json.sc_id == "-3"){ - $("span[id="+id+"]:not(.recording)").removeClass("progress").addClass("sc-error"); + if (json.sc_id > 0){ + $("#fc-show-instance-"+id) + .find(".progress") + .removeClass("progress") + .addClass("soundcloud"); } + else if (json.sc_id == "-3"){ + $("#fc-show-instance-"+id) + .find(".progress") + .removeClass("progress") + .addClass("sc-error"); + } + setTimeout(checkSCUploadStatus, 5000); }); }); @@ -425,7 +429,7 @@ function getCurrentShow(){ $el; $.post(url, {format: "json"}, function(json) { if (json.current_show === true) { - $el = $("div[class*=fc-event-time][id="+json.si_id+"]"); + $el = $("div[class*=fc-event-time]"); if (view_name === 'agendaDay' || view_name === 'agendaWeek') { /* Need to remove now-playing class because if user @@ -440,40 +444,40 @@ function getCurrentShow(){ * icon will overwrite it. */ $el.siblings().remove("span[class=small-icon recording]"); - $el.before(''); + $el.before(''); } else if ($el.siblings().hasClass("small-icon rebroadcast")) { /* Without removing rebroadcast icon, the now playing * icon will overwrite it. */ $el.siblings().remove("span[class=small-icon rebroadcast]"); - $el.before(''); + $el.before(''); } else { - $el.before(''); + $el.before(''); } } } else if (view_name === 'month') { - if (!$("span[class*=fc-event-title][id="+json.si_id+"]").siblings().hasClass("small-icon now-playing")) { - $("span[class*=fc-event-title][id="+json.si_id+"]").after(''); + if (!$("span[class*=fc-event-title]").siblings().hasClass("small-icon now-playing")) { + $("span[class*=fc-event-title]").after(''); } } } //remove icon from shows that have ended $(".now-playing").each(function(){ - id = $(this).attr("id"); - if (id != json.si_id) { - $(this).remove("span[small-icon now-playing]"); - } - }); + id = $(this).parents("div.fc-event").data("event").id; + + if (id != json.si_id) { + $(this).remove("span[small-icon now-playing]"); + } + }); + setTimeout(getCurrentShow, 5000); }); } - -function addQtipsToIcons(ele){ - var id = $(ele).attr("id"); - - if($(ele).hasClass("progress")){ +function addQtipsToIcons(ele, id){ + + if ($(ele).hasClass("progress")){ $(ele).qtip({ content: { text: $.i18n._("Uploading in progress...") diff --git a/airtime_mvc/public/js/airtime/schedule/schedule.js b/airtime_mvc/public/js/airtime/schedule/schedule.js index 82531a726..b313aba74 100644 --- a/airtime_mvc/public/js/airtime/schedule/schedule.js +++ b/airtime_mvc/public/js/airtime/schedule/schedule.js @@ -58,24 +58,22 @@ function confirmCancelRecordedShow(show_instance_id){ } } -function uploadToSoundCloud(show_instance_id){ +function uploadToSoundCloud(show_instance_id, el){ - var url = baseUrl+"Schedule/upload-to-sound-cloud"; - var span = $(window.triggerElement).find(".recording"); + var url = baseUrl+"Schedule/upload-to-sound-cloud", + $el = $(el), + $span = $el.find(".soundcloud"); - $.post(url, - {id: show_instance_id, format: "json"}, - function(json){ - scheduleRefetchEvents(json); - }); + $.post(url, {id: show_instance_id, format: "json"}); - if(span.length == 0){ - span = $(window.triggerElement).find(".soundcloud"); - span.removeClass("soundcloud") - .addClass("progress"); - }else{ - span.removeClass("recording") - .addClass("progress"); + //first upload to soundcloud. + if ($span.length === 0){ + $span = $("", {"class": "progress"}); + + $el.find(".fc-event-title").after($span); + } + else { + $span.removeClass("soundcloud").addClass("progress"); } } @@ -93,8 +91,6 @@ function checkCalendarSCUploadStatus(){ else if (json.sc_id == "-3") { span.removeClass("progress").addClass("sc-error"); } - - setTimeout(checkCalendarSCUploadStatus, 5000); } function checkSCUploadStatusRequest() { @@ -106,6 +102,7 @@ function checkCalendarSCUploadStatus(){ } $("#schedule_calendar span.progress").each(checkSCUploadStatusRequest); + setTimeout(checkCalendarSCUploadStatus, 5000); } function findViewportDimensions() { @@ -421,7 +418,7 @@ $(document).ready(function() { if (oItems.soundcloud_upload !== undefined) { callback = function() { - uploadToSoundCloud(data.id); + uploadToSoundCloud(data.id, this.context); }; oItems.soundcloud_upload.callback = callback; }