From d9a8528c8baaa1b94efa0b0efea0c22ccf988cf1 Mon Sep 17 00:00:00 2001 From: Brad Berger Date: Mon, 21 Jul 2014 09:42:44 +0200 Subject: [PATCH] Update backgroundColorByHexString function The implementation when `hexString.length == 4` was a bit off. The current version either doesn't actually use the `split` variable, so that variable could be removed, or used in place accessing the string characters as they are now. Opted for the former in this case, though it doesn't really matter. Since the length is always going to be a number, also changed to `===` instead, as well as updated the check for `#` at the beginning of the string. Since it's always looking for the `#` tat the beginning `charAt(0)` seems to be a better fit. --- www/statusbar.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/statusbar.js b/www/statusbar.js index 63967a9..96c0808 100644 --- a/www/statusbar.js +++ b/www/statusbar.js @@ -71,13 +71,13 @@ var StatusBar = { }, backgroundColorByHexString: function (hexString) { - if (hexString.indexOf("#") < 0) { + if (hexString.charAt(0) === "#") { hexString = "#" + hexString; } - if (hexString.length == 4) { + if (hexString.length === 4) { var split = hexString.split(""); - hexString = "#" + hexString[1] + hexString[1] + hexString[2] + hexString[2] + hexString[3] + hexString[3]; + hexString = "#" + split[1] + split[1] + split[2] + split[2] + split[3] + split[3]; } exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);