diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index da508f31d..8fcb64cda 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1042,7 +1042,7 @@ SQL; if (!empty($show["background_color"])) { $event["color"] = "#" . $show["background_color"]; } else { - $event["color"] = "#" . DEFAULT_SHOW_COLOR; + $event["color"] = "#" . self::getDefaultBackgroundColor($startsDT);//DEFAULT_SHOW_COLOR; } foreach ($options as $key => $value) { @@ -1054,6 +1054,22 @@ SQL; return $events; } + /** Get a palettized colour for the show. */ + private static function getDefaultBackgroundColor($date) { + + $palette = [['42d5a1', '56bd99', '65ab93', '7b938b'], + ['42a4d5', '569bbd', '6594ab', '7b8b93'], + ['4264d5', '566fbd', '6576ab', '7b8193']]; + + //$hashValue = (md5($date->format('d'))[0] % $cols) + ((intval($date->format('h'))/24) % $rows); + $row = intval($date->format('d')) % sizeof($palette); + $foo = $date->format('H'); + $col = intval(intval($date->format('H'))/24.0 * sizeof($palette[0])); + //$color = $palette[$hashValue % sizeof($palette)]; + $color = $palette[$row][$col]; + return $color; + } + /** * Calculates the percentage of a show scheduled given the start and end times in date/time format * and the time_filled as the total time the schow is scheduled for in time format. diff --git a/airtime_mvc/public/css/fullcalendar.css b/airtime_mvc/public/css/fullcalendar.css index 95f8427e0..2ce2e3a52 100644 --- a/airtime_mvc/public/css/fullcalendar.css +++ b/airtime_mvc/public/css/fullcalendar.css @@ -606,7 +606,7 @@ table.fc-border-separate { width: 100%; height: 100%; background: #fff; - opacity: .3; + opacity: 0.3; filter: alpha(opacity=30); } diff --git a/airtime_mvc/public/js/airtime/schedule/add-show.js b/airtime_mvc/public/js/airtime/schedule/add-show.js index d9a8887ed..326bf9a14 100644 --- a/airtime_mvc/public/js/airtime/schedule/add-show.js +++ b/airtime_mvc/public/js/airtime/schedule/add-show.js @@ -75,10 +75,17 @@ function setupStartTimeWidgets() { $('#add_show_start_date').removeProp('disabled'); $('#add_show_start_time').removeProp('disabled'); } - } } +function calculateShowColor() { + var bgColorEle = $("#add_show_background_color"); + var textColorEle = $("#add_show_color"); + var colorCode = stringToColor($('#add_show_start_time').val());//$(this).val()); + //bgColorEle.val(colorCode); + //textColorEle.val(getContrastYIQ(colorCode)); +} + //$el is DOM element #add-show-form //form is the new form contents to append to $el function redrawAddShowForm($el, form) { @@ -226,7 +233,10 @@ function intToRGB(i){ function stringToColor(s) { - var palette = ['d56f42', 'aad542', '7242d5', '42d563', 'd542be']; + var palette = ['42d5a1', '56bd99', '65ab93', '7b938b', + '42a4d5', '569bbd', '6594ab', '7b8b93', + '4264d5', '566fbd', '6576ab', '7b8193']; + //var palette = ['d56f42', 'aad542', '7242d5', '42d563', 'd542be']; return palette[Math.abs(hashCode(s)) % palette.length]; //return intToRGB(hashCode(s)); } @@ -943,13 +953,12 @@ function setAddShowEvents(form) { // Since Zend's setAttrib won't apply through the wrapper, set accept=image/* here $("#add_show_logo").prop("accept", "image/*"); - var bgColorEle = $("#add_show_background_color"); - var textColorEle = $("#add_show_color"); - $('#add_show_name').bind('input', 'change', function(){ - var colorCode = stringToColor($(this).val()); - bgColorEle.val(colorCode); - textColorEle.val(getContrastYIQ(colorCode)); + + //$('#add_show_name').bind('input', 'change', function(){ + $('#add_show_start_time').bind('input', 'change', function(){ + calculateShowColor(); }); + } function showErrorSections() { 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 62e0f4f0f..2ead8e7ea 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -112,6 +112,7 @@ function dayClick(date, allDay, jsEvent, view){ $("#add_show_start_time").val(startTime_string) $("#add_show_end_time").val(endTimeString) } + calculateShowColor(); $("#schedule-show-when").show(); openAddShowForm();