diff --git a/NEWS b/NEWS index dcc96cc83..b88ce7c0d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,16 @@ +2.3.4 (YYYY-MM-DD) +------------------ + +New features + - + +Enhancements + - + + +Bug fixes + - JavaScript exception when printing events from calendars with no assigned color (#3203) + 2.3.3a (2015-11-18) ------------------- diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 6eb5270a1..3b11a8183 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -440,17 +440,23 @@ function onAjaxRequestStateChange(http) { /* taken from Lightning */ function getContrastingTextColor(bgColor) { - var calcColor = bgColor.substring(1); - var red = parseInt(calcColor.substring(0, 2), 16); - var green = parseInt(calcColor.substring(2, 4), 16); - var blue = parseInt(calcColor.substring(4, 6), 16); + var textColor = "black"; + if (bgColor) { + var calcColor = bgColor.substring(1); + var red = parseInt(calcColor.substring(0, 2), 16); + var green = parseInt(calcColor.substring(2, 4), 16); + var blue = parseInt(calcColor.substring(4, 6), 16); - // Calculate the brightness (Y) value using the YUV color system. - var brightness = (0.299 * red) + (0.587 * green) + (0.114 * blue); + // Calculate the brightness (Y) value using the YUV color system. + var brightness = (0.299 * red) + (0.587 * green) + (0.114 * blue); - // Consider all colors with less than 56% brightness as dark colors and - // use white as the foreground color, otherwise use black. - return ((brightness < 144) ? "white" : "black"); + // Consider all colors with less than 56% brightness as dark colors and + // use white as the foreground color, otherwise use black. + if (brightness < 144) + textColor = "white"; + } + + return textColor; } function triggerAjaxRequest(url, callback, userdata, content, headers, attempt) {