From b44ff58c78b84e1b644156cf4ff2c73aaefa634a Mon Sep 17 00:00:00 2001 From: Just van den Broecke Date: Tue, 12 Aug 2014 14:18:22 +0200 Subject: [PATCH] issue #230 - IE8 fix for generating random color for WFS layers --- src/script/plugins/WFSSource.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/script/plugins/WFSSource.js b/src/script/plugins/WFSSource.js index 48896bf9..07a4d6ae 100644 --- a/src/script/plugins/WFSSource.js +++ b/src/script/plugins/WFSSource.js @@ -229,8 +229,11 @@ gxp.plugins.WFSSource = Ext.extend(gxp.plugins.LayerSource, { return keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4); } - // Generate a random color (thanks to Mark Prins) - var colour = '#' + ('000000' + Math.round(0xffffff * Math.random()).toString(16)).substr(-6); + // Generate a random color (thanks to Mark Prins) - not working in IE8... + // var colour = '#' + Math.round(0xffffff * Math.random()).toString(16); + + // better (IE compat): http://www.paulirish.com/2009/random-hex-color-code-snippets/ + var colour = '#'+('00000'+(Math.random()*(1<<24)|0).toString(16)).slice(-6); // Save color in record to generate StyleMap later record.data.colour = colour;