mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
[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:
parent
ef1fd19a98
commit
83749b16c7
1 changed files with 15 additions and 5 deletions
|
@ -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};
|
||||
|
|
Loading…
Reference in a new issue