From 8dcb1f8f3dd5a1171eb4656e41ec076911bbf5e9 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 13 Jul 2012 10:28:50 -0400 Subject: [PATCH] CC-4101Calendar displays white on white for certain show names, making shows invisible --- airtime_mvc/public/js/airtime/schedule/add-show.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/airtime_mvc/public/js/airtime/schedule/add-show.js b/airtime_mvc/public/js/airtime/schedule/add-show.js index d85742e4b..9e1d8e704 100644 --- a/airtime_mvc/public/js/airtime/schedule/add-show.js +++ b/airtime_mvc/public/js/airtime/schedule/add-show.js @@ -118,6 +118,14 @@ function stringToColor(s) return intToRGB(hashCode(s)); } +function getContrastYIQ(hexcolor){ + var r = parseInt(hexcolor.substr(0,2),16); + var g = parseInt(hexcolor.substr(2,2),16); + var b = parseInt(hexcolor.substr(4,2),16); + var yiq = ((r*299)+(g*587)+(b*114))/1000; + return (yiq >= 128) ? '000000' : 'ffffff'; +} + function setAddShowEvents() { @@ -578,9 +586,11 @@ function setAddShowEvents() { } 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)); }); }