diff --git a/airtime_mvc/public/js/airtime/dashboard/helperfunctions.js b/airtime_mvc/public/js/airtime/dashboard/helperfunctions.js index 12b419d96..58b3ff5bb 100644 --- a/airtime_mvc/public/js/airtime/dashboard/helperfunctions.js +++ b/airtime_mvc/public/js/airtime/dashboard/helperfunctions.js @@ -11,6 +11,23 @@ function popup(mylink){ return false; } +/* Take a string representing a date in the format 2012-04-25 and return + * a javascript date object representing this date. */ +function getDateFromString(time){ + var date = time.split("-"); + + if (date.length != 3){ + return null; + } + + var year = parseInt(date[0], 10); + var month = parseInt(date[1], 10) -1; + var day = parseInt(date[2], 10); + + return new Date(year, month, day); + +} + function convertSecondsToDaysHoursMinutesSeconds(seconds){ if (seconds < 0) seconds = 0; diff --git a/airtime_mvc/public/js/airtime/schedule/add-show.js b/airtime_mvc/public/js/airtime/schedule/add-show.js index e33b6fbea..14e1c9fdc 100644 --- a/airtime_mvc/public/js/airtime/schedule/add-show.js +++ b/airtime_mvc/public/js/airtime/schedule/add-show.js @@ -110,7 +110,22 @@ function setAddShowEvents() { form.find("#add_show_repeats").click(function(){ $(this).blur(); form.find("#schedule-show-when > fieldset:last").toggle(); + + var checkBoxSelected = false; + var days = form.find("#add_show_day_check-element input").each( function() { + var currentCheckBox = $(this).attr("checked"); + if (currentCheckBox && currentCheckBox == "checked"){ + checkBoxSelected = true; + } + }); + + if (!checkBoxSelected){ + var d = getDateFromString(form.find("#add_show_start_date").attr("value")); + if ( d != null) + form.find("#add_show_day_check-"+d.getDay()).attr('checked', true); + } + //must switch rebroadcast displays if(form.find("#add_show_rebroadcast").attr('checked')) {