Fix an issue with new color code causing incorrect behavior with
converting colors to hex codes
This commit is contained in:
parent
dbf89dcaef
commit
3d97b39f1b
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* appchan x - Version 2.7.4 - 2014-01-02
|
||||
* appchan x - Version 2.7.4 - 2014-01-04
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
// ==/UserScript==
|
||||
|
||||
/*
|
||||
* appchan x - Version 2.7.4 - 2014-01-02
|
||||
* appchan x - Version 2.7.4 - 2014-01-04
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||
@ -13642,7 +13642,7 @@
|
||||
};
|
||||
|
||||
colorToHex = function(color) {
|
||||
var digits, hex;
|
||||
var digits, hex, len;
|
||||
if (color.substr(0, 1) === '#') {
|
||||
if (color.length !== 4) {
|
||||
return color.slice(1);
|
||||
@ -13650,11 +13650,14 @@
|
||||
return shortToLong(color.substr(1, 3));
|
||||
}
|
||||
}
|
||||
if (/[0-9a-f]{3}/i.test(color)) {
|
||||
if (color.length === 6) {
|
||||
return color;
|
||||
} else {
|
||||
return shortToLong(color);
|
||||
len = color.length;
|
||||
if (len === 3 || len === 6) {
|
||||
if (/[0-9a-f]{3}/i.test(color)) {
|
||||
if (color.length === 6) {
|
||||
return color;
|
||||
} else {
|
||||
return shortToLong(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (digits = color.match(/(.*?)rgba?\((\d+), ?(\d+), ?(\d+)(.*?)\)/)) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript
|
||||
/*
|
||||
* appchan x - Version 2.7.4 - 2014-01-02
|
||||
* appchan x - Version 2.7.4 - 2014-01-04
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||
@ -13653,7 +13653,7 @@
|
||||
};
|
||||
|
||||
colorToHex = function(color) {
|
||||
var digits, hex;
|
||||
var digits, hex, len;
|
||||
if (color.substr(0, 1) === '#') {
|
||||
if (color.length !== 4) {
|
||||
return color.slice(1);
|
||||
@ -13661,11 +13661,14 @@
|
||||
return shortToLong(color.substr(1, 3));
|
||||
}
|
||||
}
|
||||
if (/[0-9a-f]{3}/i.test(color)) {
|
||||
if (color.length === 6) {
|
||||
return color;
|
||||
} else {
|
||||
return shortToLong(color);
|
||||
len = color.length;
|
||||
if (len === 3 || len === 6) {
|
||||
if (/[0-9a-f]{3}/i.test(color)) {
|
||||
if (color.length === 6) {
|
||||
return color;
|
||||
} else {
|
||||
return shortToLong(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (digits = color.match(/(.*?)rgba?\((\d+), ?(\d+), ?(\d+)(.*?)\)/)) {
|
||||
|
||||
@ -16,8 +16,10 @@ class Color
|
||||
else
|
||||
return shortToLong color.substr(1, 3)
|
||||
|
||||
if /[0-9a-f]{3}/i.test color
|
||||
return if color.length is 6 then color else shortToLong color
|
||||
len = color.length
|
||||
if len in [3, 6]
|
||||
if /[0-9a-f]{3}/i.test color
|
||||
return if color.length is 6 then color else shortToLong color
|
||||
|
||||
if digits = color.match /(.*?)rgba?\((\d+), ?(\d+), ?(\d+)(.*?)\)/
|
||||
# [R, G, B] to 0xRRGGBB
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user