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.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* appchan x - Version 2.7.4 - 2014-01-02
|
* appchan x - Version 2.7.4 - 2014-01-04
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||||
@ -13642,7 +13642,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
colorToHex = function(color) {
|
colorToHex = function(color) {
|
||||||
var digits, hex;
|
var digits, hex, len;
|
||||||
if (color.substr(0, 1) === '#') {
|
if (color.substr(0, 1) === '#') {
|
||||||
if (color.length !== 4) {
|
if (color.length !== 4) {
|
||||||
return color.slice(1);
|
return color.slice(1);
|
||||||
@ -13650,6 +13650,8 @@
|
|||||||
return shortToLong(color.substr(1, 3));
|
return shortToLong(color.substr(1, 3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
len = color.length;
|
||||||
|
if (len === 3 || len === 6) {
|
||||||
if (/[0-9a-f]{3}/i.test(color)) {
|
if (/[0-9a-f]{3}/i.test(color)) {
|
||||||
if (color.length === 6) {
|
if (color.length === 6) {
|
||||||
return color;
|
return color;
|
||||||
@ -13657,6 +13659,7 @@
|
|||||||
return shortToLong(color);
|
return shortToLong(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (digits = color.match(/(.*?)rgba?\((\d+), ?(\d+), ?(\d+)(.*?)\)/)) {
|
if (digits = color.match(/(.*?)rgba?\((\d+), ?(\d+), ?(\d+)(.*?)\)/)) {
|
||||||
hex = ((parseInt(digits[2], 10) << 16) | (parseInt(digits[3], 10) << 8) | (parseInt(digits[4], 10))).toString(16);
|
hex = ((parseInt(digits[2], 10) << 16) | (parseInt(digits[3], 10) << 8) | (parseInt(digits[4], 10))).toString(16);
|
||||||
while (hex.length < 6) {
|
while (hex.length < 6) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript
|
// 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.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||||
@ -13653,7 +13653,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
colorToHex = function(color) {
|
colorToHex = function(color) {
|
||||||
var digits, hex;
|
var digits, hex, len;
|
||||||
if (color.substr(0, 1) === '#') {
|
if (color.substr(0, 1) === '#') {
|
||||||
if (color.length !== 4) {
|
if (color.length !== 4) {
|
||||||
return color.slice(1);
|
return color.slice(1);
|
||||||
@ -13661,6 +13661,8 @@
|
|||||||
return shortToLong(color.substr(1, 3));
|
return shortToLong(color.substr(1, 3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
len = color.length;
|
||||||
|
if (len === 3 || len === 6) {
|
||||||
if (/[0-9a-f]{3}/i.test(color)) {
|
if (/[0-9a-f]{3}/i.test(color)) {
|
||||||
if (color.length === 6) {
|
if (color.length === 6) {
|
||||||
return color;
|
return color;
|
||||||
@ -13668,6 +13670,7 @@
|
|||||||
return shortToLong(color);
|
return shortToLong(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (digits = color.match(/(.*?)rgba?\((\d+), ?(\d+), ?(\d+)(.*?)\)/)) {
|
if (digits = color.match(/(.*?)rgba?\((\d+), ?(\d+), ?(\d+)(.*?)\)/)) {
|
||||||
hex = ((parseInt(digits[2], 10) << 16) | (parseInt(digits[3], 10) << 8) | (parseInt(digits[4], 10))).toString(16);
|
hex = ((parseInt(digits[2], 10) << 16) | (parseInt(digits[3], 10) << 8) | (parseInt(digits[4], 10))).toString(16);
|
||||||
while (hex.length < 6) {
|
while (hex.length < 6) {
|
||||||
|
|||||||
@ -16,6 +16,8 @@ class Color
|
|||||||
else
|
else
|
||||||
return shortToLong color.substr(1, 3)
|
return shortToLong color.substr(1, 3)
|
||||||
|
|
||||||
|
len = color.length
|
||||||
|
if len in [3, 6]
|
||||||
if /[0-9a-f]{3}/i.test color
|
if /[0-9a-f]{3}/i.test color
|
||||||
return if color.length is 6 then color else shortToLong color
|
return if color.length is 6 then color else shortToLong color
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user