From ed4309ce41557d39576108731631ac59aa6e3120 Mon Sep 17 00:00:00 2001 From: "John Molakvoæ (skjnldsv)" Date: Mon, 7 May 2018 10:50:33 +0200 Subject: Unify colour algorithm output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- core/js/placeholder.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/js/placeholder.js b/core/js/placeholder.js index a0dfe8491d4..81f0b12e61a 100644 --- a/core/js/placeholder.js +++ b/core/js/placeholder.js @@ -62,13 +62,16 @@ (function ($) { String.prototype.toRgb = function() { - var hash = this.toLowerCase().replace(/[^0-9a-f]+/g, ''); + // Normalize hash + var hash = this.toLowerCase(); // Already a md5 hash? - if( !hash.match(/^[0-9a-f]{32}$/g) ) { + if( hash.match(/^([0-9a-f]{4}-?){8}$/) === null ) { hash = md5(hash); } + hash = hash.replace(/[^0-9a-f]/g, ''); + function Color(r,g,b) { this.r = r; this.g = g; @@ -116,7 +119,7 @@ var result = Array(); // Splitting evenly the string - for (var i in hash) { + for (var i=0; i