[Case 4315] ESLint Pass 5 resolves hex already defined issue (details below).

* var hex was declared both the hexToRGB and hexToHsb functions.
    * hexToRGB was updated to have a more explicit var name
    * hexToRGB & hexToHSB also had the function param name updated to clarify the expected
      object type.  Also error statements and early returns were added should an unsupported
      object type be received.

* Issue Count is now 28

Changes Committed:
    modified:   scripts/system/html/js/colpick.js
This commit is contained in:
LaShonda Hopper 2018-02-09 17:35:03 -05:00
parent ef1fd19a98
commit 83749b16c7

View file

@ -496,12 +496,22 @@ For usage and examples: colpick.com/plugin
};
}();
// Color space convertions
var hexToRgb = function (hex) {
var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
var hexToRgb = function (hexString) {
if (typeof hexString !== "string") {
print("Error - ColPick.js::hexToRgb expects string object.");
return;
}
var hexNumber = parseInt(((hexString.indexOf('#') > -1) ? hexString.substring(1) : hexString), 16);
return { r: hexNumber >> 16, g: (hexNumber & 0x00FF00) >> 8, b: (hexNumber & 0x0000FF)};
};
var hexToHsb = function (hex) {
return rgbToHsb(hexToRgb(hex));
var hexToHsb = function (hexString) {
if (typeof hexString !== "string") {
print("Error - ColPick.js::hexToHsb expects string object.");
return;
}
return rgbToHsb(hexToRgb(hexString));
};
var rgbToHsb = function (rgb) {
var hsb = {h: 0, s: 0, b: 0};